diff options
| author | Stephen Kitt <steve@sk2.org> | 2022-01-08 16:43:04 +0100 |
|---|---|---|
| committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-01-08 20:51:19 +0100 |
| commit | f091d3e26e4cdef9ecc632d6f4bd94dc16fce43e (patch) | |
| tree | cc191964efc76a4c08bec4dea92168637134979d | |
| parent | 3f311b381d2bbcbf8b067280cd503bf3f7eedb61 (diff) | |
| download | man-pages-f091d3e26e4cdef9ecc632d6f4bd94dc16fce43e.tar.gz | |
strtok.3: Fix j/str1 declaration
for (int j = 1, str1 = argv[1]; ...
declares two variables of type int, j and str1; the pre-existing
char * str1 isn't used. This causes compiler warnings. Declaring j
outside the loop fixes everything.
Signed-off-by: Stephen Kitt <steve@sk2.org>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
| -rw-r--r-- | man3/strtok.3 | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/man3/strtok.3 b/man3/strtok.3 index aec914094f..06e9688b63 100644 --- a/man3/strtok.3 +++ b/man3/strtok.3 @@ -255,6 +255,7 @@ main(int argc, char *argv[]) { char *str1, *str2, *token, *subtoken; char *saveptr1, *saveptr2; + int j; if (argc != 4) { fprintf(stderr, "Usage: %s string delim subdelim\en", @@ -262,7 +263,7 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } - for (int j = 1, str1 = argv[1]; ; j++, str1 = NULL) { + for (j = 1, str1 = argv[1]; ; j++, str1 = NULL) { token = strtok_r(str1, argv[2], &saveptr1); if (token == NULL) break; |
