summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-03-28 14:56:41 +0200
committerDanny Baumann <dannybaumann@web.de>2007-03-28 14:56:41 +0200
commitea9973fe84f471141323f7e4fa7f0c33f4f23c4d (patch)
tree0f3a3d98b62fcbd3dca66ee9ab08ca9120198d95
parent4ae846274cf30e3914670f14c809438d7ebcf6a2 (diff)
downloadberyl-bcop-ea9973fe84f471141323f7e4fa7f0c33f4f23c4d.tar.gz
beryl-bcop-ea9973fe84f471141323f7e4fa7f0c33f4f23c4d.tar.bz2
bcop: convert option names to CamelCaps for source code printing
-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);