LEFT | RIGHT |
1 // Inferno utils/cc/lex.c | 1 // Inferno utils/cc/lex.c |
2 // http://code.google.com/p/inferno-os/source/browse/utils/cc/lex.c | 2 // http://code.google.com/p/inferno-os/source/browse/utils/cc/lex.c |
3 // | 3 // |
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. | 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. |
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) | 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) |
6 // Portions Copyright © 1997-1999 Vita Nuova Limited | 6 // Portions Copyright © 1997-1999 Vita Nuova Limited |
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) | 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuov
a.com) |
8 // Portions Copyright © 2004,2006 Bruce Ellis | 8 // Portions Copyright © 2004,2006 Bruce Ellis |
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) | 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) |
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others | 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 398 |
399 Sym* | 399 Sym* |
400 lookup(void) | 400 lookup(void) |
401 { | 401 { |
402 Sym *s; | 402 Sym *s; |
403 uint32 h; | 403 uint32 h; |
404 char *p; | 404 char *p; |
405 int c, n; | 405 int c, n; |
406 char *r, *w; | 406 char *r, *w; |
407 | 407 |
| 408 if(symb[0] == 0xc2 && symb[1] == 0xb7) { |
| 409 // turn leading · into ""· |
| 410 memmove(symb+2, symb, w-symb); |
| 411 symb[0] = '"'; |
| 412 symb[1] = '"'; |
| 413 } |
| 414 |
408 // turn · into . | 415 // turn · into . |
409 for(r=w=symb; *r; r++) { | 416 for(r=w=symb; *r; r++) { |
410 if((uchar)*r == 0xc2 && (uchar)*(r+1) == 0xb7) { | 417 if((uchar)*r == 0xc2 && (uchar)*(r+1) == 0xb7) { |
411 *w++ = '.'; | 418 *w++ = '.'; |
412 r++; | 419 r++; |
413 }else | 420 }else |
414 *w++ = *r; | 421 *w++ = *r; |
415 } | 422 } |
416 *w++ = '\0'; | 423 *w++ = '\0'; |
417 if(symb[0] == '.') { | |
418 // turn leading . into "". | |
419 memmove(symb+2, symb, w-symb); | |
420 symb[0] = '"'; | |
421 symb[1] = '"'; | |
422 } | |
423 | 424 |
424 h = 0; | 425 h = 0; |
425 for(p=symb; *p;) { | 426 for(p=symb; *p;) { |
426 h = h * 3; | 427 h = h * 3; |
427 h += *p++; | 428 h += *p++; |
428 } | 429 } |
429 n = (p - symb) + 1; | 430 n = (p - symb) + 1; |
430 h &= 0xffffff; | 431 h &= 0xffffff; |
431 h %= NHASH; | 432 h %= NHASH; |
432 c = symb[0]; | 433 c = symb[0]; |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 return alloc(n+d); | 1576 return alloc(n+d); |
1576 p = realloc(p, n+d); | 1577 p = realloc(p, n+d); |
1577 if(p == nil) { | 1578 if(p == nil) { |
1578 print("allocn out of mem\n"); | 1579 print("allocn out of mem\n"); |
1579 exit(1); | 1580 exit(1); |
1580 } | 1581 } |
1581 if(d > 0) | 1582 if(d > 0) |
1582 memset((char*)p+n, 0, d); | 1583 memset((char*)p+n, 0, d); |
1583 return p; | 1584 return p; |
1584 } | 1585 } |
LEFT | RIGHT |