accidentally applied wrong (old) patch, fixing up...
[oweals/busybox.git] / miscutils / strings.c
index e9f335ebda5ec4698591f5873cd8b614bd46bbc2..0d5576e9b2aea464567bb8540cbec3f7c70e6e22 100644 (file)
 int strings_main(int argc, char **argv)
 {
        int n, c, i = 0, status = EXIT_SUCCESS;
-       unsigned long opt;
+       unsigned opt;
        unsigned long count;
        FILE *file = stdin;
        char *string;
        const char *fmt = "%s: ";
        char *n_arg = "4";
 
-       opt = bb_getopt_ulflags(argc, argv, "afon:", &n_arg);
+       opt = getopt32(argc, argv, "afon:", &n_arg);
        /* -a is our default behaviour */
 
        argc -= optind;
        argv += optind;
 
-       n = bb_xgetlarg(n_arg, 10, 1, INT_MAX);
+       n = xatoul_range(n_arg, 1, INT_MAX);
        string = xzalloc(n + 1);
        n--;
 
@@ -45,7 +45,8 @@ int strings_main(int argc, char **argv)
        }
 
        do {
-               if ((file = bb_wfopen(*argv, "r"))) {
+               file = fopen_or_warn(*argv, "r");
+               if (file) {
 PIPE:
                        count = 0;
                        do {
@@ -74,7 +75,7 @@ PIPE:
                                }
                                count++;
                        } while (c != EOF);
-                       bb_fclose_nonstdin(file);
+                       fclose_if_not_stdin(file);
                } else {
                        status = EXIT_FAILURE;
                }
@@ -83,5 +84,5 @@ PIPE:
        if (ENABLE_FEATURE_CLEAN_UP)
                free(string);
 
-       bb_fflush_stdout_and_exit(status);
+       fflush_stdout_and_exit(status);
 }