Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4265 → Rev 4266

/trunk/uspace/app/bdsh/input.c
61,7 → 61,7
if (NULL == usr->line)
return CL_EFAIL;
 
tmp = strdup(usr->line);
tmp = str_dup(usr->line);
 
cmd[n] = strtok(tmp, " ");
while (cmd[n] && n < WORD_MAX) {
155,7 → 155,7
/* Make sure we don't have rubbish or a C/R happy user */
if (str_cmp(line, "") == 0 || str_cmp(line, "\n") == 0)
return;
usr->line = strdup(line);
usr->line = str_dup(line);
 
return;
}
/trunk/uspace/app/bdsh/cmds/modules/touch/touch.c
80,7 → 80,7
}
 
for (i = 1; i < argc; i ++) {
buff = strdup(argv[i]);
buff = str_dup(argv[i]);
dirp = opendir(buff);
if (dirp) {
cli_error(CL_ENOTSUP, "%s is a directory", buff);
/trunk/uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
93,7 → 93,7
 
/* Its a good idea to allocate path, plus we (may) need a copy of
* path to tokenize if parents are specified */
if (NULL == (tmp = strdup(path))) {
if (NULL == (tmp = str_dup(path))) {
cli_error(CL_ENOMEM, "%s: path too big?", cmdname);
return 1;
}
/trunk/uspace/app/bdsh/cmds/modules/ls/ls.c
182,7 → 182,7
if (argc == 1)
getcwd(buff, PATH_MAX);
else
strncpy(buff, argv[1], PATH_MAX);
str_ncpy(buff, argv[1], PATH_MAX);
 
scope = ls_scope(buff);
 
/trunk/uspace/app/bdsh/exec.c
80,7 → 80,7
return (char *) cmd;
}
 
path_tok = strdup(PATH);
path_tok = str_dup(PATH);
 
/* Extract the PATH env to a path[] array */
path[n] = strtok(path_tok, PATH_DELIM);
114,7 → 114,7
task_id_t tid;
char *tmp;
 
tmp = strdup(find_command(cmd));
tmp = str_dup(find_command(cmd));
free(found);
 
tid = task_spawn((const char *)tmp, argv);
/trunk/uspace/app/tetris/scores.c
131,7 → 131,7
clear_screen();
moveto(10 , 10);
puts("Insert your name: ");
strncpy(scores[NUMSPOTS - 1].hs_name, "Player", MAXLOGNAME);
str_ncpy(scores[NUMSPOTS - 1].hs_name, "Player", MAXLOGNAME);
i = 6; off = 6;
 
moveto(10 , 28);
195,7 → 195,7
{
int i;
for(i = 0; i < NUMSPOTS; i++) {
strncpy(scores[i].hs_name, "HelenOS Team", MAXLOGNAME);
str_ncpy(scores[i].hs_name, "HelenOS Team", MAXLOGNAME);
scores[i].hs_score = (NUMSPOTS - i) * 200;
scores[i].hs_level = (i + 1 > MAXLEVEL?MAXLEVEL:i + 1);
}
/trunk/uspace/app/tetris/tetris.c
311,7 → 311,7
errx(1, "duplicate command keys specified.");
}
if (keys[i] == ' ')
strncpy(key_write[i], "<space>", sizeof key_write[i]);
str_ncpy(key_write[i], "<space>", sizeof key_write[i]);
else {
key_write[i][0] = keys[i];
key_write[i][1] = '\0';
/trunk/uspace/lib/libc/include/string.h
78,6 → 78,8
extern bool wstr_linsert(wchar_t *str, wchar_t ch, count_t pos, count_t max_pos);
extern bool wstr_remove(wchar_t *str, count_t pos);
 
extern char *str_dup(const char *);
 
/*
* TODO: Get rid of this.
*/
86,12 → 88,8
extern int stricmp(const char *, const char *);
 
extern char *strcpy(char *, const char *);
extern char *strncpy(char *, const char *, size_t);
 
extern char *strcat(char *, const char *);
 
extern char *strdup(const char *);
 
extern long int strtol(const char *, char **, int);
extern unsigned long strtoul(const char *, char **, int);
 
/trunk/uspace/lib/libc/generic/string.c
40,6 → 40,7
#include <malloc.h>
#include <errno.h>
#include <align.h>
#include <mem.h>
#include <string.h>
 
/** Byte mask consisting of lowest @n bits (out of 8) */
806,15 → 807,6
return orig;
}
 
char *strncpy(char *dest, const char *src, size_t n)
{
char *orig = dest;
while ((*(dest++) = *(src++)) && --n)
;
return orig;
}
 
char *strcat(char *dest, const char *src)
{
char *orig = dest;
826,15 → 818,15
return orig;
}
 
char * strdup(const char *s1)
char *str_dup(const char *src)
{
size_t len = str_size(s1) + 1;
void *ret = malloc(len);
size_t size = str_size(src);
void *dest = malloc(size + 1);
 
if (ret == NULL)
if (dest == NULL)
return (char *) NULL;
 
return (char *) memcpy(ret, s1, len);
return (char *) memcpy(dest, src, size + 1);
}
 
char *strtok(char *s, const char *delim)
/trunk/uspace/lib/libc/generic/vfs/vfs.c
99,7 → 99,7
* the address in ncwd_path need not be the same as ncwd_path_nc, even
* though they both point into the same dynamically allocated buffer.
*/
ncwd_path = strdup(ncwd_path);
ncwd_path = str_dup(ncwd_path);
free(ncwd_path_nc);
if (!ncwd_path) {
futex_up(&cwd_futex);