summaryrefslogtreecommitdiff
path: root/as
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2005-01-23 15:31:04 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:50 +0200
commit62c27c1c5cb6257b13dfc9be0394e0d2e86f2735 (patch)
treef702b7e5f80293367e1b6f9812bd45e80378be26 /as
parent6cb598cc5f1c8ae6d14381c2776338584368257e (diff)
downloaddev86-62c27c1c5cb6257b13dfc9be0394e0d2e86f2735.tar.gz
Import Dev86src-0.16.17.tar.gzv0.16.17
Diffstat (limited to 'as')
-rw-r--r--as/readsrc.c49
-rw-r--r--as/table.c16
2 files changed, 33 insertions, 32 deletions
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
}