Mercurial > hg > CbC > old > device
diff mc-macro.c @ 560:d6ff45d719a5 string-shared
string sharing
author | kono |
---|---|
date | Sat, 07 Jan 2006 18:11:53 +0900 |
parents | ef225b589888 |
children | de0b0380c461 |
line wrap: on
line diff
--- a/mc-macro.c Sat Jan 07 13:09:45 2006 +0900 +++ b/mc-macro.c Sat Jan 07 18:11:53 2006 +0900 @@ -252,6 +252,9 @@ */ static int next_eof; +struct cheap *st_cheap, *cheap1; +// ST_COMMENT may interfere with other inrement_cheap, so we use +// another cheap area. extern void getline(void) @@ -295,24 +298,30 @@ if (inmode) { int i=0; int c; - char *p = cheap->ptr; + char *p; + // should be done in some init + if (!st_cheap) { + st_cheap = cheap1 = new_cheap(); + } + + p = st_cheap->ptr; sprintf(num,"%d: ",lineno); parse = list3(ST_COMMENT,parse,(int)p); // should contain file name c = 0; - while((*cheap->ptr = num[c++])) - cheap = increment_cheap(cheap,&p); - while((c = *cheap->ptr = linebuf[i++])) { - cheap = increment_cheap(cheap,&p); + while((*st_cheap->ptr = num[c++])) + st_cheap = increment_cheap(st_cheap,&p); + while((c = *st_cheap->ptr = linebuf[i++])) { + st_cheap = increment_cheap(st_cheap,&p); if (c=='\n') { - *cheap->ptr = 0; - cheap = increment_cheap(cheap,&p); - p = cheap->ptr; + *st_cheap->ptr = 0; + st_cheap = increment_cheap(st_cheap,&p); + p = st_cheap->ptr; // parse = list3(ST_COMMENT,parse,(int)p); sprintf(num,"%d: ",lineno); c = 0; while((*cheap->ptr = num[c++])) - cheap = increment_cheap(cheap,&p); + st_cheap = increment_cheap(st_cheap,&p); } } }