* as/hc08/asmain.c, as/mcs51/asmain.c:
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 28 Dec 2007 19:19:05 +0000 (19:19 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 28 Dec 2007 19:19:05 +0000 (19:19 +0000)
  added missing initialization of a_addr field
* support/regression/tests/long_asm_line.c: added regtest for long
  assembler line

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4983 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
as/asxxsrc/aslex.c
as/z80/asmain.c
support/regression/tests/long_asm_line.c [new file with mode: 0644]

index e5cf333ec39ecb0e86657921901ff8bb32f504d6..da6d0d1ce8e85a5859ca3369046b69d7075c704a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,8 +6,10 @@
          as/z80/as_z80.dsp, as/hc08/Makefile.in, as/mcs51/Makefile.in,
          as/z80/Makefile.in: moved aslex.c to asxxsrc
        * as/hc08/aslex.c, as/z80/aslex.c: deleted
-       * as/z80/asmain.c, as/hc08/asmain.c, as/mcs51/asmain.c:
+       * as/hc08/asmain.c, as/mcs51/asmain.c:
          added missing initialization of a_addr field
+       * support/regression/tests/long_asm_line.c: added regtest for long
+         assembler line
 
 2007-12-22 Borut Razem <borut.razem AT siol.net>
 
index 41031ebbedc5de314aea6f61c4a93bf553725ebe..ecf37f908755ccc19cb4b64e047b6a04bfe53e3d 100644 (file)
@@ -380,7 +380,7 @@ getmap(d)
  */
 
 char *
-readlin(char *str, int n, FILE *infp)
+readlin(char *str, size_t n, FILE *infp)
 {
   int c;
   char *s;
@@ -392,28 +392,36 @@ readlin(char *str, int n, FILE *infp)
       return NULL;
     }
 
-  s = str;
-  while (--n && (c = getc(infp)) != '\n' && c != EOF)
-    *s++ = c;
-
-  /* chop CR */
-  if (s > str && *(s - 1) == '\r')
-    --s;
-
-  /* terminate the line */
-  *s = '\0';
-
-  /* eat characters until the end of line */
-  while (c != '\n' && c != EOF)
-    c = getc(infp);
-
-  /* if the EOF is not at the beginning of the line, return the line;
-     return NULL at the next call of redlin */
-  if (c == EOF)
+  if (n > 0)
     {
-      if (s == str)
-        return NULL;
-      eof_f = 1;
+    s = str;
+    if (n > 1)
+      {
+        while (--n && (c = getc(infp)) != '\n' && c != EOF)
+          *s++ = c;
+      }
+    else
+      c = ' ';  /* initialize it to something for the caharacter eating step */
+
+    /* chop CR */
+    if (s > str && *(s - 1) == '\r')
+      --s;
+
+    /* terminate the line */
+    *s = '\0';
+
+    /* eat characters until the end of line */
+    while (c != '\n' && c != EOF)
+      c = getc(infp);
+
+    /* if the EOF is not at the beginning of the line, return the line;
+       return NULL at the next call of redlin */
+    if (c == EOF)
+      {
+        if (s == str)
+          return NULL;
+        eof_f = 1;
+      }
     }
 
   return str;
index 85b5382592bf4e3a39291889effa23fda4f4cc5a..9e6c63812e7df5fcee2f56de20235a00c2bacc9c 100644 (file)
@@ -915,7 +915,6 @@ loop:
                         ap->a_ap = areap;
                         ap->a_id = strsto(id);
                         ap->a_ref = areap->a_ref + 1;
-                        ap->a_addr = 0;
                         ap->a_size = 0;
                         ap->a_fuzz = 0;
                         ap->a_flag = uaf ? uf : (A_CON|A_REL);
diff --git a/support/regression/tests/long_asm_line.c b/support/regression/tests/long_asm_line.c
new file mode 100644 (file)
index 0000000..202ab8d
--- /dev/null
@@ -0,0 +1,21 @@
+/* Long line assembler test
+ */
+#include <testfwk.h>
+
+volatile unsigned char U0GCR;
+volatile unsigned char CLKCON;
+
+enum __nesc_unnamed4261 {
+  CC2430_CLKCON_OSC32K = 7,
+  CC2430_CLKCON_OSC = 6,
+  CC2430_CLKCON_TICKSPD = 3,
+  CC2430_CLKCON_CLKSPD = 0,
+  CC2430_CLKCON_TICKSPD_MASK = 0x38
+};
+
+void
+testLongAsmLine(void)
+{
+  U0GCR = 230400 == 2400 ? 6 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 4800 ? 7 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 9600 ? 8 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 14400 ? 8 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 19200 ? 9 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 28800 ? 9 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 38400 ? 10 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 57600 ? 10 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 76800 ? 11 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 115200 ? 11 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 153600 ? 12 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 230400 ? 12 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 230400 == 307200 ? 13 + ((CLKCON & (1 << CC2430_CLKCON_OSC)) >> CC2430_CLKCON_OSC) : 0;
+}
+