Changeset 1b0b48e0 in mainline
- Timestamp:
- 2009-04-01T19:01:39Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 06b785f
- Parents:
- f25b2819
- Location:
- kernel/generic/src/printf
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/printf/printf_core.c
rf25b2819 r1b0b48e0 253 253 if (str == NULL) 254 254 return printf_putstr(nullstr, ps); 255 256 /* Print leading spaces */257 size_t size= str_length(str);255 256 /* Print leading spaces. */ 257 count_t strw = str_length(str); 258 258 if (precision == 0) 259 precision = s ize;259 precision = strw; 260 260 261 261 count_t counter = 0; … … 269 269 270 270 int retval; 271 size_t bytes = str_lsize(str, min(size, precision));272 if ((retval = printf_putnchars_utf8(str, bytes, ps)) < 0)271 size_t size = str_lsize(str, precision); 272 if ((retval = printf_putnchars_utf8(str, size, ps)) < 0) 273 273 return -counter; 274 274 275 275 counter += retval; 276 276 277 277 while (width-- > 0) { 278 278 if (printf_putchar(' ', ps) == 1) … … 281 281 282 282 return ((int) counter); 283 283 284 } 284 285 … … 292 293 * @return Number of UTF-32 characters printed, negative value on failure. 293 294 */ 294 static int print_utf32(wchar_t * str, int width, unsigned int precision,295 static int print_utf32(wchar_t *wstr, int width, unsigned int precision, 295 296 uint32_t flags, printf_spec_t *ps) 296 297 { 297 if ( str == NULL)298 if (wstr == NULL) 298 299 return printf_putstr(nullstr, ps); 299 300 /* Print leading spaces */301 size_t s ize = wstr_length(str);300 301 /* Print leading spaces. */ 302 size_t strw = wstr_length(wstr); 302 303 if (precision == 0) 303 precision = s ize;304 304 precision = strw; 305 305 306 count_t counter = 0; 306 307 width -= precision; … … 311 312 } 312 313 } 313 314 314 315 int retval; 315 size_t bytes = min(size, precision) * sizeof(wchar_t);316 if ((retval = printf_putnchars_utf32( str, bytes, ps)) < 0)316 size_t size = min(strw, precision) * sizeof(wchar_t); 317 if ((retval = printf_putnchars_utf32(wstr, size, ps)) < 0) 317 318 return -counter; 318 319 319 320 counter += retval; 320 321 321 322 while (width-- > 0) { 322 323 if (printf_putchar(' ', ps) == 1) 323 324 counter++; 324 325 } 325 326 326 327 return ((int) counter); 327 328 } … … 585 586 int printf_core(const char *fmt, printf_spec_t *ps, va_list ap) 586 587 { 587 index_t i = 0; /* Index of the currently processed character from fmt */588 index_t nxt = 0;589 index_t j = 0; /* Index to the first not printed nonformating character */588 size_t i = 0; /* Index of the currently processed character from fmt */ 589 size_t nxt = 0; 590 size_t j = 0; /* Index to the first not printed nonformating character */ 590 591 591 592 wchar_t uc; /* Current UTF-32 character decoded from fmt */ -
kernel/generic/src/printf/vprintf.c
rf25b2819 r1b0b48e0 46 46 static int vprintf_write_utf8(const char *str, size_t size, void *data) 47 47 { 48 index_t index= 0;49 index_t chars = 0;50 51 while ( index< size) {52 putchar(chr_decode(str, & index, size));48 size_t offset = 0; 49 count_t chars = 0; 50 51 while (offset < size) { 52 putchar(chr_decode(str, &offset, size)); 53 53 chars++; 54 54 } 55 55 56 56 return chars; 57 57 } … … 60 60 { 61 61 index_t index = 0; 62 62 63 63 while (index < (size / sizeof(wchar_t))) { 64 64 putchar(str[index]); 65 65 index++; 66 66 } 67 67 68 68 return index; 69 69 } … … 71 71 int puts(const char *str) 72 72 { 73 index_t index= 0;74 index_t chars = 0;73 size_t offset = 0; 74 count_t chars = 0; 75 75 wchar_t uc; 76 77 while ((uc = chr_decode(str, & index, UTF8_NO_LIMIT)) != 0) {76 77 while ((uc = chr_decode(str, &offset, UTF8_NO_LIMIT)) != 0) { 78 78 putchar(uc); 79 79 chars++; 80 80 } 81 81 82 82 return chars; 83 83 } … … 90 90 NULL 91 91 }; 92 92 93 93 ipl_t ipl = interrupts_disable(); 94 94 spinlock_lock(&printf_lock); 95 95 96 96 int ret = printf_core(fmt, &ps, ap); 97 97 98 98 spinlock_unlock(&printf_lock); 99 99 interrupts_restore(ipl); 100 100 101 101 return ret; 102 102 } -
kernel/generic/src/printf/vsnprintf.c
rf25b2819 r1b0b48e0 78 78 79 79 if (left <= size) { 80 /* We have not enought space forwhole string80 /* We do not have enough space for the whole string 81 81 * with the trailing zero => print only a part 82 82 * of string
Note:
See TracChangeset
for help on using the changeset viewer.