libbb: remove glibc-style bloat from sha_crypt. -1130 bytes.
[oweals/busybox.git] / util-linux / more.c
index ee559b102eb7dc0d03af7abcc256ea3841f15751..cf8e137eb56d6c4680b3de3cfce34547e7b4b407 100644 (file)
@@ -28,9 +28,7 @@ struct globals {
        struct termios new_settings;
 };
 #define G (*(struct globals*)bb_common_bufsiz1)
-//#define G (*ptr_to_globals)
 #define INIT_G() ((void)0)
-//#define INIT_G() PTR_TO_GLOBALS = xzalloc(sizeof(G))
 #define initial_settings (G.initial_settings)
 #define new_settings     (G.new_settings    )
 #define cin_fileno       (G.cin_fileno      )
@@ -38,7 +36,7 @@ struct globals {
 #define setTermSettings(fd, argp) tcsetattr(fd, TCSANOW, argp)
 #define getTermSettings(fd, argp) tcgetattr(fd, argp)
 
-static void gotsig(int sig)
+static void gotsig(int sig UNUSED_PARAM)
 {
        bb_putchar('\n');
        setTermSettings(cin_fileno, &initial_settings);
@@ -53,7 +51,7 @@ static void gotsig(int sig)
 #define CONVERTED_TAB_SIZE 8
 
 int more_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int more_main(int argc, char **argv)
+int more_main(int argc UNUSED_PARAM, char **argv)
 {
        int c = c; /* for gcc */
        int lines;
@@ -64,8 +62,8 @@ int more_main(int argc, char **argv)
        FILE *file;
        FILE *cin;
        int len;
-       int terminal_width;
-       int terminal_height;
+       unsigned terminal_width;
+       unsigned terminal_height;
 
        INIT_G();
 
@@ -74,7 +72,7 @@ int more_main(int argc, char **argv)
         * is not a tty and turns into cat. This makes sense. */
        if (!isatty(STDOUT_FILENO))
                return bb_cat(argv);
-       cin = fopen(CURRENT_TTY, "r");
+       cin = fopen_for_read(CURRENT_TTY);
        if (!cin)
                return bb_cat(argv);
 
@@ -87,9 +85,11 @@ int more_main(int argc, char **argv)
        new_settings.c_cc[VMIN] = 1;
        new_settings.c_cc[VTIME] = 0;
        setTermSettings(cin_fileno, &new_settings);
-       signal(SIGINT, gotsig);
-       signal(SIGQUIT, gotsig);
-       signal(SIGTERM, gotsig);
+       bb_signals(0
+               + (1 << SIGINT)
+               + (1 << SIGQUIT)
+               + (1 << SIGTERM)
+               , gotsig);
 #endif
 
        do {
@@ -165,7 +165,7 @@ int more_main(int argc, char **argv)
                        if (c == '\t') {
                                spaces = CONVERTED_TAB_SIZE - 1;
                                c = ' ';
-                       }
+                       }
 
                        /*
                         * There are two input streams to worry about here: