]> Cypherpunks repositories - gostls13.git/commitdiff
cc: correct handling of leading ·
authorRuss Cox <rsc@golang.org>
Tue, 26 Jan 2010 02:31:44 +0000 (18:31 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 26 Jan 2010 02:31:44 +0000 (18:31 -0800)
R=ken2
CC=golang-dev
https://golang.org/cl/193081

src/cmd/cc/lex.c
src/cmd/cc/lexbody

index 857b15206fff819ac43740b4460cce301f9775d2..fd4b0b87b2f60b2517c649b9cda9dd70e43010fe 100644 (file)
@@ -196,7 +196,8 @@ compile(char *file, char **defs, int ndef)
        int i, c, fd[2];
        static int first = 1;
 
-       ofile = strdup(file);
+       ofile = alloc(strlen(file)+10);
+       strcpy(ofile, file);
        p = utfrrune(ofile, pathchar());
        if(p) {
                *p++ = 0;
@@ -405,9 +406,9 @@ lookup(void)
        int c, n;
        char *r, *w;
 
-       if(symb[0] == 0xc2 && symb[1] == 0xb7) {
+       if((uchar)symb[0] == 0xc2 && (uchar)symb[1] == 0xb7) {
                // turn leading · into ""·
-               memmove(symb+2, symb, w-symb);
+               memmove(symb+2, symb, strlen(symb)+1);
                symb[0] = '"';
                symb[1] = '"';
        }
index 7c726b3f5ea1e2c799f8e49e1e2c4f3fee6eeb03..c6246e95ffb3e9ae9b33573a9aef3d0885ff45cf 100644 (file)
@@ -223,6 +223,13 @@ lookup(void)
        int c, l;
        char *r, *w;
 
+       if((uchar)symb[0] == 0xc2 && (uchar)symb[1] == 0xb7) {
+               // turn leading · into ""·
+               memmove(symb+2, symb, strlen(symb)+1);
+               symb[0] = '"';
+               symb[1] = '"';
+       }
+
        // turn · into .
        for(r=w=symb; *r; r++) {
                if((uchar)*r == 0xc2 && (uchar)*(r+1) == 0xb7) {
@@ -232,12 +239,6 @@ lookup(void)
                        *w++ = *r;
        }
        *w++ = '\0';
-       if(symb[0] == '.') {
-               // turn leading . into "".
-               memmove(symb+2, symb, w-symb);
-               symb[0] = '"';
-               symb[1] = '"';
-       }
 
        h = 0;
        for(p=symb; c = *p; p++)