Changeset 2feeb26 in rtems
 Timestamp:
 Nov 30, 2009, 12:47:44 PM (11 years ago)
 Branches:
 4.10, 4.11, 5, master
 Children:
 51bdbca1
 Parents:
 f9925bc
 Location:
 cpukit
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

cpukit/ChangeLog
rf9925bc r2feeb26 7 7 CACHED. 8 8 * libblock/src/ide_part_table.c: Free memory in case of an error. 9 10 20091130 Sebastian Huber <sebastian.huber@embeddedbrains.de> 11 12 * libcsupport/src/vprintk.c: Fixed output of unsigned integers. 13 Changed type of boolean variables to bool. Use unsigned integer type 14 for radix and width parameters. 9 15 10 16 20091130 Sebastian Huber <sebastian.huber@embeddedbrains.de> 
cpukit/libcsupport/src/vprintk.c
rf9925bc r2feeb26 23 23 #include <stdarg.h> 24 24 #include <stdio.h> 25 #include <stdbool.h> 25 26 #include <rtems/bspIo.h> 26 27 27 28 static void printNum( 28 29 long num, 29 intbase,30 intsign,31 intmaxwidth,32 intlead30 unsigned base, 31 bool sign, 32 unsigned maxwidth, 33 char lead 33 34 ); 34 35 … … 47 48 ) 48 49 { 49 char c; 50 int lflag, base, sign, width, lead, minus; 50 for (; *fmt != '\0'; fmt++) { 51 unsigned base = 0; 52 unsigned width = 0; 53 bool lflag = false; 54 bool minus = false; 55 bool sign = false; 56 char lead = ' '; 57 char c; 51 58 52 for (; *fmt != '\0'; fmt++) {53 lflag = 0;54 base = 0;55 sign = 0;56 width = 0;57 minus = 0;58 lead = ' ';59 59 if (*fmt != '%') { 60 60 BSP_output_char(*fmt); … … 67 67 } 68 68 if (*fmt == '' ) { 69 minus = 1;69 minus = true; 70 70 fmt++; 71 71 } 72 72 while (*fmt >= '0' && *fmt <= '9' ) { 73 73 width *= 10; 74 width += ( *fmt  '0');74 width += ((unsigned) *fmt  '0'); 75 75 fmt++; 76 76 } 77 77 78 78 if ((c = *fmt) == 'l') { 79 lflag = 1;79 lflag = true; 80 80 c = *++fmt; 81 81 } 82 82 if ( c == 'c' ) { 83 char chr = (char) va_arg(ap, int);83 char chr = va_arg(ap, char); 84 84 BSP_output_char(chr); 85 85 continue; 86 86 } 87 87 if ( c == 's' ) { 88 inti, len;88 unsigned i, len; 89 89 char *s, *str; 90 90 … … 123 123 /* must be a numeric format or something unsupported */ 124 124 if ( c == 'o'  c == 'O' ) { 125 base = 8; sign = 0;125 base = 8; sign = false; 126 126 } else if ( c == 'i'  c == 'I'  127 127 c == 'd'  c == 'D' ) { 128 base = 10; sign = 1;128 base = 10; sign = true; 129 129 } else if ( c == 'u'  c == 'U' ) { 130 base = 10; sign = 0;130 base = 10; sign = false; 131 131 } else if ( c == 'x'  c == 'X' ) { 132 base = 16; sign = 0;132 base = 16; sign = false; 133 133 } else if ( c == 'p' ) { 134 base = 16; sign = 0; lflag = 1;134 base = 16; sign = false; lflag = true; 135 135 } else { 136 136 BSP_output_char(c); … … 156 156 static void printNum( 157 157 long num, 158 intbase,159 intsign,160 intmaxwidth,161 intlead158 unsigned base, 159 bool sign, 160 unsigned maxwidth, 161 char lead 162 162 ) 163 163 { 164 long n; 165 int count; 164 unsigned long unsigned_num; 165 unsigned long n; 166 unsigned count; 166 167 char toPrint[20]; 167 168 168 if ( (sign == 1) && ((long)num < 0) ) {169 if ( sign && (num < 0) ) { 169 170 BSP_output_char(''); 170 num =num;171 unsigned_num = (unsigned long) num; 171 172 if (maxwidth) maxwidth; 173 } else { 174 unsigned_num = (unsigned long) num; 172 175 } 173 176 174 177 count = 0; 175 while ((n = num / base) > 0) {176 toPrint[count++] = (char) ( num  (n*base));177 num = n;178 while ((n = unsigned_num / base) > 0) { 179 toPrint[count++] = (char) (unsigned_num  (n * base)); 180 unsigned_num = n; 178 181 } 179 toPrint[count++] = (char) num;182 toPrint[count++] = (char) unsigned_num; 180 183 181 184 for (n=maxwidth ; n > count; n ) 182 BSP_output_char( (char)lead);185 BSP_output_char(lead); 183 186 184 187 for (n = 0; n < count; n++) {
Note: See TracChangeset
for help on using the changeset viewer.