X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/072bb12e618b26cce359784aa56f9a2b70e1ce52..486240dc4c5d57b0afaddba60d87fe375112bed5:/src/util.c diff --git a/src/util.c b/src/util.c index e47be5e..ae16914 100644 --- a/src/util.c +++ b/src/util.c @@ -53,13 +53,13 @@ remove_sep(char *base) { char *p; char *s = g_strdup(base); - while((p=strchr(s,':'))) + while((p = strchr(s, ':'))) strcpy(p,p+1); return s; } char * -replace_sep(char *base, char r) +replace_sep(const char *base, char r) { char *p; char *s = g_strdup(base); @@ -76,7 +76,7 @@ replace_sep(char *base, char r) /*separate the namespace part and then replace rest of separators with r*/ void -separns_replace_sep(char *base, char **ns, char **name, char r) +separns_replace_sep(const char *base, char **ns, char **name, char r) { char *p; char *s = g_strdup(base); @@ -100,21 +100,35 @@ separns_replace_sep(char *base, char **ns, char **name, char r) /* make a macro with some prefix before the name but after namespace */ char * -make_pre_macro(char *base, char *pre) +make_pre_macro(const char *base, const char *pre) { - char *s1,*s2; + char *ns, *name; char *s; + char **v = NULL; + + if(strchr(base, ' ')) { + int i; + v = g_strsplit(base, " ", 0); + for(i = 0; v[i] != NULL; i++) { + if(*v[i] && strcmp(v[i], "const") != 0) { + base = v[i]; + break; + } + } + } - separns_replace_sep(base,&s1,&s2,'_'); - if(s1) - s = g_strconcat(s1,"_",pre,"_",s2,NULL); + separns_replace_sep(base, &ns, &name, '_'); + if(ns) + s = g_strconcat(ns, "_", pre, "_", name,NULL); else - s = g_strconcat(pre,"_",s2,NULL); + s = g_strconcat(pre, "_", name, NULL); g_strup(s); - g_free(s1); - g_free(s2); + g_free(ns); + g_free(name); + + g_strfreev(v); return s; }