Переглянути джерело

Clean up parser refactoring

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@39841 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 15 роки тому
батько
коміт
349da72497

+ 8 - 8
lib/gis/parser.c

@@ -84,7 +84,7 @@ static int set_flag(int);
 static int contains(const char *, int);
 static int contains(const char *, int);
 static int is_option(const char *);
 static int is_option(const char *);
 static int set_option(const char *);
 static int set_option(const char *);
-static int check_opts();
+static int check_opts(void);
 static int check_an_opt(const char *, int, const char *, const char **, char **);
 static int check_an_opt(const char *, int, const char *, const char **, char **);
 static int check_int(const char *, const char **);
 static int check_int(const char *, const char **);
 static int check_double(const char *, const char **);
 static int check_double(const char *, const char **);
@@ -419,28 +419,28 @@ int G_parser(int argc, char **argv)
 	/* If first arg is "--interface-description" then print out
 	/* If first arg is "--interface-description" then print out
 	 * a xml description of the task */
 	 * a xml description of the task */
 	if (strcmp(argv[1], "--interface-description") == 0) {
 	if (strcmp(argv[1], "--interface-description") == 0) {
-	    usage_xml();
+	    G__usage_xml();
 	    exit(EXIT_SUCCESS);
 	    exit(EXIT_SUCCESS);
 	}
 	}
 
 
 	/* If first arg is "--html-description" then print out
 	/* If first arg is "--html-description" then print out
 	 * a html description of the task */
 	 * a html description of the task */
 	if (strcmp(argv[1], "--html-description") == 0) {
 	if (strcmp(argv[1], "--html-description") == 0) {
-	    usage_html();
+	    G__usage_html();
 	    exit(EXIT_SUCCESS);
 	    exit(EXIT_SUCCESS);
 	}
 	}
 
 
 	/* If first arg is "--wps-process-description" then print out
 	/* If first arg is "--wps-process-description" then print out
 	 * the wps process description of the task */
 	 * the wps process description of the task */
 	if (strcmp(argv[1], "--wps-process-description") == 0) {
 	if (strcmp(argv[1], "--wps-process-description") == 0) {
-	    wps_print_process_description();
+	    G__wps_print_process_description();
 	    exit(EXIT_SUCCESS);
 	    exit(EXIT_SUCCESS);
 	}
 	}
 
 
 	/* If first arg is "--script" then then generate
 	/* If first arg is "--script" then then generate
 	 * g.parser boilerplate */
 	 * g.parser boilerplate */
 	if (strcmp(argv[1], "--script") == 0) {
 	if (strcmp(argv[1], "--script") == 0) {
-	    script();
+	    G__script();
 	    exit(EXIT_SUCCESS);
 	    exit(EXIT_SUCCESS);
 	}
 	}
 
 
@@ -683,7 +683,7 @@ void G_set_keywords(const char *keywords)
 }
 }
 
 
 
 
-int uses_new_gisprompt(void)
+int G__uses_new_gisprompt(void)
 {
 {
     struct Option *opt;
     struct Option *opt;
     char age[KEYLENGTH];
     char age[KEYLENGTH];
@@ -710,7 +710,7 @@ int uses_new_gisprompt(void)
     return 0;
     return 0;
 }
 }
 
 
-void print_keywords(FILE *fd, void (*format)(FILE *, const char *))
+void G__print_keywords(FILE *fd, void (*format)(FILE *, const char *))
 {
 {
     int i;
     int i;
 
 
@@ -1291,7 +1291,7 @@ static int check_overwrite(void)
     return (error);
     return (error);
 }
 }
 
 
-void split_gisprompt(const char *gisprompt, char *age, char *element,
+static void split_gisprompt(const char *gisprompt, char *age, char *element,
 			    char *desc)
 			    char *desc)
 {
 {
     const char *ptr1;
     const char *ptr1;

+ 2 - 2
lib/gis/parser_help.c

@@ -33,7 +33,7 @@ void G_usage(void)
     int len, n;
     int len, n;
     int new_prompt = 0;
     int new_prompt = 0;
 
 
-    new_prompt = uses_new_gisprompt();
+    new_prompt = G__uses_new_gisprompt();
 
 
     if (!st->pgm_name)		/* v.dave && r.michael */
     if (!st->pgm_name)		/* v.dave && r.michael */
 	st->pgm_name = G_program_name();
 	st->pgm_name = G_program_name();
@@ -49,7 +49,7 @@ void G_usage(void)
     }
     }
     if (st->module_info.keywords) {
     if (st->module_info.keywords) {
 	fprintf(stderr, _("\nKeywords:\n "));
 	fprintf(stderr, _("\nKeywords:\n "));
-	print_keywords(stderr, NULL);
+	G__print_keywords(stderr, NULL);
 	fprintf(stderr, "\n");
 	fprintf(stderr, "\n");
     }
     }
 
 

