Changeset 6eb2e96 in mainline
- Timestamp:
- 2009-04-10T07:53:54Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3cc6a52
- Parents:
- f4b1535
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/ls/ls.c
rf4b1535 r6eb2e96 183 183 getcwd(buff, PATH_MAX); 184 184 else 185 str_ ncpy(buff, argv[1], PATH_MAX);185 str_cpy(buff, PATH_MAX, argv[1]); 186 186 187 187 scope = ls_scope(buff); -
uspace/app/tetris/scores.c
rf4b1535 r6eb2e96 118 118 static void copyhiscore(int dest, int src) 119 119 { 120 strcpy(scores[dest].hs_name, scores[src].hs_name); 120 str_cpy(scores[dest].hs_name, STR_BOUNDS(MAXLOGNAME) + 1, 121 scores[src].hs_name); 121 122 scores[dest].hs_score = scores[src].hs_score; 122 123 scores[dest].hs_level = scores[src].hs_level; … … 132 133 moveto(10 , 10); 133 134 puts("Insert your name: "); 134 str_ncpy(scores[NUMSPOTS - 1].hs_name, "Player", MAXLOGNAME); 135 str_cpy(scores[NUMSPOTS - 1].hs_name, STR_BOUNDS(MAXLOGNAME) + 1, 136 "Player"); 135 137 i = 6; off = 6; 136 138 … … 196 198 int i; 197 199 for(i = 0; i < NUMSPOTS; i++) { 198 str_ ncpy(scores[i].hs_name, "HelenOS Team", MAXLOGNAME);200 str_cpy(scores[i].hs_name, STR_BOUNDS(MAXLOGNAME) + 1, "HelenOS Team"); 199 201 scores[i].hs_score = (NUMSPOTS - i) * 200; 200 202 scores[i].hs_level = (i + 1 > MAXLEVEL?MAXLEVEL:i + 1); -
uspace/app/tetris/tetris.c
rf4b1535 r6eb2e96 312 312 } 313 313 if (keys[i] == ' ') 314 str_ ncpy(key_write[i], "<space>", sizeof key_write[i]);314 str_cpy(key_write[i], sizeof key_write[i], "<space>"); 315 315 else { 316 316 key_write[i][0] = keys[i]; -
uspace/lib/libc/generic/loader.c
rf4b1535 r6eb2e96 181 181 182 182 while (*ap != NULL) { 183 str_ ncpy(dp, *ap, buffer_size - (dp - arg_buf));183 str_cpy(dp, buffer_size - (dp - arg_buf), *ap); 184 184 dp += str_size(*ap) + 1; 185 185 -
uspace/lib/libc/generic/string.c
rf4b1535 r6eb2e96 463 463 } 464 464 465 /** Copy NULL-terminated string. 466 * 467 * Copy source string @a src to destination buffer @a dst. 468 * No more than @a size bytes are written. NULL-terminator is always 469 * written after the last succesfully copied character (i.e. if the 470 * destination buffer is has at least 1 byte, it will be always 471 * NULL-terminated). 472 * 473 * @param src Source string. 465 /** Copy string. 466 * 467 * Copy source string @a src to destination buffer @a dest. 468 * No more than @a size bytes are written. If the size of the output buffer 469 * is at least one byte, the output string will always be well-formed, i.e. 470 * null-terminated and containing only complete characters. 471 * 474 472 * @param dst Destination buffer. 475 473 * @param count Size of the destination buffer. 476 * 477 */ 478 void str_ncpy(char *dst, const char *src, size_t size) 479 { 480 /* No space for the NULL-terminator in the buffer */ 474 * @param src Source string. 475 */ 476 void str_cpy(char *dest, size_t size, const char *src) 477 { 478 wchar_t ch; 479 size_t src_off; 480 size_t dest_off; 481 482 /* No space for the NULL-terminator in the buffer. */ 481 483 if (size == 0) 482 484 return; 483 485 486 src_off = 0; 487 dest_off = 0; 488 489 while ((ch = str_decode(src, &src_off, STR_NO_LIMIT)) != 0) { 490 if (chr_encode(ch, dest, &dest_off, size - 1) != EOK) 491 break; 492 } 493 494 dest[dest_off] = '\0'; 495 } 496 497 /** Copy size-limited substring. 498 * 499 * Copy source string @a src to destination buffer @a dest. 500 * No more than @a size bytes are written. If the size of the output buffer 501 * is at least one byte, the output string will always be well-formed, i.e. 502 * null-terminated and containing only complete characters. 503 * 504 * No more than @a n bytes are read from the input string, so it does not 505 * have to be null-terminated. 506 * 507 * @param dst Destination buffer. 508 * @param count Size of the destination buffer. 509 * @param src Source string. 510 */ 511 void str_ncpy(char *dest, size_t size, const char *src, size_t n) 512 { 484 513 wchar_t ch; 485 size_t str_off = 0; 486 size_t dst_off = 0; 487 488 while ((ch = str_decode(src, &str_off, STR_NO_LIMIT)) != 0) { 489 if (chr_encode(ch, dst, &dst_off, size) != EOK) 514 size_t src_off; 515 size_t dest_off; 516 517 /* No space for the null terminator in the buffer. */ 518 if (size == 0) 519 return; 520 521 src_off = 0; 522 dest_off = 0; 523 524 while ((ch = str_decode(src, &src_off, n)) != 0) { 525 if (chr_encode(ch, dest, &dest_off, size - 1) != EOK) 490 526 break; 491 527 } 492 493 if (dst_off >= size) 494 dst[size - 1] = 0; 495 else 496 dst[dst_off] = 0; 528 529 dest[dest_off] = '\0'; 497 530 } 498 531 … … 799 832 } 800 833 801 char *strcpy(char *dest, const char *src)802 {803 char *orig = dest;804 805 while ((*(dest++) = *(src++)))806 ;807 return orig;808 }809 810 834 char *strcat(char *dest, const char *src) 811 835 { -
uspace/lib/libc/generic/vfs/vfs.c
rf4b1535 r6eb2e96 77 77 return NULL; 78 78 } 79 str_ ncpy(ncwd_path_nc, cwd_path, cwd_size + 1 + size + 1);79 str_cpy(ncwd_path_nc, cwd_size + 1 + size + 1, cwd_path); 80 80 ncwd_path_nc[cwd_size] = '/'; 81 81 ncwd_path_nc[cwd_size + 1] = '\0'; … … 535 535 return NULL; 536 536 } 537 str_ ncpy(buf, cwd_path, size);537 str_cpy(buf, size, cwd_path); 538 538 futex_up(&cwd_futex); 539 539 return buf; -
uspace/lib/libc/include/string.h
rf4b1535 r6eb2e96 70 70 extern int str_lcmp(const char *s1, const char *s2, count_t max_len); 71 71 72 extern void str_ncpy(char *dst, const char *src, size_t size); 72 extern void str_cpy(char *dest, size_t size, const char *src); 73 extern void str_ncpy(char *dest, size_t size, const char *src, size_t n); 74 73 75 extern void wstr_nstr(char *dst, const wchar_t *src, size_t size); 74 76 … … 88 90 extern int stricmp(const char *, const char *); 89 91 90 extern char *strcpy(char *, const char *);91 92 extern char *strcat(char *, const char *); 92 93 -
uspace/srv/fs/fat/fat_ops.c
rf4b1535 r6eb2e96 490 490 str_cmp(d->name, FAT_NAME_DOT) == 0) { 491 491 memset(d, 0, sizeof(fat_dentry_t)); 492 str cpy(d->name, FAT_NAME_DOT);493 str cpy(d->ext, FAT_EXT_PAD);492 str_cpy(d->name, 8, FAT_NAME_DOT); 493 str_cpy(d->ext, 3, FAT_EXT_PAD); 494 494 d->attr = FAT_ATTR_SUBDIR; 495 495 d->firstc = host2uint16_t_le(childp->firstc); … … 500 500 str_cmp(d->name, FAT_NAME_DOT_DOT) == 0) { 501 501 memset(d, 0, sizeof(fat_dentry_t)); 502 str cpy(d->name, FAT_NAME_DOT_DOT);503 str cpy(d->ext, FAT_EXT_PAD);502 str_cpy(d->name, 8, FAT_NAME_DOT_DOT); 503 str_cpy(d->ext, 3, FAT_EXT_PAD); 504 504 d->attr = FAT_ATTR_SUBDIR; 505 505 d->firstc = (parentp->firstc == FAT_CLST_ROOT) ? -
uspace/srv/fs/tmpfs/tmpfs_ops.c
rf4b1535 r6eb2e96 326 326 return ENOMEM; 327 327 } 328 str cpy(namep->name, nm);328 str_cpy(namep->name, size + 1, nm); 329 329 namep->parent = parentp; 330 330
Note:
See TracChangeset
for help on using the changeset viewer.