/trunk/kernel/generic/src/printf/printf_core.c |
---|
125,9 → 125,9 |
static int printf_putstr(const char *str, printf_spec_t *ps) |
{ |
if (str == NULL) |
return printf_putnchars_utf8(nullstr, str_size(nullstr), ps); |
return printf_putnchars_utf8(nullstr, strlen(nullstr), ps); |
return ps->write_utf8((void *) str, str_size(str), ps->data); |
return ps->write_utf8((void *) str, strlen(str), ps->data); |
} |
/** Print one ASCII character. |
/trunk/kernel/generic/src/lib/string.c |
---|
69,6 → 69,7 |
* @param limit Size of the substring. |
* |
* @return Value of decoded character or '?' on decoding error. |
* |
*/ |
wchar_t chr_decode(const char *str, size_t *offset, size_t sz) |
{ |
245,6 → 246,7 |
/** Check whether character is Unicode. |
* |
* @return True if character is valid Unicode code point. |
* |
*/ |
bool unicode_check(const wchar_t ch) |
{ |
254,19 → 256,18 |
return false; |
} |
/** Return number of bytes the string occupies. |
/** Return number of plain characters in a string. |
* |
* @param str A string. |
* @return Number of bytes in @a str excluding the null terminator. |
* @param str NULL-terminated string. |
* |
* @return Number of characters in @a str. |
* |
*/ |
size_t str_size(const char *str) |
size_t strlen(const char *str) |
{ |
size_t size; |
for (size = 0; str[size]; size++); |
size = 0; |
while (*str++ != '\0') |
++size; |
return size; |
} |
345,6 → 346,7 |
* @param len Maximal length for comparison. |
* |
* @return 0 if the strings are equal, -1 if first is smaller, 1 if second smaller. |
* |
*/ |
int strncmp(const char *src, const char *dst, size_t len) |
{ |
378,6 → 380,7 |
* @param src Source string. |
* @param dest Destination buffer. |
* @param len Size of destination buffer. |
* |
*/ |
void strncpy(char *dest, const char *src, size_t len) |
{ |
/trunk/kernel/generic/src/console/kconsole.c |
---|
137,8 → 137,8 |
spinlock_lock(&cmd->lock); |
spinlock_lock(&hlp->lock); |
} |
if ((strncmp(hlp->name, cmd->name, max(str_size(cmd->name), |
str_size(hlp->name))) == 0)) { |
if ((strncmp(hlp->name, cmd->name, max(strlen(cmd->name), |
strlen(hlp->name))) == 0)) { |
/* The command is already there. */ |
spinlock_unlock(&hlp->lock); |
spinlock_unlock(&cmd->lock); |
172,7 → 172,7 |
{ |
int i; |
for (i = str_size(str); i > pos; i--) |
for (i = strlen(str); i > pos; i--) |
str[i] = str[i - 1]; |
str[pos] = ch; |
} |
180,7 → 180,7 |
/** Try to find a command beginning with prefix */ |
static const char *cmdtab_search_one(const char *name,link_t **startpos) |
{ |
size_t namelen = str_size(name); |
size_t namelen = strlen(name); |
const char *curname; |
spinlock_lock(&cmd_lock); |
193,7 → 193,7 |
hlp = list_get_instance(*startpos, cmd_info_t, link); |
curname = hlp->name; |
if (str_size(curname) < namelen) |
if (strlen(curname) < namelen) |
continue; |
if (strncmp(curname, name, namelen) == 0) { |
spinlock_unlock(&cmd_lock); |
222,7 → 222,7 |
while ((foundtxt = cmdtab_search_one(name, &startpos))) { |
startpos = startpos->next; |
if (!found) |
strncpy(output, foundtxt, str_size(foundtxt) + 1); |
strncpy(output, foundtxt, strlen(foundtxt) + 1); |
else { |
for (i = 0; output[i] && foundtxt[i] && |
output[i] == foundtxt[i]; i++) |
234,7 → 234,7 |
if (!found) |
return 0; |
if (found > 1 && !str_size(output)) { |
if (found > 1 && !strlen(output)) { |
printf("\n"); |
startpos = NULL; |
while ((foundtxt = cmdtab_search_one(name, &startpos))) { |
309,10 → 309,10 |
i++, curlen++) |
insert_char(current, tmp[i], i + position); |
if (str_size(tmp) || found == 1) { /* If we have a hint */ |
if (strlen(tmp) || found == 1) { /* If we have a hint */ |
for (i = position; i < curlen; i++) |
putchar(current[i]); |
position += str_size(tmp); |
position += strlen(tmp); |
/* Add space to end */ |
if (found == 1 && position == curlen && |
curlen < MAX_CMDLINE) { |
325,7 → 325,7 |
printf("%s> ", prompt); |
for (i = 0; i < curlen; i++) |
putchar(current[i]); |
position += str_size(tmp); |
position += strlen(tmp); |
} |
rdln_print_c('\b', curlen - position); |
continue; |
384,7 → 384,7 |
} |
current = history[histposition]; |
printf("%s", current); |
curlen = str_size(current); |
curlen = strlen(current); |
position = curlen; |
continue; |
} |
443,7 → 443,7 |
while (true) { |
cmdline = clever_readline((char *) prompt, stdin); |
len = str_size(cmdline); |
len = strlen(cmdline); |
if (!len) |
continue; |
544,7 → 544,7 |
hlp = list_get_instance(cur, cmd_info_t, link); |
spinlock_lock(&hlp->lock); |
if (strncmp(hlp->name, &cmdline[start], max(str_size(hlp->name), |
if (strncmp(hlp->name, &cmdline[start], max(strlen(hlp->name), |
end - start + 1)) == 0) { |
cmd = hlp; |
break; |
/trunk/kernel/generic/src/console/cmd.c |
---|
519,8 → 519,8 |
hlp = list_get_instance(cur, cmd_info_t, link); |
spinlock_lock(&hlp->lock); |
if (str_size(hlp->name) > len) |
len = str_size(hlp->name); |
if (strlen(hlp->name) > len) |
len = strlen(hlp->name); |
spinlock_unlock(&hlp->lock); |
} |
591,7 → 591,7 |
hlp = list_get_instance(cur, cmd_info_t, link); |
spinlock_lock(&hlp->lock); |
if (strncmp(hlp->name, (const char *) argv->buffer, str_size(hlp->name)) == 0) { |
if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) { |
printf("%s - %s\n", hlp->name, hlp->description); |
if (hlp->help) |
hlp->help(); |
972,8 → 972,8 |
size_t len = 0; |
test_t *test; |
for (test = tests; test->name != NULL; test++) { |
if (str_size(test->name) > len) |
len = str_size(test->name); |
if (strlen(test->name) > len) |
len = strlen(test->name); |
} |
for (test = tests; test->name != NULL; test++) |
/trunk/kernel/generic/src/debug/symtab.c |
---|
106,7 → 106,7 |
*/ |
static char * symtab_search_one(const char *name, int *startpos) |
{ |
unsigned int namelen = str_size(name); |
unsigned int namelen = strlen(name); |
char *curname; |
int i, j; |
int colonoffset = -1; |
126,7 → 126,7 |
continue; |
j -= colonoffset; |
curname += j; |
if (str_size(curname) < namelen) |
if (strlen(curname) < namelen) |
continue; |
if (strncmp(curname, name, namelen) == 0) { |
*startpos = i; |
157,7 → 157,7 |
i = 0; |
while ((hint = symtab_search_one(name, &i))) { |
if (!str_size(hint)) { |
if (!strlen(hint)) { |
*addr = uint64_t_le2host(symbol_table[i].address_le); |
found++; |
} |
214,7 → 214,7 |
name++; |
/* Do not print everything */ |
if (!str_size(name)) |
if (!strlen(name)) |
return 0; |
223,7 → 223,7 |
while ((foundtxt = symtab_search_one(name, &startpos))) { |
startpos++; |
if (!found) |
strncpy(output, foundtxt, str_size(foundtxt) + 1); |
strncpy(output, foundtxt, strlen(foundtxt) + 1); |
else { |
for (i = 0; output[i] && foundtxt[i] && |
output[i] == foundtxt[i]; i++) |
235,7 → 235,7 |
if (!found) |
return 0; |
if (found > 1 && !str_size(output)) { |
if (found > 1 && !strlen(output)) { |
printf("\n"); |
startpos = 0; |
while ((foundtxt = symtab_search_one(name, &startpos))) { |
/trunk/kernel/generic/include/string.h |
---|
43,15 → 43,14 |
extern wchar_t chr_decode(const char *, size_t *, size_t); |
extern bool chr_encode(const wchar_t, char *, size_t *, size_t); |
extern size_t str_lsize(const char *, count_t); |
extern bool ascii_check(const wchar_t ch); |
extern bool unicode_check(const wchar_t ch); |
extern size_t str_size(const char *str); |
extern size_t str_lsize(const char *, count_t); |
extern size_t strlen(const char *str); |
extern count_t str_length(const char *str); |
extern count_t wstr_length(const wchar_t *str); |
extern bool ascii_check(const wchar_t ch); |
extern bool unicode_check(const wchar_t ch); |
extern int strcmp(const char *src, const char *dst); |
extern int strncmp(const char *src, const char *dst, size_t len); |
extern void strncpy(char *dest, const char *src, size_t len); |
/trunk/kernel/genarch/src/multiboot/multiboot.c |
---|
54,7 → 54,7 |
/* Find the first space. */ |
end = strchr(cmd_line, ' '); |
if (end == NULL) |
end = cmd_line + str_size(cmd_line); |
end = cmd_line + strlen(cmd_line); |
/* |
* Find last occurence of '/' before 'end'. If found, place start at |
/trunk/kernel/genarch/src/ofw/ofw_tree.c |
---|
252,8 → 252,8 |
if (path[0] != '/') |
return NULL; |
for (i = 1; i < str_size(path) && node; i = j + 1) { |
for (j = i; j < str_size(path) && path[j] != '/'; j++) |
for (i = 1; i < strlen(path) && node; i = j + 1) { |
for (j = i; j < strlen(path) && path[j] != '/'; j++) |
; |
if (i == j) /* skip extra slashes */ |
continue; |