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
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>
*/
char *
-readlin(char *str, int n, FILE *infp)
+readlin(char *str, size_t n, FILE *infp)
{
int c;
char *s;
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;
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);
--- /dev/null
+/* 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;
+}
+