From 453ec8afb328f34432ee8f62f180bcb0c644c95c Mon Sep 17 00:00:00 2001 From: borutr Date: Fri, 28 Dec 2007 19:19:05 +0000 Subject: [PATCH] * 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 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4983 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 +- as/asxxsrc/aslex.c | 52 ++++++++++++++---------- as/z80/asmain.c | 1 - support/regression/tests/long_asm_line.c | 21 ++++++++++ 4 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 support/regression/tests/long_asm_line.c diff --git a/ChangeLog b/ChangeLog index e5cf333e..da6d0d1c 100644 --- 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 diff --git a/as/asxxsrc/aslex.c b/as/asxxsrc/aslex.c index 41031ebb..ecf37f90 100644 --- a/as/asxxsrc/aslex.c +++ b/as/asxxsrc/aslex.c @@ -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; diff --git a/as/z80/asmain.c b/as/z80/asmain.c index 85b53825..9e6c6381 100644 --- a/as/z80/asmain.c +++ b/as/z80/asmain.c @@ -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 index 00000000..202ab8d5 --- /dev/null +++ b/support/regression/tests/long_asm_line.c @@ -0,0 +1,21 @@ +/* Long line assembler test + */ +#include + +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; +} + -- 2.30.2