/* GOB C Preprocessor
* Copyright (C) 1999-2000 the Free Software Foundation.
+ * Copyright (C) 2000 Eazel, Inc.
*
* Author: George Lebl
*
#include <stdio.h>
#include <glib.h>
-#include "tree.h"
+#include "treefuncs.h"
#include "main.h"
#include "util.h"
{
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);
/*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);
/* 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;
}
return any_special;
}
+
+/* get the id without the first underscore, but only if we're removing them */
+char *
+get_real_id(char *id)
+{
+ if(!no_kill_underscores &&
+ id[0] == '_' &&
+ id[1] != '\0')
+ return &id[1];
+ else
+ return id;
+}