From dc20d0c93ca0edae5563f20db960d228d359c42a Mon Sep 17 00:00:00 2001 From: Christian Wiese Date: Thu, 23 Aug 2007 19:16:53 +0200 Subject: [PATCH] Fixed dietlibc printf behavior that broke modinfo output - added patch from upstream CVS that fixes printf when using padding --- .../dietlibc/dietlibc-0.30-7_printf_pad.patch | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 base/dietlibc/dietlibc-0.30-7_printf_pad.patch diff --git a/base/dietlibc/dietlibc-0.30-7_printf_pad.patch b/base/dietlibc/dietlibc-0.30-7_printf_pad.patch new file mode 100644 index 000000000..f125ebd1a --- /dev/null +++ b/base/dietlibc/dietlibc-0.30-7_printf_pad.patch @@ -0,0 +1,149 @@ +Index: ./lib/__v_printf.c +=================================================================== +RCS file: /cvs/dietlibc/lib/__v_printf.c,v +retrieving revision 1.33 +retrieving revision 1.35 +diff -u -r1.33 -r1.35 +--- ./lib/__v_printf.c 10 Jan 2007 22:51:09 -0000 1.33 ++++ ./lib/__v_printf.c 17 May 2007 05:00:42 -0000 1.35 +@@ -19,9 +19,9 @@ + #define B_WRITE(fn,buf,sz) { if ((unsigned long)(sz) > (((unsigned long)(int)(-1))>>1) || len+(int)(sz)15;len-=16,nr+=16) { + A_WRITE(fn,pad_line[(padwith=='0')?1:0],16); + } +@@ -34,7 +34,7 @@ + + int __v_printf(struct arg_printf* fn, const char *format, va_list arg_ptr) + { +- int len=0; ++ unsigned int len=0; + #ifdef WANT_ERROR_PRINTF + int _errno = errno; + #endif +@@ -51,7 +51,7 @@ + #define s u_str.s + + int retval; +- unsigned char ch, padwith=' '; ++ unsigned char ch, padwith=' ', precpadwith=' '; + + char flag_in_sign=0; + char flag_upcase=0; +@@ -172,7 +172,7 @@ + if (flag_dot && sz>preci) sz=preci; + preci=0; + flag_dot^=flag_dot; +- padwith=' '; ++ padwith=precpadwith=' '; + + print_out: + { +@@ -192,46 +192,46 @@ + sz-=todo; + width-=todo; + } +- +- if (!flag_left) { +- if (flag_dot) { +- vs=preci>sz?preci:sz; +- if (write_pad(&len,fn,(signed int)width-(signed int)vs,' ')) +- return -1; +- if (todo) { +- B_WRITE(fn,sign,todo); +- len+=todo; +- } +- if (write_pad(&len,fn,(signed int)preci-(signed int)sz,'0')) +- return -1; +- } else { +- if (todo && padwith=='0') { +- B_WRITE(fn,sign,todo); +- len+=todo; todo=0; +- } +- if (write_pad(&len,fn,(signed int)width-(signed int)sz, padwith)) +- return -1; +- if (todo) { +- B_WRITE(fn,sign,todo); +- len+=todo; +- } +- } +- B_WRITE(fn,s,sz); len+=sz; +- } else if (flag_left) { +- if (todo) { +- B_WRITE(fn,sign,todo); +- len+=todo; +- } +- if (write_pad(&len,fn,(signed int)preci-(signed int)sz, '0')) ++ ++ /* These are the cases for 1234 or "1234" respectively: ++ %.6u -> "001234" ++ %6u -> " 1234" ++ %06u -> "001234" ++ %-6u -> "1234 " ++ %.6s -> "1234" ++ %6s -> " 1234" ++ %06s -> " 1234" ++ %-6s -> "1234 " ++ %6.5u -> " 01234" ++ %6.5s -> " 1234" ++ In this code, for %6.5s, 6 is width, 5 is preci. ++ flag_dot means there was a '.' and preci is set. ++ flag_left means there was a '-'. ++ sz is 4 (strlen("1234")). ++ padwith will be '0' for %06u, ' ' otherwise. ++ precpadwith is '0' for %u, ' ' for %s. ++ */ ++ ++ if (flag_dot && width==0) width=preci; ++ if (!flag_dot) preci=sz; ++ if (!flag_left) { /* do left-side padding */ ++ if (write_pad(&len,fn,width-preci,padwith)) + return -1; +- B_WRITE(fn,s,sz); len+=sz; +- vs=preci>sz?preci:sz; +- if ((signed int)width-(signed int)vs<0) return -1; +- if (write_pad(&len,fn,(signed int)width-(signed int)vs, ' ')) ++ } ++ if (todo) { ++ B_WRITE(fn,sign,todo); ++ len+=todo; ++ } ++ /* do preci padding */ ++ if (write_pad(&len,fn,preci-sz,precpadwith)) ++ return -1; ++ /* write actual string */ ++ B_WRITE(fn,s,sz); len+=sz; ++ if (flag_left) { ++ if (write_pad(&len,fn,width-preci,padwith)) + return -1; +- } else { +- B_WRITE(fn,s,sz); len+=sz; + } ++ + break; + } + +@@ -327,6 +327,8 @@ + ++sz; + } else flag_in_sign=0; + ++ precpadwith='0'; ++ + goto print_out; + + #ifdef WANT_FLOATING_POINT_IN_PRINTF +@@ -374,6 +376,8 @@ + } + + sz=strlen(s); ++ if (width