Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/gis/parser_local_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void G__md_print_python_short_version(FILE *file, const char *indent,
void G__md_print_cli_long_version(FILE *file, const char *indent);
void G__md_print_python_long_version(FILE *file, const char *indent,
bool tools_api);
void G__md_print_escaped(FILE *f, const char *str);
void G__md_print_escaped(FILE *f, const char *str, const char *indent);
void G__md_print_escaped_for_options(FILE *f, const char *str);
int G__option_num_tuple_items(const struct Option *opt);

Expand Down
32 changes: 16 additions & 16 deletions lib/gis/parser_md_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ void print_cli_flag(FILE *file, const char *key, const char *label,
fprintf(file, "\n");
if (label != NULL) {
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, label);
G__md_print_escaped(file, "\t", indent);
G__md_print_escaped(file, label, indent);
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
}
if (description != NULL) {
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, description);
G__md_print_escaped(file, "\t", indent);
G__md_print_escaped(file, description, indent);
}
}

Expand Down Expand Up @@ -82,24 +82,24 @@ void print_cli_option(FILE *file, const struct Option *opt, const char *indent)
fprintf(file, "\n");
if (opt->label) {
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, opt->label);
G__md_print_escaped(file, "\t", indent);
G__md_print_escaped(file, opt->label, indent);
}
if (opt->description) {
if (opt->label) {
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
}
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, opt->description);
G__md_print_escaped(file, "\t", indent);
G__md_print_escaped(file, opt->description, indent);
}

if (opt->options) {
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
fprintf(file, "%s: *", _("Allowed values"));
G__md_print_escaped_for_options(file, opt->options);
fprintf(file, "*");
Expand All @@ -109,10 +109,10 @@ void print_cli_option(FILE *file, const struct Option *opt, const char *indent)
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
fprintf(file, "%s:", _("Default"));
fprintf(file, " *");
G__md_print_escaped(file, opt->def);
G__md_print_escaped(file, opt->def, indent);
fprintf(file, "*");
}

Expand All @@ -137,19 +137,19 @@ void print_cli_option(FILE *file, const struct Option *opt, const char *indent)
thumbnails = "northarrows";

if (thumbnails) {
G__md_print_escaped(file, "\t\t");
G__md_print_escaped(file, "\t\t", indent);
fprintf(file, "![%s](%s/%s.png) ", opt->opts[i],
thumbnails, opt->opts[i]);
}
else {
G__md_print_escaped(file, "\t\t");
G__md_print_escaped(file, "\t\t", indent);
}
}
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
fprintf(file, "**");
G__md_print_escaped(file, opt->opts[i]);
G__md_print_escaped(file, opt->opts[i], indent);
fprintf(file, "**: ");
G__md_print_escaped(file, opt->descs[i]);
G__md_print_escaped(file, opt->descs[i], indent);
}
i++;
}
Expand Down
24 changes: 17 additions & 7 deletions lib/gis/parser_md_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,27 @@
fputs(escaped, f); \
break

