summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@beryl-project.org>2007-03-28 15:01:16 +0200
committerDennis Kasprzyk <onestone@beryl-project.org>2007-03-28 15:01:16 +0200
commit7e94e5124adae1c24004b2aef9987ee1e19a1380 (patch)
tree0f3a3d98b62fcbd3dca66ee9ab08ca9120198d95
parent4ae846274cf30e3914670f14c809438d7ebcf6a2 (diff)
downloadberyl-bcop-7e94e5124adae1c24004b2aef9987ee1e19a1380.tar.gz
beryl-bcop-7e94e5124adae1c24004b2aef9987ee1e19a1380.tar.bz2
maniac's Camel conversion
-rw-r--r--src/bcop.h1
-rw-r--r--src/xml_parser.c24
2 files changed, 24 insertions, 1 deletions
diff --git a/src/bcop.h b/src/bcop.h
index ed28968..1f0f0d2 100644
--- a/src/bcop.h
+++ b/src/bcop.h
@@ -212,6 +212,7 @@ typedef struct _ParserState {
char * strToLower(char *str);
char * strToUpper(char *str);
char * strToFirstUp(char *str);
+char * strToCamel(char *str);
int genCode(char *src, char *hdr);
diff --git a/src/xml_parser.c b/src/xml_parser.c
index 2609e59..5fabf3e 100644
--- a/src/xml_parser.c
+++ b/src/xml_parser.c
@@ -573,7 +573,7 @@ parseOption(xmlDoc *doc, ParserState* pState, xmlNode *node)
Option *ns = calloc(1, sizeof(Option));
ns->name = strToLower((char *)name);
ns->uName = strToUpper((char *)name);
- ns->fUName = strToFirstUp((char *)name);
+ ns->fUName = strToCamel((char *)name);
ns->type = sType;
ns->group = (pState->group)?strdup(pState->group):NULL;
ns->subGroup = (pState->subGroup)?strdup(pState->subGroup):NULL;
@@ -833,6 +833,28 @@ char * strToFirstUp(char *str)
return ret;
}
+char * strToCamel(char *str)
+{
+ char *lowString = strToLower(str);
+ char *token;
+ char *buffer;
+
+ buffer = malloc (sizeof(char) * (strlen(lowString) + 1));
+ strcpy (buffer, "");
+
+ token = strtok (lowString, "_");
+ while (token)
+ {
+ token[0] = toupper(token[0]);
+ strcat (buffer, token);
+ token = strtok (NULL, "_");
+ }
+
+ free (lowString);
+
+ return buffer;
+}
+
static void usage(void)
{
printf("Usage: %9s [options] <options file>\n",programName);