Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4205 → Rev 4206

/trunk/kernel/generic/src/printf/vprintf.c
45,14 → 45,14
 
static int vprintf_write_utf8(const char *str, size_t size, void *data)
{
index_t index = 0;
index_t chars = 0;
while (index < size) {
putchar(chr_decode(str, &index, size));
size_t offset = 0;
count_t chars = 0;
 
while (offset < size) {
putchar(chr_decode(str, &offset, size));
chars++;
}
 
return chars;
}
 
59,26 → 59,26
static int vprintf_write_utf32(const wchar_t *str, size_t size, void *data)
{
index_t index = 0;
 
while (index < (size / sizeof(wchar_t))) {
putchar(str[index]);
index++;
}
 
return index;
}
 
int puts(const char *str)
{
index_t index = 0;
index_t chars = 0;
size_t offset = 0;
count_t chars = 0;
wchar_t uc;
while ((uc = chr_decode(str, &index, UTF8_NO_LIMIT)) != 0) {
 
while ((uc = chr_decode(str, &offset, UTF8_NO_LIMIT)) != 0) {
putchar(uc);
chars++;
}
 
return chars;
}
 
89,15 → 89,15
vprintf_write_utf32,
NULL
};
 
ipl_t ipl = interrupts_disable();
spinlock_lock(&printf_lock);
 
int ret = printf_core(fmt, &ps, ap);
 
spinlock_unlock(&printf_lock);
interrupts_restore(ipl);
 
return ret;
}
 
/trunk/kernel/generic/src/printf/vsnprintf.c
77,7 → 77,7
}
if (left <= size) {
/* We have not enought space for whole string
/* We do not have enough space for the whole string
* with the trailing zero => print only a part
* of string
*/
/trunk/kernel/generic/src/printf/printf_core.c
252,11 → 252,11
{
if (str == NULL)
return printf_putstr(nullstr, ps);
/* Print leading spaces */
size_t size = str_length(str);
 
/* Print leading spaces. */
count_t strw = str_length(str);
if (precision == 0)
precision = size;
precision = strw;
 
count_t counter = 0;
width -= precision;
268,12 → 268,12
}
 
int retval;
size_t bytes = str_lsize(str, min(size, precision));
if ((retval = printf_putnchars_utf8(str, bytes, ps)) < 0)
size_t size = str_lsize(str, precision);
if ((retval = printf_putnchars_utf8(str, size, ps)) < 0)
return -counter;
 
counter += retval;
 
while (width-- > 0) {
if (printf_putchar(' ', ps) == 1)
counter++;
280,6 → 280,7
}
 
return ((int) counter);
 
}
 
/** Print UTF-32 string.
291,17 → 292,17
*
* @return Number of UTF-32 characters printed, negative value on failure.
*/
static int print_utf32(wchar_t *str, int width, unsigned int precision,
static int print_utf32(wchar_t *wstr, int width, unsigned int precision,
uint32_t flags, printf_spec_t *ps)
{
if (str == NULL)
if (wstr == NULL)
return printf_putstr(nullstr, ps);
/* Print leading spaces */
size_t size = wstr_length(str);
 
/* Print leading spaces. */
size_t strw = wstr_length(wstr);
if (precision == 0)
precision = size;
precision = strw;
 
count_t counter = 0;
width -= precision;
if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
310,19 → 311,19
counter++;
}
}
 
int retval;
size_t bytes = min(size, precision) * sizeof(wchar_t);
if ((retval = printf_putnchars_utf32(str, bytes, ps)) < 0)
size_t size = min(strw, precision) * sizeof(wchar_t);
if ((retval = printf_putnchars_utf32(wstr, size, ps)) < 0)
return -counter;
 
counter += retval;
 
while (width-- > 0) {
if (printf_putchar(' ', ps) == 1)
counter++;
}
 
return ((int) counter);
}
 
584,9 → 585,9
*/
int printf_core(const char *fmt, printf_spec_t *ps, va_list ap)
{
index_t i = 0; /* Index of the currently processed character from fmt */
index_t nxt = 0;
index_t j = 0; /* Index to the first not printed nonformating character */
size_t i = 0; /* Index of the currently processed character from fmt */
size_t nxt = 0;
size_t j = 0; /* Index to the first not printed nonformating character */
wchar_t uc; /* Current UTF-32 character decoded from fmt */
count_t counter = 0; /* Number of UTF-8 characters printed */