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@9331 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4c1b1332a5
commit
93facf4e21
1 changed files with 20 additions and 18 deletions
|
|
@ -203,14 +203,16 @@ void scanner_close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------------
|
/* ----------------------------------------------------------------------------
|
||||||
* char nextchar()
|
* unsigned char nextchar()
|
||||||
*
|
*
|
||||||
* gets next character from input.
|
* gets next character from input.
|
||||||
* If we're in inlining mode, we actually retrieve a character
|
* If we're in inlining mode, we actually retrieve a character
|
||||||
* from inline_yybuffer instead.
|
* 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;
|
int c = 0;
|
||||||
|
|
||||||
while (LEX_in) {
|
while (LEX_in) {
|
||||||
|
|
@ -231,7 +233,7 @@ char nextchar() {
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
if (!expanding_macro) cparse_line++;
|
if (!expanding_macro) cparse_line++;
|
||||||
}
|
}
|
||||||
return(c);
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void retract(int n) {
|
void retract(int n) {
|
||||||
|
|
@ -298,7 +300,7 @@ void yycomment(char *a, int b, int c) {
|
||||||
|
|
||||||
void
|
void
|
||||||
skip_balanced(int startchar, int endchar) {
|
skip_balanced(int startchar, int endchar) {
|
||||||
char c;
|
int c;
|
||||||
int num_levels = 1;
|
int num_levels = 1;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
char temp[2] = {0,0};
|
char temp[2] = {0,0};
|
||||||
|
|
@ -375,7 +377,7 @@ skip_balanced(int startchar, int endchar) {
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void skip_decl(void) {
|
void skip_decl(void) {
|
||||||
char c;
|
int c;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
int start_line = cparse_line;
|
int start_line = cparse_line;
|
||||||
|
|
||||||
|
|
@ -1208,9 +1210,9 @@ int yylex(void) {
|
||||||
}
|
}
|
||||||
if ((c == '<') && !start_template) {
|
if ((c == '<') && !start_template) {
|
||||||
int fcount = 1;
|
int fcount = 1;
|
||||||
char c = nextchar();
|
int c2 = nextchar();
|
||||||
while (isspace((int)c)) {c = nextchar(); ++fcount;}
|
while (isspace(c2)) {c2 = nextchar(); ++fcount;}
|
||||||
if (isalpha((int)c)|| c == ':') {
|
if (isalpha(c2) || c2 == ':') {
|
||||||
start_template = count;
|
start_template = count;
|
||||||
}
|
}
|
||||||
retract(fcount);
|
retract(fcount);
|
||||||
|
|
@ -1246,7 +1248,7 @@ int yylex(void) {
|
||||||
int nlen = len - tlen;
|
int nlen = len - tlen;
|
||||||
if (nlen) {
|
if (nlen) {
|
||||||
String *ns = 0;
|
String *ns = 0;
|
||||||
while (isspace((int)end[--nlen]));
|
while (isspace((unsigned char)end[--nlen]));
|
||||||
ns = NewStringWithSize(s, nlen + 1);
|
ns = NewStringWithSize(s, nlen + 1);
|
||||||
retract(count - start_template);
|
retract(count - start_template);
|
||||||
Delete(s);
|
Delete(s);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue