X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/b3db2950b11fc5f3abd9ecdae855746e2d19c836..7f1f40bee65a4a3d3947ad8c50b535ea0754f629:/src/util.c diff --git a/src/util.c b/src/util.c index de1d008..ddf9485 100644 --- a/src/util.c +++ b/src/util.c @@ -1,6 +1,7 @@ /* GOB C Preprocessor * Copyright (C) 1999-2000 the Free Software Foundation. * Copyright (C) 2000 Eazel, Inc. + * Copyright (C) 2022 Nick Bowler * * Author: George Lebl * @@ -20,7 +21,7 @@ * USA. */ -#include "config.h" +#include #include #include #include @@ -81,13 +82,17 @@ remove_sep(const char *base) { char *p; char *s = g_strdup(base); + char *q=s; /* don't eat C++ :: thingies */ if (for_cpp && strstr (s, "::") != NULL) return s; - while((p = strchr(s, ':'))) - strcpy(p, p+1); + for(p=(char *)base;*p;p++){ + if (*p!=':') + *q++=*p; + } + *q='\0'; return s; } @@ -101,8 +106,18 @@ replace_sep(const char *base, char r) if (for_cpp && strstr (s, "::") != NULL) return s; - while((p=strchr(s,':'))) - *p = r; + if (r == '\0') { + while ((p=strchr(s,':')) != NULL) { + char *t = p; + while (*t != '\0') { + *t = *(t+1); + t++; + } + } + } else { + while ((p=strchr(s,':')) != NULL) + *p = r; + } if(*s == r) { p = g_strdup(s+1); g_free(s); @@ -258,7 +273,10 @@ get_cast (const char *type, gboolean simple_only) init_type_hash (); - gtype = g_hash_table_lookup (type_hash, type); + if(strncmp(type, "BOXED_", 6) == 0) + gtype = g_hash_table_lookup (type_hash, "BOXED"); + else + gtype = g_hash_table_lookup (type_hash, type); if (gtype == NULL || (simple_only && @@ -339,7 +357,7 @@ setup_special_array(Class *c, gboolean *special_array) char * get_type (const Type *t, gboolean postfix_to_stars) { - char *s; + char *ret, *s; int i; int extra; GString *gs; @@ -366,29 +384,51 @@ get_type (const Type *t, gboolean postfix_to_stars) g_string_append_c (gs, '*'); g_string_append_c (gs, ' '); } - - return g_string_free (gs, FALSE); + ret = gs->str; + g_string_free(gs, FALSE); + return ret; } -char * -gob_strup (char *str) +#if HAVE_G_ASCII_STRCASECMP +char *gob_strup(char *str) { char *s; + for (s = str; *s; s++) - *s = g_ascii_toupper (*s); + *s = g_ascii_toupper(*s); return str; } -char * -gob_strdown (char *str) +char *gob_strdown(char *str) { char *s; + for (s = str; *s; s++) - *s = g_ascii_tolower (*s); + *s = g_ascii_tolower(*s); return str; } +#endif + +char * +gob_str_delete_quotes(char *str) +{ + char *p, *i; + p=i=str; + while(*p!='\0') + { + if(*p=='\"') + { + p++; + continue; + } + *i=*p; + p++; i++; + } + *i=*p; + return str; +} char * make_me_type (const char *type, const char *alt)