From: borutr Date: Mon, 15 Sep 2008 19:55:17 +0000 (+0000) Subject: * support/regression/tests/bug1057979.c: X-Git-Url: https://git.gag.com/?p=fw%2Fsdcc;a=commitdiff_plain;h=24a948a79cc9a76ee83dc2d90b6f5a3604fa617d * support/regression/tests/bug1057979.c: removed old pic16 sprintf specifics * .version, doc/sdccman.lyx: bumped sdcc version to 2.8.4 * doc/sdccman.lyx: documented 'b' binary format specifier removal git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5240 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/.version b/.version index 9f8d8a91..2701a226 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.8.3 +2.8.4 diff --git a/ChangeLog b/ChangeLog index 1ca93c60..723558c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,10 @@ * device/lib/pic16/libc/stdio/vfprintf.c: applied patch #2044424: PIC16: vfprintf thanks Mauro Giachero + * support/regression/tests/bug1057979.c: + removed old pic16 sprintf specifics + * .version, doc/sdccman.lyx: bumped sdcc version to 2.8.4 + * doc/sdccman.lyx: documented 'b' binary format specifier removal 2008-09-15 Raphael Neider diff --git a/device/lib/pic16/libc/stdio/printf_tiny.c b/device/lib/pic16/libc/stdio/printf_tiny.c index f88bb36d..fb44bcf5 100644 --- a/device/lib/pic16/libc/stdio/printf_tiny.c +++ b/device/lib/pic16/libc/stdio/printf_tiny.c @@ -79,11 +79,12 @@ #define ISCHAR (fchar) #define HAVESIGN (nosign) - -#if 1 -extern void io_long (long); -extern void io_int (long); -extern void io_char (char); +#ifdef BINARY_SPECIFIER +/* "%lb" = "0" - "11111111111111111111111111111111" */ +# define BUF_SIZE 33 +#else +/* "%lo" = "0" - "37777777777" or "-21777777777" - "17777777777" */ +# define BUF_SIZE 13 #endif void @@ -97,8 +98,7 @@ printf_tiny (const char *fmt, ...) char *str, *ch; __data char *str1; long val; -// static char buffer[16]; - char buffer[16]; + char buffer[BUF_SIZE]; va_list ap; va_start (ap, fmt); diff --git a/device/lib/pic16/libc/stdio/vfprintf.c b/device/lib/pic16/libc/stdio/vfprintf.c index 95d8b002..304bb01b 100644 --- a/device/lib/pic16/libc/stdio/vfprintf.c +++ b/device/lib/pic16/libc/stdio/vfprintf.c @@ -122,6 +122,14 @@ */ #define EXTRA_INTEGER +#ifdef BINARY_SPECIFIER +/* "%lb" = "0" - "11111111111111111111111111111111" */ +# define BUF_SIZE 33 +#else +/* "%lo" = "0" - "37777777777" or "-20000000000" - "17777777777" */ +# define BUF_SIZE 13 +#endif + #if _DEBUG extern void io_long (unsigned long); extern void io_str (char *); @@ -156,8 +164,7 @@ vfprintf (FILE * stream, const char *fmt, va_list ap) int count = 0; char *str, *ch; long val; -// static char buffer[16]; - char buffer[16]; + char buffer[BUF_SIZE]; #if _DEBUG io_str ("vfprintf: "); diff --git a/doc/sdccman.lyx b/doc/sdccman.lyx index d8aa817a..38436d89 100644 --- a/doc/sdccman.lyx +++ b/doc/sdccman.lyx @@ -104,7 +104,7 @@ SDCC Compiler User Guide \begin_layout Date \size normal -SDCC 2.8.3 +SDCC 2.8.4 \size footnotesize \newline @@ -1166,10 +1166,14 @@ in older versions, the preprocessor was always called with -std=c99 regardless comments \end_layout -\begin_layout Standard - -\emph on - +\begin_layout Itemize +in versions older then 2.8.4 the pic16 *printf() and printf_tiny() library + functions supported undocumented and not standard compliant 'b' binary + format specifier ("%b", "%hb" and "%lb"). + The 'b' specifier is now disabled by default. + It can be enabled by defining BINARY_SPECIFIER macro in files device/lib/pic16/ +libc/stdio/vfprintf.c and device/lib/pic16/libc/stdio/printf_tiny.c and recompilin +g the library. \end_layout \begin_layout Section diff --git a/support/regression/tests/bug1057979.c b/support/regression/tests/bug1057979.c index b7301acb..08aa3e1a 100644 --- a/support/regression/tests/bug1057979.c +++ b/support/regression/tests/bug1057979.c @@ -7,66 +7,50 @@ #include #include -char s[12+1]; +char s[12 + 1]; void -test_sprintf(void) +test_sprintf (void) { s[12] = 0x12; - sprintf( s, "%d", 99 ); - ASSERT( 0 == strcmp( s, "99" ) ); - sprintf( s, "%d", 100 ); - ASSERT( 0 == strcmp( s, "100" ) ); - sprintf( s, "%d", 2004 ); - ASSERT( 0 == strcmp( s, "2004" ) ); - sprintf( s, "%ld", 2147483647L ); - ASSERT( 0 == strcmp( s, "2147483647" ) ); + sprintf (s, "%d", 99); + ASSERT (0 == strcmp (s, "99")); + sprintf (s, "%d", 100); + ASSERT (0 == strcmp (s, "100")); + sprintf (s, "%d", 2004); + ASSERT (0 == strcmp (s, "2004")); + sprintf (s, "%ld", 2147483647L); + ASSERT (0 == strcmp (s, "2147483647")); //and from bug 1073386 -#ifdef SDCC_pic16 - //pic16 printf doesn't support flags, width and precision specifiers - sprintf( s, "%04X", 0x8765u ); - ASSERT( 0 == strcmp( s, "04X" ) ); + sprintf (s, "%04X", 0x8765u); + ASSERT (0 == strcmp (s, "8765")); //and from bug 1193299 - sprintf( s, "%3.3s", "abcd" ); - ASSERT( 0 == strcmp( s, "3.3s" ) ); - sprintf( s, "%-3.3s", "abcd" ); - ASSERT( 0 == strcmp( s, "-3.3s" ) ); - sprintf( s, "%3.3s", "ab" ); - ASSERT( 0 == strcmp( s, "3.3s" ) ); - sprintf( s, "%-3.3s", "ab" ); - ASSERT( 0 == strcmp( s, "-3.3s" ) ); -#else - sprintf( s, "%04X", 0x8765u ); - ASSERT( 0 == strcmp( s, "8765" ) ); - - //and from bug 1193299 - sprintf( s, "%3.3s", "abcd" ); - ASSERT( 0 == strcmp( s, "abc" ) ); - sprintf( s, "%-3.3s", "abcd" ); - ASSERT( 0 == strcmp( s, "abc" ) ); - sprintf( s, "%3.3s", "ab" ); - ASSERT( 0 == strcmp( s, " ab" ) ); - sprintf( s, "%-3.3s", "ab" ); - ASSERT( 0 == strcmp( s, "ab " ) ); -#endif + sprintf (s, "%3.3s", "abcd"); + ASSERT (0 == strcmp (s, "abc")); + sprintf (s, "%-3.3s", "abcd"); + ASSERT (0 == strcmp (s, "abc")); + sprintf (s, "%3.3s", "ab"); + ASSERT (0 == strcmp (s, " ab")); + sprintf (s, "%-3.3s", "ab"); + ASSERT (0 == strcmp (s, "ab ")); #if defined(SDCC_ds390) || defined(PORT_HOST) //and from bug 1358192 - sprintf( s, "%f", 10.1 ); - LOG((s)); - ASSERT( 0 == strcmp( s, "10.100000" ) ); + sprintf (s, "%f", 10.1); + LOG ((s)); + ASSERT (0 == strcmp (s, "10.100000")); //and from bug 1388703 - sprintf( s, "%4.1f", 1.36 ); - LOG((s)); - ASSERT( 0 == strcmp( s, " 1.4" ) ); - sprintf( s, "%4.1f", -1.37 ); - LOG((s)); - ASSERT( 0 == strcmp( s, "-1.4" ) ); + sprintf (s, "%4.1f", 1.36); + LOG ((s)); + ASSERT (0 == strcmp (s, " 1.4")); + sprintf (s, "%4.1f", -1.37); + LOG ((s)); + ASSERT (0 == strcmp (s, "-1.4")); #endif - ASSERT( s[12]==0x12 ); + ASSERT (s[12] == 0x12); }