diff options
author | John Millaway <john43@users.sourceforge.net> | 2002-08-17 20:04:51 +0000 |
---|---|---|
committer | John Millaway <john43@users.sourceforge.net> | 2002-08-17 20:04:51 +0000 |
commit | 67bfe789c2818f8709fd05f058f48ae436715575 (patch) | |
tree | e26dda5bf292496dc05882068e55aff8a1c0d6ea /misc.c | |
parent | 063a57d1cd27021f230bca2ce9298377e635fe5d (diff) |
Start conditions now optional in header.
undef's now optional in header.
Start conditions are NOT prefixed.
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 101 |
1 files changed, 0 insertions, 101 deletions
@@ -942,104 +942,3 @@ char* chomp(str) return str; } -/* Converts str to lowercase in place. returns str*/ -char * strlower (str) - char* str; -{ - char * s = str; - if (str) - for (s=str; *s; s++) - *s = tolower(*s); - return str; -} - -/* Converts str to uppercase in place. returns str*/ -char * strupper (str) - char* str; -{ - char * s; - if (str) - for (s=str; *s; s++) - *s = toupper(*s); - return str; -} - -/* return < 0 if prefers lowercase - * return > 0 if prefers uppercase - * return 0 if no preference or it looks like first-letter-capitalization - * Similar to strcmp(), the absolute value of the return value is larger - * the more characters are upper or lowercase. - */ -int case_preference (str) - const char* str; -{ - int nup=0, nlow=0, first_up=0; - const char* s; - if (!str) - return 0; - - /* find the first upper or lowercase letter */ - for (s=str; *s; s++){ - if (!isupper(*s) && !islower(*s)) - continue; - first_up = isupper(*s); - break; - } - - for (s=str; *s; s++){ - if (isupper(*s)) - nup++; - if (islower(*s)) - nlow++; - } - - return (first_up && nlow > nup) ? 0 : nup - nlow; -} - -/* Creates a name-space friendly start condition name, safe for - * use in the generated header. - * buf should be large enough to contain name and prefix. - * returns buf - */ -char * fix_scname (buf, name) - char * buf; - const char * name; -{ - char * pre; - int cn,cp; - - buf[0]= '\0'; - if (!name) - return buf; - - /* we do comparisons in lowercase */ - pre = copy_string(prefix); - strlower(pre); - strcpy(buf,name); - strlower(buf); - - /* If the user has already prefixed name, then we leave it alone. */ - if (strncmp(buf,pre,strlen(pre))==0 && strlen(name) > strlen(pre)){ - strcpy(buf,name); - free(pre); - return buf; - } - - /* Build the new name */ - sprintf(buf,"%ssc_%s", prefix, name); - - /* Decide whether the user prefers upper or lowercase or neither */ - cp = case_preference(prefix); - cn = case_preference(name); - - if (cn != 0) { - /* If it's mostly lowercase... */ - if (cn < 0 && (0 - cn) > strlen(name)/2) - strlower(buf); - else if (cn > 0 && cn > strlen(name)/2) - strupper(buf); - } - - free(pre); - return buf; -} |