- Timestamp:
- 2019-02-05T18:26:05Z (6 years ago)
- Children:
- 1d2f85e
- Parents:
- d066259
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-05 16:16:55)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-05 18:26:05)
- Location:
- kernel
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/amd64.c
rd066259 r08e103d4 185 185 186 186 sysinfo_set_item_data("platform", NULL, (void *) platform, 187 str_ size(platform));187 str_bytes(platform)); 188 188 189 189 #ifdef CONFIG_PC_KBD -
kernel/arch/arm32/src/arm32.c
rd066259 r08e103d4 113 113 114 114 sysinfo_set_item_data("platform", NULL, (void *) platform, 115 str_ size(platform));115 str_bytes(platform)); 116 116 } 117 117 -
kernel/arch/ia32/src/ia32.c
rd066259 r08e103d4 170 170 171 171 sysinfo_set_item_data("platform", NULL, (void *) platform, 172 str_ size(platform));172 str_bytes(platform)); 173 173 174 174 #ifdef CONFIG_PC_KBD -
kernel/arch/ia64/src/ia64.c
rd066259 r08e103d4 156 156 #endif 157 157 sysinfo_set_item_data("platform", NULL, (void *) platform, 158 str_ size(platform));158 str_bytes(platform)); 159 159 160 160 #ifdef MACHINE_ski -
kernel/arch/mips32/src/mips32.c
rd066259 r08e103d4 155 155 sysinfo_set_item_data("platform", NULL, 156 156 (void *) machine_get_platform_name(), 157 str_ size(machine_get_platform_name()));157 str_bytes(machine_get_platform_name())); 158 158 159 159 machine_input_init(); -
kernel/arch/ppc32/src/ppc32.c
rd066259 r08e103d4 281 281 282 282 sysinfo_set_item_data("platform", NULL, (void *) platform, 283 str_ size(platform));283 str_bytes(platform)); 284 284 285 285 ofw_tree_walk_by_device_type("mac-io", macio_register, NULL); -
kernel/arch/sparc64/src/sun4u/sparc64.c
rd066259 r08e103d4 127 127 128 128 sysinfo_set_item_data("platform", NULL, (void *) platform, 129 str_ size(platform));129 str_bytes(platform)); 130 130 131 131 standalone_sparc64_console_init(); -
kernel/arch/sparc64/src/sun4v/sparc64.c
rd066259 r08e103d4 125 125 126 126 sysinfo_set_item_data("platform", NULL, (void *) platform, 127 str_ size(platform));127 str_bytes(platform)); 128 128 129 129 niagarain_init(); -
kernel/genarch/src/multiboot/multiboot.c
rd066259 r08e103d4 51 51 const char *end = str_chr(cmd_line, ' '); 52 52 if (end == NULL) 53 end = cmd_line + str_ size(cmd_line);53 end = cmd_line + str_bytes(cmd_line); 54 54 55 55 /* … … 88 88 } 89 89 90 const char *end = cmd_line + str_ size(cmd_line);90 const char *end = cmd_line + str_bytes(cmd_line); 91 91 92 92 /* Skip the space(s). */ -
kernel/genarch/src/ofw/ofw_tree.c
rd066259 r08e103d4 250 250 size_t j; 251 251 252 for (size_t i = 1; (i < str_ size(path)) && (node); i = j + 1) {252 for (size_t i = 1; (i < str_bytes(path)) && (node); i = j + 1) { 253 253 j = i; 254 while (j < str_ size(path) && path[j] != '/')254 while (j < str_bytes(path) && path[j] != '/') 255 255 j++; 256 256 … … 342 342 *size = 0; 343 343 for (size_t i = 0; i < node->properties; i++) 344 *size += str_ size(node->property[i].name) + 1 +344 *size += str_bytes(node->property[i].name) + 1 + 345 345 sizeof(node->property[i].size) + node->property[i].size; 346 346 … … 359 359 /* Property name */ 360 360 str_cpy(dump + pos, *size - pos, node->property[i].name); 361 pos += str_ size(node->property[i].name) + 1;361 pos += str_bytes(node->property[i].name) + 1; 362 362 363 363 /* Value size */ … … 393 393 if ((cur->parent) && (path)) 394 394 snprintf(cur_path, PATH_MAX_LEN, "%s.%s", path, cur->da_name); 395 else if (!str_ size(cur->da_name))395 else if (!str_bytes(cur->da_name)) 396 396 snprintf(cur_path, PATH_MAX_LEN, "firmware.ofw"); 397 397 else -
kernel/generic/include/str.h
rd066259 r08e103d4 72 72 extern errno_t chr_encode(wchar_t ch, char *str, size_t *offset, size_t sz); 73 73 74 extern size_t str_ size(const char *str);75 extern size_t wstr_ size(const wchar_t *str);74 extern size_t str_bytes(const char *str); 75 extern size_t wstr_bytes(const wchar_t *str); 76 76 77 extern size_t str_l size(const char *str, size_t max_len);78 extern size_t wstr_l size(const wchar_t *str, size_t max_len);77 extern size_t str_lbytes(const char *str, size_t max_len); 78 extern size_t wstr_lbytes(const wchar_t *str, size_t max_len); 79 79 80 extern size_t str_ length(const char *str);81 extern size_t wstr_ length(const wchar_t *wstr);80 extern size_t str_code_points(const char *str); 81 extern size_t wstr_code_points(const wchar_t *wstr); 82 82 83 extern size_t str_n length(const char *str, size_t size);84 extern size_t wstr_n length(const wchar_t *str, size_t size);83 extern size_t str_ncode_points(const char *str, size_t size); 84 extern size_t wstr_ncode_points(const wchar_t *str, size_t size); 85 85 86 86 extern bool ascii_check(wchar_t ch); -
kernel/generic/src/console/cmd.c
rd066259 r08e103d4 668 668 list_foreach(cmd_list, link, cmd_info_t, hlp) { 669 669 spinlock_lock(&hlp->lock); 670 if (str_ length(hlp->name) > len)671 len = str_ length(hlp->name);670 if (str_code_points(hlp->name) > len) 671 len = str_code_points(hlp->name); 672 672 spinlock_unlock(&hlp->lock); 673 673 } … … 919 919 spinlock_lock(&hlp->lock); 920 920 921 if (str_lcmp(hlp->name, (const char *) argv->buffer, str_ length(hlp->name)) == 0) {921 if (str_lcmp(hlp->name, (const char *) argv->buffer, str_code_points(hlp->name)) == 0) { 922 922 printf("%s - %s\n", hlp->name, hlp->description); 923 923 if (hlp->help) … … 1486 1486 1487 1487 for (test = tests; test->name != NULL; test++) { 1488 if (str_ length(test->name) > len)1489 len = str_ length(test->name);1488 if (str_code_points(test->name) > len) 1489 len = str_code_points(test->name); 1490 1490 } 1491 1491 -
kernel/generic/src/console/console.c
rd066259 r08e103d4 271 271 272 272 count--; 273 offset = str_l size(buf, count);273 offset = str_lbytes(buf, count); 274 274 buf[offset] = 0; 275 275 } -
kernel/generic/src/console/kconsole.c
rd066259 r08e103d4 167 167 { 168 168 link_t **startpos = (link_t **) ctx; 169 size_t namelen = str_ length(name);169 size_t namelen = str_code_points(name); 170 170 171 171 spinlock_lock(&cmd_lock); … … 178 178 179 179 const char *curname = hlp->name; 180 if (str_ length(curname) < namelen)180 if (str_code_points(curname) < namelen) 181 181 continue; 182 182 … … 187 187 188 188 spinlock_unlock(&cmd_lock); 189 return (curname + str_l size(curname, namelen));189 return (curname + str_lbytes(curname, namelen)); 190 190 } 191 191 } … … 233 233 234 234 while ((hint = hints_enum(name, NULL, &pos))) { 235 if ((found == 0) || (str_ length(hint) > str_length(output)))235 if ((found == 0) || (str_code_points(hint) > str_code_points(output))) 236 236 str_cpy(output, MAX_CMDLINE, hint); 237 237 … … 249 249 } 250 250 251 if ((found > 1) && (str_ length(output) != 0)) {251 if ((found > 1) && (str_code_points(output) != 0)) { 252 252 printf("\n"); 253 253 pos = NULL; … … 358 358 putwchar('\b'); 359 359 printf("%ls ", current + position); 360 print_cc('\b', wstr_ length(current) - position + 1);360 print_cc('\b', wstr_code_points(current) - position + 1); 361 361 continue; 362 362 } … … 440 440 printf("%s> ", prompt); 441 441 printf("%ls", current); 442 position += str_ length(tmp);443 print_cc('\b', wstr_ length(current) - position);442 position += str_code_points(tmp); 443 print_cc('\b', wstr_code_points(current) - position); 444 444 continue; 445 445 } … … 448 448 449 449 printf("%ls", current + position); 450 position += str_ length(tmp);451 print_cc('\b', wstr_ length(current) - position);452 453 if (position == wstr_ length(current)) {450 position += str_code_points(tmp); 451 print_cc('\b', wstr_code_points(current) - position); 452 453 if (position == wstr_code_points(current)) { 454 454 /* Insert a space after the last completed argument */ 455 455 if (wstr_linsert(current, ' ', position, MAX_CMDLINE)) { … … 472 472 if (ch == U_RIGHT_ARROW) { 473 473 /* Right */ 474 if (position < wstr_ length(current)) {474 if (position < wstr_code_points(current)) { 475 475 putwchar(current[position]); 476 476 position++; … … 482 482 /* Up, down */ 483 483 print_cc('\b', position); 484 print_cc(' ', wstr_ length(current));485 print_cc('\b', wstr_ length(current));484 print_cc(' ', wstr_code_points(current)); 485 print_cc('\b', wstr_code_points(current)); 486 486 487 487 if (ch == U_UP_ARROW) { … … 498 498 current = history[history_pos]; 499 499 printf("%ls", current); 500 position = wstr_ length(current);500 position = wstr_code_points(current); 501 501 continue; 502 502 } … … 512 512 /* End */ 513 513 printf("%ls", current + position); 514 position = wstr_ length(current);514 position = wstr_code_points(current); 515 515 continue; 516 516 } … … 518 518 if (ch == U_DELETE) { 519 519 /* Delete */ 520 if (position == wstr_ length(current))520 if (position == wstr_code_points(current)) 521 521 continue; 522 522 523 523 if (wstr_remove(current, position)) { 524 524 printf("%ls ", current + position); 525 print_cc('\b', wstr_ length(current) - position + 1);525 print_cc('\b', wstr_code_points(current) - position + 1); 526 526 } 527 527 continue; … … 531 531 printf("%ls", current + position); 532 532 position++; 533 print_cc('\b', wstr_ length(current) - position);534 } 535 } 536 537 if (wstr_ length(current) > 0) {533 print_cc('\b', wstr_code_points(current) - position); 534 } 535 } 536 537 if (wstr_code_points(current) > 0) { 538 538 history_pos++; 539 539 history_pos = history_pos % KCONSOLE_HISTORY; … … 690 690 691 691 if (str_lcmp(hlp->name, cmdline + start, 692 max(str_ length(hlp->name),693 str_n length(cmdline + start, (size_t) (end - start)))) == 0) {692 max(str_code_points(hlp->name), 693 str_ncode_points(cmdline + start, (size_t) (end - start)))) == 0) { 694 694 cmd = hlp; 695 695 break; … … 826 826 while (true) { 827 827 wchar_t *tmp = clever_readline((char *) prompt, stdin, buffer); 828 size_t len = wstr_ length(tmp);828 size_t len = wstr_code_points(tmp); 829 829 if (!len) 830 830 continue; -
kernel/generic/src/debug/symtab.c
rd066259 r08e103d4 120 120 static const char *symtab_search_one(const char *name, size_t *startpos) 121 121 { 122 size_t namelen = str_ length(name);122 size_t namelen = str_code_points(name); 123 123 124 124 size_t pos; … … 131 131 continue; 132 132 133 if (str_ length(curname) < namelen)133 if (str_code_points(curname) < namelen) 134 134 continue; 135 135 136 136 if (str_lcmp(name, curname, namelen) == 0) { 137 137 *startpos = pos; 138 return (curname + str_l size(curname, namelen));138 return (curname + str_lbytes(curname, namelen)); 139 139 } 140 140 } … … 164 164 165 165 while ((hint = symtab_search_one(name, &pos))) { 166 if (str_ length(hint) == 0) {166 if (str_code_points(hint) == 0) { 167 167 *addr = uint64_t_le2host(symbol_table[pos].address_le); 168 168 found++; … … 206 206 { 207 207 #ifdef CONFIG_SYMTAB 208 size_t len = str_ length(input);208 size_t len = str_code_points(input); 209 209 struct symtab_entry **entry = (struct symtab_entry **)ctx; 210 210 … … 220 220 continue; 221 221 222 if (str_ length(curname) < len)222 if (str_code_points(curname) < len) 223 223 continue; 224 224 … … 227 227 if (help) 228 228 *help = NULL; 229 return (curname + str_l size(curname, len));229 return (curname + str_lbytes(curname, len)); 230 230 } 231 231 } -
kernel/generic/src/lib/str.c
rd066259 r08e103d4 288 288 * 289 289 */ 290 size_t str_ size(const char *str)290 size_t str_bytes(const char *str) 291 291 { 292 292 size_t size = 0; … … 308 308 * 309 309 */ 310 size_t wstr_ size(const wchar_t *str)311 { 312 return (wstr_ length(str) * sizeof(wchar_t));310 size_t wstr_bytes(const wchar_t *str) 311 { 312 return (wstr_code_points(str) * sizeof(wchar_t)); 313 313 } 314 314 … … 326 326 * 327 327 */ 328 size_t str_l size(const char *str, size_t max_len)328 size_t str_lbytes(const char *str, size_t max_len) 329 329 { 330 330 size_t len = 0; … … 354 354 * 355 355 */ 356 size_t wstr_l size(const wchar_t *str, size_t max_len)357 { 358 return (wstr_n length(str, max_len * sizeof(wchar_t)) * sizeof(wchar_t));356 size_t wstr_lbytes(const wchar_t *str, size_t max_len) 357 { 358 return (wstr_ncode_points(str, max_len * sizeof(wchar_t)) * sizeof(wchar_t)); 359 359 } 360 360 … … 366 366 * 367 367 */ 368 size_t str_ length(const char *str)368 size_t str_code_points(const char *str) 369 369 { 370 370 size_t len = 0; … … 384 384 * 385 385 */ 386 size_t wstr_ length(const wchar_t *wstr)386 size_t wstr_code_points(const wchar_t *wstr) 387 387 { 388 388 size_t len = 0; … … 402 402 * 403 403 */ 404 size_t str_n length(const char *str, size_t size)404 size_t str_ncode_points(const char *str, size_t size) 405 405 { 406 406 size_t len = 0; … … 421 421 * 422 422 */ 423 size_t wstr_n length(const wchar_t *str, size_t size)423 size_t wstr_ncode_points(const wchar_t *str, size_t size) 424 424 { 425 425 size_t len = 0; … … 508 508 * Do a char-by-char comparison of two NULL-terminated strings. 509 509 * The strings are considered equal iff 510 * min(str_ length(s1), max_len) == min(str_length(s2), max_len)510 * min(str_code_points(s1), max_len) == min(str_code_points(s2), max_len) 511 511 * and both strings consist of the same sequence of characters, 512 512 * up to max_len characters. … … 690 690 bool wstr_linsert(wchar_t *str, wchar_t ch, size_t pos, size_t max_pos) 691 691 { 692 size_t len = wstr_ length(str);692 size_t len = wstr_code_points(str); 693 693 694 694 if ((pos > len) || (pos + 1 > max_pos)) … … 718 718 bool wstr_remove(wchar_t *str, size_t pos) 719 719 { 720 size_t len = wstr_ length(str);720 size_t len = wstr_code_points(str); 721 721 722 722 if (pos >= len) … … 748 748 char *str_dup(const char *src) 749 749 { 750 size_t size = str_ size(src) + 1;750 size_t size = str_bytes(src) + 1; 751 751 char *dest = malloc(size); 752 752 if (!dest) … … 779 779 char *str_ndup(const char *src, size_t n) 780 780 { 781 size_t size = str_ size(src);781 size_t size = str_bytes(src); 782 782 if (size > n) 783 783 size = n; -
kernel/generic/src/main/kinit.c
rd066259 r08e103d4 193 193 for (i = 0; i < init.cnt; i++) { 194 194 const char *arguments = init.tasks[i].arguments; 195 if (str_ length(arguments) == 0)196 continue; 197 if (str_ length(init.tasks[i].name) == 0)198 continue; 199 size_t arguments_size = str_ size(arguments);195 if (str_code_points(arguments) == 0) 196 continue; 197 if (str_code_points(init.tasks[i].name) == 0) 198 continue; 199 size_t arguments_size = str_bytes(arguments); 200 200 201 201 void *arguments_copy = malloc(arguments_size); -
kernel/generic/src/main/main.c
rd066259 r08e103d4 279 279 sys_waitq_init(); 280 280 281 sysinfo_set_item_data("boot_args", NULL, bargs, str_ size(bargs) + 1);281 sysinfo_set_item_data("boot_args", NULL, bargs, str_bytes(bargs) + 1); 282 282 283 283 if (init.cnt > 0) { -
kernel/generic/src/printf/printf_core.c
rd066259 r08e103d4 156 156 { 157 157 if (str == NULL) 158 return printf_putnchars(nullstr, str_ size(nullstr), ps);159 160 return ps->str_write((void *) str, str_ size(str), ps->data);158 return printf_putnchars(nullstr, str_bytes(nullstr), ps); 159 160 return ps->str_write((void *) str, str_bytes(str), ps->data); 161 161 } 162 162 … … 285 285 286 286 /* Print leading spaces. */ 287 size_t strw = str_ length(str);287 size_t strw = str_code_points(str); 288 288 if ((precision == 0) || (precision > strw)) 289 289 precision = strw; … … 301 301 /* Part of @a str fitting into the alloted space. */ 302 302 int retval; 303 size_t size = str_l size(str, precision);303 size_t size = str_lbytes(str, precision); 304 304 if ((retval = printf_putnchars(str, size, ps)) < 0) 305 305 return -counter; … … 333 333 334 334 /* Print leading spaces. */ 335 size_t strw = wstr_ length(str);335 size_t strw = wstr_code_points(str); 336 336 if ((precision == 0) || (precision > strw)) 337 337 precision = strw; … … 349 349 /* Part of @a wstr fitting into the alloted space. */ 350 350 int retval; 351 size_t size = wstr_l size(str, precision);351 size_t size = wstr_lbytes(str, precision); 352 352 if ((retval = printf_wputnchars(str, size, ps)) < 0) 353 353 return -counter; -
kernel/generic/src/sysinfo/sysinfo.c
rd066259 r08e103d4 530 530 if (spaces == 0) { 531 531 printf("%s", cur->name); 532 length = str_ length(cur->name);532 length = str_code_points(cur->name); 533 533 } else { 534 534 sysinfo_indent(spaces); 535 535 printf(".%s", cur->name); 536 length = str_ length(cur->name) + 1;536 length = str_code_points(cur->name) + 1; 537 537 } 538 538 … … 747 747 size_t size = 0; 748 748 for (sysinfo_item_t *cur = subtree; cur; cur = cur->next) 749 size += str_ size(cur->name) + 1;749 size += str_bytes(cur->name) + 1; 750 750 751 751 if (dry_run) { … … 762 762 for (sysinfo_item_t *cur = subtree; cur; cur = cur->next) { 763 763 str_cpy(names + pos, size - pos, cur->name); 764 pos += str_ size(cur->name) + 1;764 pos += str_bytes(cur->name) + 1; 765 765 } 766 766 -
kernel/generic/src/udebug/udebug_ops.c
rd066259 r08e103d4 432 432 errno_t udebug_name_read(char **data, size_t *data_size) 433 433 { 434 size_t name_size = str_ size(TASK->name) + 1;434 size_t name_size = str_bytes(TASK->name) + 1; 435 435 436 436 *data = malloc(name_size); -
kernel/test/test.c
rd066259 r08e103d4 66 66 void **ctx) 67 67 { 68 size_t len = str_ length(input);68 size_t len = str_code_points(input); 69 69 test_t **test = (test_t **) ctx; 70 70 … … 75 75 const char *curname = (*test)->name; 76 76 77 if (str_ length(curname) < len)77 if (str_code_points(curname) < len) 78 78 continue; 79 79 … … 82 82 if (help) 83 83 *help = (*test)->desc; 84 return (curname + str_l size(curname, len));84 return (curname + str_lbytes(curname, len)); 85 85 } 86 86 }
Note:
See TracChangeset
for help on using the changeset viewer.