Be careful to only pass unsigned char values to isalpha(), etc in the hope

this is the cause of bug #1518219 (I can't reproduce it on Linux, but glibc
implements a safety net by making isalpha() etc work on signed char values
too...)


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9331 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-09-23 10:43:29 +00:00
commit 25ed8b2e50

View file

@ -203,14 +203,16 @@ void scanner_close() {
}
/* ----------------------------------------------------------------------------
* char nextchar()
* unsigned char nextchar()
*
* gets next character from input.
* If we're in inlining mode, we actually retrieve a character
* from inline_yybuffer instead.
* Return value is unsigned char since isalpha(), etc aren't defined for the
* negative values that we get if char is signed.
* ------------------------------------------------------------------------- */
char nextchar() {
unsigned char nextchar() {
int c = 0;
while (LEX_in) {
@ -231,7 +233,7 @@ char nextchar() {
if (c == '\n') {
if (!expanding_macro) cparse_line++;
}
return(c);
return c;
}
void retract(int n) {
@ -298,7 +300,7 @@ void yycomment(char *a, int b, int c) {
void
skip_balanced(int startchar, int endchar) {
char c;
int c;
int num_levels = 1;
int state = 0;
char temp[2] = {0,0};
@ -375,7 +377,7 @@ skip_balanced(int startchar, int endchar) {
* ------------------------------------------------------------------------- */
void skip_decl(void) {
char c;
int c;
int done = 0;
int start_line = cparse_line;
@ -1208,9 +1210,9 @@ int yylex(void) {
}
if ((c == '<') && !start_template) {
int fcount = 1;
char c = nextchar();
while (isspace((int)c)) {c = nextchar(); ++fcount;}
if (isalpha((int)c)|| c == ':') {
int c2 = nextchar();
while (isspace(c2)) {c2 = nextchar(); ++fcount;}
if (isalpha(c2) || c2 == ':') {
start_template = count;
}
retract(fcount);
@ -1246,7 +1248,7 @@ int yylex(void) {
int nlen = len - tlen;
if (nlen) {
String *ns = 0;
while (isspace((int)end[--nlen]));
while (isspace((unsigned char)end[--nlen]));
ns = NewStringWithSize(s, nlen + 1);
retract(count - start_template);
Delete(s);