wget: -O FILE is allowed to overwrite existing file (compat)
[oweals/busybox.git] / networking / hostname.c
index 50ef7b5d13fef2c63edd94d8b56a7330d54a9af2..6783dbacb38cd41066b716f82b924a71b00b0af0 100644 (file)
@@ -29,12 +29,13 @@ static void do_sethostname(char *s, int isfile)
                }
        } else {
                f = xfopen(s, "r");
-               while (fgets(bb_common_bufsiz1, sizeof(bb_common_bufsiz1), f) != NULL) {
-                       if (bb_common_bufsiz1[0] == '#') {
+#define strbuf bb_common_bufsiz1
+               while (fgets(strbuf, sizeof(strbuf), f) != NULL) {
+                       if (strbuf[0] == '#') {
                                continue;
                        }
-                       chomp(bb_common_bufsiz1);
-                       do_sethostname(bb_common_bufsiz1, 0);
+                       chomp(strbuf);
+                       do_sethostname(strbuf, 0);
                }
                if (ENABLE_FEATURE_CLEAN_UP)
                        fclose(f);
@@ -59,7 +60,7 @@ int hostname_main(int argc, char **argv)
        if (argc < 1)
                bb_show_usage();
 
-       getopt32(argc, argv, "dfisF:", &hostname_str);
+       getopt32(argv, "dfisF:", &hostname_str);
 
        /* Output in desired format */
        if (option_mask32 & OPT_dfis) {
@@ -82,7 +83,7 @@ int hostname_main(int argc, char **argv)
                        while (hp->h_addr_list[0]) {
                                printf("%s ", inet_ntoa(*(struct in_addr *) (*hp->h_addr_list++)));
                        }
-                       puts("");
+                       bb_putchar('\n');
                }
        }
        /* Set the hostname */