summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-10-13 15:21:09 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2015-10-13 15:21:09 (GMT)
commit69f043998a0635b754c6828608f7a2e2f8430307 (patch)
tree91a682d83e290a5594e05c609af29c39c0d82ac2
parent44edef813d0319616dd5003dd62267742bd0e0a9 (diff)
downloadnsgenbind-69f043998a0635b754c6828608f7a2e2f8430307.tar.gz
nsgenbind-69f043998a0635b754c6828608f7a2e2f8430307.tar.bz2
slightly modify the IDL to c name translation
This tweaks the IDL name to c name translation to not leave isolated characters. e.g. HTMLIFrameElement became html_i_frame_element now its html_iframe_element HTMLDList became html_d_list and is now html_dlist
-rw-r--r--src/duk-libdom-common.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/duk-libdom-common.c b/src/duk-libdom-common.c
index ce3ebe9..6111070 100644
--- a/src/duk-libdom-common.c
+++ b/src/duk-libdom-common.c
@@ -177,7 +177,7 @@ char *gen_idl2c_name(const char *idlname)
const char *inc;
char *outc;
char *name;
- int wasupper;
+ int waslower;
/* enpty strings are a bad idea */
if ((idlname == NULL) || (idlname[0] == 0)) {
@@ -191,7 +191,7 @@ char *gen_idl2c_name(const char *idlname)
outc = name;
inc = idlname;
- wasupper = 0;
+ waslower = 1;
/* first character handled separately as inserting a leading underscore
* is undesirable
@@ -211,13 +211,19 @@ char *gen_idl2c_name(const char *idlname)
(islower(inc[1]) == 0)) {
*outc++ = '_';
}
- if ((islower(*inc) != 0) && (wasupper != 0)) {
- *outc = *(outc - 1);
- *(outc - 1) = '_';
- outc++;
- wasupper = 0;
+ if (islower(*inc) != 0) {
+ if (waslower == 0) {
+ /* high to lower case transition */
+ if (((outc - name) <= 3) ||
+ (*(outc - 3) != '_')) {
+ *outc = *(outc - 1);
+ *(outc - 1) = '_';
+ outc++;
+ }
+ }
+ waslower = 1;
} else {
- wasupper = isupper(*inc);
+ waslower = 0;
}
*outc++ = tolower(*inc++);
}