void G__md_print_escaped(FILE *f, const char *str)
void G__md_print_escaped(FILE *f, const char *str, const char *indent)
{
const char *s;

for (s = str; *s; s++) {
switch (*s) {
do_escape('\n', "\\\n");
do_escape('\t', "    ");
do_escape('<', "&lt;");
do_escape('>', "&gt;");
do_escape('*', "\\*");
case '\n':
fputs(MD_NEWLINE "\n", f);
fputs(indent, f);
break;
case '\t':
fputs("&nbsp;&nbsp;&nbsp;&nbsp;", f);
break;
case '<':
fputs("&lt;", f);
break;
case '>':
fputs("&gt;", f);
break;
case '*':
fputs("\\*", f);
break;
default:
fputc(*s, f);
}
Expand Down
52 changes: 26 additions & 26 deletions lib/gis/parser_md_python.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ void print_python_short_flag(FILE *file, const char *key, const char *label,
const char *description, const char *indent)
{
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
fprintf(file, "**%s**", key);
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
if (label != NULL) {
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t\t");
G__md_print_escaped(file, label);
G__md_print_escaped(file, "\t\t", indent);
G__md_print_escaped(file, label, indent);
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
}
if (description != NULL) {
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t\t");
G__md_print_escaped(file, description);
G__md_print_escaped(file, "\t\t", indent);
G__md_print_escaped(file, description, indent);
}
}

Expand All @@ -62,20 +62,20 @@ void print_python_long_flag(FILE *file, const char *key, const char *label,
fprintf(file, "\n");
if (label != NULL) {
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, label);
G__md_print_escaped(file, "\t", indent);
G__md_print_escaped(file, label, indent);
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
}
if (description != NULL) {
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, description);
G__md_print_escaped(file, "\t", indent);
G__md_print_escaped(file, description, indent);
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
}
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
const char *flag_default = "*None*";
fprintf(file, "Default: %s", flag_default);
}
Expand Down Expand Up @@ -172,23 +172,23 @@ void print_python_option(FILE *file, const struct Option *opt,
fprintf(file, "\n");
if (opt->label) {
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, opt->label);
G__md_print_escaped(file, "\t", indent);
G__md_print_escaped(file, opt->label, indent);
}
if (opt->description) {
if (opt->label) {
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
}
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, opt->description);
G__md_print_escaped(file, "\t", indent);
G__md_print_escaped(file, opt->description, indent);
}
if (opt->gisprompt || opt->key_desc) {
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
fprintf(file, "%s: ", _("Used as"));
}
if (opt->gisprompt) {
Expand All @@ -213,7 +213,7 @@ void print_python_option(FILE *file, const struct Option *opt,
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
fprintf(file, "%s: *", _("Allowed values"));
G__md_print_escaped_for_options(file, opt->options);
fprintf(file, "*");
Expand All @@ -240,19 +240,19 @@ void print_python_option(FILE *file, const struct Option *opt,
thumbnails = "northarrows";

if (thumbnails) {
G__md_print_escaped(file, "\t\t");
G__md_print_escaped(file, "\t\t", indent);
fprintf(file, "![%s](%s/%s.png) ", opt->opts[i],
thumbnails, opt->opts[i]);
}
else {
G__md_print_escaped(file, "\t\t");
G__md_print_escaped(file, "\t\t", indent);
}
}
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
fprintf(file, "**");
G__md_print_escaped(file, opt->opts[i]);
G__md_print_escaped(file, opt->opts[i], indent);
fprintf(file, "**: ");
G__md_print_escaped(file, opt->descs[i]);
G__md_print_escaped(file, opt->descs[i], indent);
}
i++;
}
Expand All @@ -262,10 +262,10 @@ void print_python_option(FILE *file, const struct Option *opt,
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
fprintf(file, "%s:", _("Default"));
fprintf(file, " *");
G__md_print_escaped(file, opt->def);
G__md_print_escaped(file, opt->def, indent);
fprintf(file, "*");
}
}
Expand Down Expand Up @@ -465,12 +465,12 @@ void G__md_print_python_short_version(FILE *file, const char *indent,
if (!tuple_items &&
(opt->type == TYPE_INTEGER || opt->type == TYPE_DOUBLE)) {
fprintf(file, "*");
G__md_print_escaped(file, opt->answer);
G__md_print_escaped(file, opt->answer, indent);
fprintf(file, "*");
}
else {
fprintf(file, "*\"");
G__md_print_escaped(file, opt->answer);
G__md_print_escaped(file, opt->answer, indent);
fprintf(file, "\"*");
}
}
Expand Down Expand Up @@ -529,7 +529,7 @@ void G__md_print_python_long_version(FILE *file, const char *indent,
fprintf(file, MD_NEWLINE);
fprintf(file, "\n");
fprintf(file, "%s", indent);
G__md_print_escaped(file, "\t");
G__md_print_escaped(file, "\t", indent);
fprintf(file, "Allowed values: ");
flag = &st->first_flag;
while (st->n_flags && flag != NULL) {
Expand Down
Loading