From 7263bfc73bef737b8ba22b78bf1f8bfa87965ad4 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 25 Jan 2010 18:31:44 -0800 Subject: [PATCH] =?UTF-8?q?cc:=20correct=20handling=20of=20leading=20?= =?UTF-8?q?=C2=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R=ken2 CC=golang-dev https://golang.org/cl/193081 --- src/cmd/cc/lex.c | 7 ++++--- src/cmd/cc/lexbody | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cmd/cc/lex.c b/src/cmd/cc/lex.c index 857b15206ff..fd4b0b87b2f 100644 --- a/src/cmd/cc/lex.c +++ b/src/cmd/cc/lex.c @@ -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] = '"'; } diff --git a/src/cmd/cc/lexbody b/src/cmd/cc/lexbody index 7c726b3f5ea..c6246e95ffb 100644 --- a/src/cmd/cc/lexbody +++ b/src/cmd/cc/lexbody @@ -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++)