From 62c27c1c5cb6257b13dfc9be0394e0d2e86f2735 Mon Sep 17 00:00:00 2001 From: Robert de Bath Date: Sun, 23 Jan 2005 15:31:04 +0100 Subject: Import Dev86src-0.16.17.tar.gz --- as/readsrc.c | 49 +++++++++++++++++++++++++------------------------ as/table.c | 16 ++++++++-------- 2 files changed, 33 insertions(+), 32 deletions(-) (limited to 'as') diff --git a/as/readsrc.c b/as/readsrc.c index df69756..1267419 100644 --- a/as/readsrc.c +++ b/as/readsrc.c @@ -50,7 +50,7 @@ PRIVATE struct get_s hid_getstak[MAXGET]; /* GET stack */ PRIVATE struct get_s *getstak; /* ptr */ #if BIGBUFFER == 1 -PRIVATE char *mem_start, *mem_end; +PRIVATE char *mem_start = 0, *mem_end; #endif PRIVATE char hid_linebuf[LINLEN]; /* line buffer */ @@ -109,6 +109,9 @@ char *name; #if BIGBUFFER == 1 if( mem_start == 0 ) { + size_t memsize = 0; + int cc; + if(fd) { struct stat st; @@ -120,36 +123,34 @@ char *name; goto cant_do_this; } } - if( filelength > 0 ) - { - if( (mem_start = malloc(filelength+2)) == 0 ) + + if (filelength > 0) { + if( (mem_start = malloc(filelength+4)) == 0 ) { mem_end = mem_start = "\n\n"; goto cant_do_this; - } + } + memsize = filelength; + filelength = read(fd, mem_start, filelength); - } - else - { - size_t memsize = 0; - int cc; + } else filelength = 0; - for(;;) - { - if( filelength >= memsize ) - { - if (memsize > 16000) - mem_start = asrealloc(mem_start, (memsize+=16384)+4); - else - mem_start = asrealloc(mem_start, (memsize+=memsize+32)+4); - } - cc = read(fd, mem_start+filelength, - (size_t)(memsize-filelength)); - if( cc <= 0 ) break; - filelength+=cc; - } + for(;;) + { + if( filelength >= memsize ) + { + if (memsize > 16000) + mem_start = asrealloc(mem_start, (memsize+=16384)+4); + else + mem_start = asrealloc(mem_start, (memsize+=memsize+32)+4); + } + cc = read(fd, mem_start+filelength, + (size_t)(memsize-filelength)); + if( cc <= 0 ) break; + filelength+=cc; } + *(mem_end=mem_start+filelength) = '\n'; mem_end[1] = '\0'; diff --git a/as/table.c b/as/table.c index 9c70015..eb9a24d 100644 --- a/as/table.c +++ b/as/table.c @@ -22,7 +22,7 @@ EXTERN char regs[]; EXTERN char typesizes[]; #endif -#ifdef DEBUG +#ifdef DEBUG_HASH unsigned nhash; unsigned nlookup; unsigned nsym; @@ -100,7 +100,7 @@ PUBLIC struct sym_s *lookup() register struct sym_s *symptr; register unsigned hashval; register unsigned length; -#ifdef DEBUG +#ifdef DEBUG_HASH int tries; ++nlookup; @@ -139,14 +139,14 @@ PUBLIC struct sym_s *lookup() { do { -#ifdef DEBUG +#ifdef DEBUG_HASH if (tries != 0) --nx[tries]; ++tries; if (tries < sizeof nx / sizeof nx[0]) ++nx[tries]; if (tries >= 5) - printchain(hashptr - spt) + printchain(hashptr - spt); #endif if ((unsigned char) length != symptr->length) continue; @@ -168,7 +168,7 @@ PUBLIC struct sym_s *lookup() } if (!ifflag) return NUL_PTR; -#ifdef DEBUG +#ifdef DEBUG_HASH ++nsym; if (hashptr >= spt && hashptr < spt + SPTSIZ) ++nhash; @@ -183,7 +183,7 @@ PUBLIC struct sym_s *lookup() return symptr; } -#ifdef DEBUG +#ifdef DEBUG_HASH static void printchain(hashval) unsigned hashval; @@ -200,7 +200,7 @@ unsigned hashval; PUBLIC void statistics() { -#ifdef DEBUG +#ifdef DEBUG_HASH int i; int weight; @@ -214,6 +214,6 @@ PUBLIC void statistics() weight += nx[i] * i; } printf("\n"); - printf("weight = %d%d\n", w); + printf("weight = %d%d\n", weight); #endif } -- cgit v1.2.1