Reimplemented Swig_string_ucase(String *s) to take into account digits in names.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8675 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d2648ed8fd
commit
165dd09f7a
1 changed files with 21 additions and 13 deletions
|
|
@ -190,24 +190,32 @@ String *Swig_string_ccase(String *s) {
|
||||||
|
|
||||||
String *Swig_string_ucase(String *s) {
|
String *Swig_string_ucase(String *s) {
|
||||||
String *ns;
|
String *ns;
|
||||||
int first = 0;
|
|
||||||
int c;
|
int c;
|
||||||
|
int lastC = 0;
|
||||||
|
int underscore = 0;
|
||||||
ns = NewStringEmpty();
|
ns = NewStringEmpty();
|
||||||
|
|
||||||
|
/* We insert a underscore when:
|
||||||
|
1. Lower case char followed by upper case char
|
||||||
|
getFoo > get_foo; getFOo > get_foo; GETFOO > getfoo
|
||||||
|
2. Number proceded by char
|
||||||
|
get2D > get_2d; get22D > get_22d; GET2D > get_2d */
|
||||||
|
|
||||||
Seek(s,0,SEEK_SET);
|
Seek(s,0,SEEK_SET);
|
||||||
|
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
if (isalpha(c)) {
|
if (isdigit(c) && isalpha(lastC))
|
||||||
if (isupper(c)) {
|
underscore = 1;
|
||||||
if (first) Putc('_',ns);
|
else if (isupper(c) && isalpha(lastC) && !isupper(lastC))
|
||||||
first = 0;
|
underscore = 1;
|
||||||
} else {
|
|
||||||
first = 1;
|
lastC = c;
|
||||||
}
|
|
||||||
}
|
if (underscore) {
|
||||||
else if (c == '_') {
|
Putc('_',ns);
|
||||||
/* We don't want two underscores in a row */
|
underscore = 0;
|
||||||
first = 0;
|
}
|
||||||
}
|
|
||||||
Putc(tolower(c),ns);
|
Putc(tolower(c),ns);
|
||||||
}
|
}
|
||||||
return ns;
|
return ns;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue