diff options
author | ache <ache@FreeBSD.org> | 1995-03-24 17:59:48 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1995-03-24 17:59:48 +0000 |
commit | f362fa39c5d219c09612e83f1458ceffd6663366 (patch) | |
tree | ae13072b2c5edc5ecb878f99b6d29344fad6eea8 /gnu/lib | |
parent | 89bccb0c6fab19c5c24cc80c7de0343b63d547c3 (diff) | |
download | FreeBSD-src-f362fa39c5d219c09612e83f1458ceffd6663366.zip FreeBSD-src-f362fa39c5d219c09612e83f1458ceffd6663366.tar.gz |
Get rid of strtok(), it is depricated inside libs
Diffstat (limited to 'gnu/lib')
-rw-r--r-- | gnu/lib/libdialog/kernel.c | 10 | ||||
-rw-r--r-- | gnu/lib/libdialog/prgbox.c | 10 |
2 files changed, 11 insertions, 9 deletions
diff --git a/gnu/lib/libdialog/kernel.c b/gnu/lib/libdialog/kernel.c index d3793037..defb321 100644 --- a/gnu/lib/libdialog/kernel.c +++ b/gnu/lib/libdialog/kernel.c @@ -167,7 +167,7 @@ void attr_clear(WINDOW *win, int height, int width, chtype attr) */ void print_autowrap(WINDOW *win, unsigned char *prompt, int height, int width, int maxwidth, int y, int x, int center, int rawmode) { - int first = 1, cur_x, cur_y, i; + int cur_x, cur_y, i; unsigned char tempstr[MAX_LEN+1], *word, *tempptr, *tempptr1; chtype ostuff[132], attrs = 0, init_bottom = 0; @@ -244,13 +244,15 @@ void print_autowrap(WINDOW *win, unsigned char *prompt, int height, int width, i waddstr(win, tempstr); } else { + char *p = tempstr; + /* Print prompt word by word, wrap around if necessary */ - while ((word = strtok(first ? tempstr : NULL, "\t\n ")) != NULL) { + while ((word = strsep(&p, "\t\n ")) != NULL) { int loop; unsigned char sc; - if (first) /* First iteration */ - first = 0; + if (*word == '\0') + continue; do { loop = 0; if (cur_x+strlen(word) >= width+1) { /* wrap around to next line */ diff --git a/gnu/lib/libdialog/prgbox.c b/gnu/lib/libdialog/prgbox.c index 7082b67..11274e2 100644 --- a/gnu/lib/libdialog/prgbox.c +++ b/gnu/lib/libdialog/prgbox.c @@ -78,13 +78,13 @@ int dialog_prgbox(unsigned char *title, const unsigned char *line, int height, i if (!use_shell) { char cmdline[MAX_LEN]; - char *av[51], **ap = av, *val; - int first = 1; + char *av[51], **ap = av, *val, *p; strcpy(cmdline, line); - while ((val = strtok(first ? cmdline : NULL, " \t")) != NULL) { - first = 0; - *ap++ = val; + p = cmdline; + while ((val = strsep(&p," \t")) != NULL) { + if (*val != '\0') + *ap++ = val; } *ap = NULL; f = raw_popen(name = av[0], av, "r"); |