file name separator changes.

Pierre Gay <[email protected]> Fri, 13 Aug 2004 19:45:15 +0200
Newsgroups gmane.comp.gnome.devtools.gob.general
Message-ID <1092419115.3301.14.camel@lurien>
Hello,

I went with the idea that people (like me) may want to change the
generated file naming convention. i.e.: change "pkg-my-object.h" into
"pkg_my_object.h" or even "pkgmyobject.h".

So I join to this message the patch I use.

Hope this helps... Bye.

Pierre
file_sep.patch (text/x-patch, 2.5 KB)
? file_sep.patch
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/gob/src/main.c,v
retrieving revision 1.124
diff -u -p -r1.124 main.c
--- src/main.c	10 Aug 2004 23:41:05 -0000	1.124
+++ src/main.c	13 Aug 2004 17:35:11 -0000
@@ -66,6 +66,8 @@ static char *ptypebase;
 
 char *output_dir = NULL;
 
+static char file_sep = '-';
+
 static int signals = 0; /* number of signals */
 static int set_properties = 0; /* number of named (set) properties */
 static int get_properties = 0; /* number of named (get) properties */
@@ -122,7 +124,7 @@ int method_unique_id = 1;
 static void
 make_bases (void)
 {
-	filebase = replace_sep (((Class *)class)->otype, '-');
+	filebase = replace_sep (((Class *)class)->otype, file_sep);
 	gob_strdown (filebase);
 
 	if (output_dir != NULL &&
@@ -4008,7 +4010,9 @@ print_help(void)
 		                          "aliases\n"
 		"\t--no-kill-underscores   Ignored for compatibility\n"
 		"\t-o,--output-dir         The directory where output "
-			                  "should be placed\n");
+			                  "should be placed\n"
+              "\t--file_sep[=c]          replace default\'-\' file "
+                                       "name separator\n");
 }
 
 static void
@@ -4125,6 +4129,11 @@ parse_options(int argc, char *argv[])
 			char *p = strchr (argv[i], '=');
 			g_assert (p != NULL);
 			output_dir = g_strdup (p+1);
+		} else if (strncmp (argv[i], "--file-sep=",
+                                    strlen ("--file-sep=")) == 0) {
+			char *p = strchr (argv[i], '=');
+			g_assert (p != NULL);
+			file_sep = *(p+1);
 		} else if(strcmp(argv[i], "--")==0) {
 			/*further arguments are files*/
 			no_opts = TRUE;
Index: src/util.c
===================================================================
RCS file: /cvs/gnome/gob/src/util.c,v
retrieving revision 1.15
diff -u -p -r1.15 util.c
--- src/util.c	5 May 2004 05:34:07 -0000	1.15
+++ src/util.c	13 Aug 2004 17:35:11 -0000
@@ -101,8 +101,19 @@ replace_sep(const char *base, char r)
 	if (for_cpp && strstr (s, "::") != NULL)
 		return s;
 
-	while((p=strchr(s,':')))
-		*p = r;
+        if (r == '\0') {
+          g_printerr ("null sep\n");
+          while((p=strchr(s,':'))) {
+            char *t = p;
+            while (*t != '\0') {
+              *t = *(t+1);
+              t++;
+            }
+          }
+        } else {
+          while((p=strchr(s,':')))
+            *p = r;
+        }
 	if(*s == r) {
 		p = g_strdup(s+1);
 		g_free(s);