From 69f043998a0635b754c6828608f7a2e2f8430307 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 13 Oct 2015 16:21:09 +0100 Subject: 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 --- src/duk-libdom-common.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src') 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++); } -- cgit v1.2.3