+ 3 - 3
lib/gis/parser_html.c

@@ -6,14 +6,14 @@ static void print_escaped_for_html(FILE * f, const char *str);
 /*!
 /*!
   \brief Print module usage description in HTML format.
   \brief Print module usage description in HTML format.
 */
 */
-void usage_html(void)
+void G__usage_html(void)
 {
 {
     struct Option *opt;
     struct Option *opt;
     struct Flag *flag;
     struct Flag *flag;
     const char *type;
     const char *type;
     int new_prompt = 0;
     int new_prompt = 0;
 
 
-    new_prompt = uses_new_gisprompt();
+    new_prompt = G__uses_new_gisprompt();
 
 
     if (!st->pgm_name)		/* v.dave && r.michael */
     if (!st->pgm_name)		/* v.dave && r.michael */
 	st->pgm_name = G_program_name();
 	st->pgm_name = G_program_name();
@@ -47,7 +47,7 @@ void usage_html(void)
 
 
     fprintf(stdout, "<h2>%s</h2>\n", _("KEYWORDS"));
     fprintf(stdout, "<h2>%s</h2>\n", _("KEYWORDS"));
     if (st->module_info.keywords) {
     if (st->module_info.keywords) {
-	print_keywords(stdout, NULL);
+	G__print_keywords(stdout, NULL);
 	fprintf(stdout, "\n");
 	fprintf(stdout, "\n");
     }
     }
     fprintf(stdout, "<h2>%s</h2>\n", _("SYNOPSIS"));
     fprintf(stdout, "<h2>%s</h2>\n", _("SYNOPSIS"));

+ 4 - 4
lib/gis/parser_interface.c

@@ -7,7 +7,7 @@
  * \param[in,out] fp file to write to
  * \param[in,out] fp file to write to
  * \param str string to write
  * \param str string to write
  */
  */
-void print_escaped_for_xml(FILE * fp, const char *str)
+static void print_escaped_for_xml(FILE * fp, const char *str)
 {
 {
     for (; *str; str++) {
     for (; *str; str++) {
 	switch (*str) {
 	switch (*str) {
@@ -29,7 +29,7 @@ void print_escaped_for_xml(FILE * fp, const char *str)
 /*!
 /*!
   \brief Print module usage description in XML format.
   \brief Print module usage description in XML format.
 */
 */
-void usage_xml(void)
+void G__usage_xml(void)
 {
 {
     struct Option *opt;
     struct Option *opt;
     struct Flag *flag;
     struct Flag *flag;
@@ -39,7 +39,7 @@ void usage_xml(void)
     char *encoding;
     char *encoding;
     int new_prompt = 0;
     int new_prompt = 0;
 
 
-    new_prompt = uses_new_gisprompt();
+    new_prompt = G__uses_new_gisprompt();
 
 
     /* gettext converts strings to encoding returned by nl_langinfo(CODESET) */
     /* gettext converts strings to encoding returned by nl_langinfo(CODESET) */
 
 
@@ -81,7 +81,7 @@ void usage_xml(void)
 
 
     if (st->module_info.keywords) {
     if (st->module_info.keywords) {
 	fprintf(stdout, "\t<keywords>\n\t\t");
 	fprintf(stdout, "\t<keywords>\n\t\t");
-	print_keywords(stdout, print_escaped_for_xml);
+	G__print_keywords(stdout, print_escaped_for_xml);
 	fprintf(stdout, "\n\t</keywords>\n");
 	fprintf(stdout, "\n\t</keywords>\n");
     }
     }
 
 

+ 11 - 11
lib/gis/parser_local_proto.h

@@ -28,7 +28,7 @@ struct Item
     struct Item *next_item;
     struct Item *next_item;
 };
 };
 
 
-typedef struct state {
+struct state {
     int no_interactive;
     int no_interactive;
     int n_opts;
     int n_opts;
     int n_flags;
     int n_flags;
@@ -52,10 +52,10 @@ typedef struct state {
     struct Item first_item;
     struct Item first_item;
     struct Item *current_item;
     struct Item *current_item;
     int n_items;
     int n_items;
-}state_type;
+};
 
 
 
 
-extern state_type *st;
+extern struct state *st;
 
 
 #define BAD_SYNTAX    1
 #define BAD_SYNTAX    1
 #define OUT_OF_RANGE  2
 #define OUT_OF_RANGE  2
@@ -66,12 +66,12 @@ extern state_type *st;
 
 
 /* functions which are used by several parser functions in different files */
 /* functions which are used by several parser functions in different files */
 
 
-void usage_xml(void);
-void usage_html(void);
-void script(void);
-void wps_print_process_description(void);
-void print_escaped_for_xml(FILE * fp, const char *str);
-int  uses_new_gisprompt(void);
-void print_keywords(FILE *fd, void (*format)(FILE *, const char *));
+void G__usage_xml(void);
+void G__usage_html(void);
+void G__script(void);
+void G__wps_print_process_description(void);
+int  G__uses_new_gisprompt(void);
+void G__print_keywords(FILE *fd, void (*format)(FILE *, const char *));
+
+#endif
 
 
-#endif

+ 2 - 2
lib/gis/parser_script.c

@@ -1,6 +1,6 @@
 #include "parser_local_proto.h"
 #include "parser_local_proto.h"
 
 
-void script(void)
+void G__script(void)
 {
 {
     FILE *fp = stdout;
     FILE *fp = stdout;
     char *type;
     char *type;
@@ -40,7 +40,7 @@ void script(void)
 	fprintf(fp, "#%% description: %s\n", st->module_info.description);
 	fprintf(fp, "#%% description: %s\n", st->module_info.description);
     if (st->module_info.keywords) {
     if (st->module_info.keywords) {
 	fprintf(fp, "#%% keywords: ");
 	fprintf(fp, "#%% keywords: ");
-	print_keywords(fp, NULL);
+	G__print_keywords(fp, NULL);
 	fprintf(fp, "\n");
 	fprintf(fp, "\n");
     }
     }
     fprintf(fp, "#%%end\n");
     fprintf(fp, "#%%end\n");

+ 21 - 2
lib/gis/parser_wps.c

@@ -36,6 +36,25 @@ static void wps_print_literal_input_output(int , int , int , const char *,
                                 const char *, const char *, const char *, int ,
                                 const char *, const char *, const char *, int ,
                                 const char **, int , const char *, int );
                                 const char **, int , const char *, int );
 
 
+static void print_escaped_for_xml(FILE * fp, const char *str)
+{
+    for (; *str; str++) {
+	switch (*str) {
+	case '&':
+	    fputs("&amp;", fp);
+	    break;
+	case '<':
+	    fputs("&lt;", fp);
+	    break;
+	case '>':
+	    fputs("&gt;", fp);
+	    break;
+	default:
+	    fputc(*str, fp);
+	}
+    }
+}
+
 /*!
 /*!
  * \brief Print the WPS 1.0.0 process description XML document to stdout
  * \brief Print the WPS 1.0.0 process description XML document to stdout
  *
  *
@@ -53,7 +72,7 @@ static void wps_print_literal_input_output(int , int , int , const char *,
  *
  *
  * */
  * */
 
 
-void wps_print_process_description()
+void G__wps_print_process_description(void)
 {
 {
     struct Option *opt;
     struct Option *opt;
     struct Flag *flag;
     struct Flag *flag;
@@ -73,7 +92,7 @@ void wps_print_process_description()
     int min = 0, max = 0;
     int min = 0, max = 0;
     int num_keywords = 0;
     int num_keywords = 0;
     int found_output = 0;
     int found_output = 0;
-    new_prompt = uses_new_gisprompt();
+    new_prompt = G__uses_new_gisprompt();
 
 
     /* gettext converts strings to encoding returned by nl_langinfo(CODESET) */
     /* gettext converts strings to encoding returned by nl_langinfo(CODESET) */