Fix to escape code handling.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4494 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2003-03-10 14:03:05 +00:00
commit a13e0a67c1
3 changed files with 13 additions and 5 deletions

View file

@ -446,8 +446,9 @@ static void get_escape() {
yylen--; yylen--;
return; return;
} }
if (c == '0') { if (isdigit(c)) {
state = 10; state = 10;
result = (c-'0');
} }
else if (c == 'x') { else if (c == 'x') {
state = 20; state = 20;
@ -761,7 +762,7 @@ int yylook(void) {
if (( c = nextchar()) == 0) return 0; if (( c = nextchar()) == 0) return 0;
if (c == '*') { if (c == '*') {
return DSTAR; return DSTAR;
} if (c == '~') { } else if (c == '~') {
return DCNOT; return DCNOT;
} else { } else {
retract(1); retract(1);
@ -997,6 +998,7 @@ void scanner_ignore_typedef() {
} }
void scanner_last_id(int x) { void scanner_last_id(int x) {
/* printf("Setting last_id = %d\n", x); */
last_id = x; last_id = x;
} }
@ -1028,14 +1030,18 @@ int yylex(void) {
next_token = 0; next_token = 0;
return l; return l;
} }
/* Printf(stdout,"%d\n", last_id);*/
l = yylook(); l = yylook();
if (l == NONID) { if (l == NONID) {
last_id = 1; last_id = 1;
} else { } else {
last_id = 0; last_id = 0;
} }
/*
yytext[yylen]= 0;
Printf(stdout,"%d '%s' %d\n", l, yytext, last_id);
*/
/* We got some sort of non-white space object. We set the start_line /* We got some sort of non-white space object. We set the start_line
variable unless it has already been set */ variable unless it has already been set */

View file

@ -4134,13 +4134,15 @@ definetype : { /* scanner_check_typedef(); */ } expr {
} }
| CHARCONST { | CHARCONST {
$$.val = NewString($1); $$.val = NewString($1);
$$.rawval = NewStringf("\'%(escape)s\'",$$.val);
/*
if (Len($$.val)) { if (Len($$.val)) {
/* $$.rawval = NewStringf("\'%(escape)s\'",$$.val); */
$$.rawval = NewStringf("\'%s\'", $$.val); $$.rawval = NewStringf("\'%s\'", $$.val);
} else { } else {
$$.rawval = NewString("\'\\0'"); $$.rawval = NewString("\'\\0'");
$$.val = NewString("\\0"); $$.val = NewString("\\0");
} }
*/
$$.type = T_CHAR; $$.type = T_CHAR;
$$.bitfield = 0; $$.bitfield = 0;
$$.throws = 0; $$.throws = 0;

View file

@ -81,7 +81,7 @@ String *Swig_string_escape(String *s) {
} else if (c == ' ') { } else if (c == ' ') {
Putc(c,ns); Putc(c,ns);
} else if (!isgraph(c)) { } else if (!isgraph(c)) {
Printf(ns,"\\0%o", c); Printf(ns,"\\%o", c);
} else { } else {
Putc(c,ns); Putc(c,ns);
} }