Patch from Larry Doolittle to cross things in multibuild.pl
[oweals/busybox.git] / more.c
diff --git a/more.c b/more.c
index 2334576c05c228322f82797cad49651ef4a5554b..c4c74fe4adb176b5c0564dc683b2be62776b2979 100644 (file)
--- a/more.c
+++ b/more.c
  *
  */
 
-#include "internal.h"
+#include "busybox.h"
 #include <stdio.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <stdlib.h>
 #include <sys/ioctl.h>
 #define BB_DECLARE_EXTERN
 #define bb_need_help
 #              define getTermSettings(fd,argp) tcgetattr(fd, argp);
 #      endif
 
-FILE *cin;
+static FILE *cin;
 
-struct termios initial_settings, new_settings;
+static struct termios initial_settings, new_settings;
 
-void gotsig(int sig)
+static void gotsig(int sig)
 {
        setTermSettings(fileno(cin), &initial_settings);
-       fprintf(stdout, "\n");
-       exit(TRUE);
+       putchar('\n');
+       exit(EXIT_FAILURE);
 }
 #endif /* BB_FEATURE_USE_TERMIOS */
 
@@ -78,20 +79,12 @@ extern int more_main(int argc, char **argv)
        argc--;
        argv++;
 
-       if (argc > 0
-               && (strcmp(*argv, dash_dash_help) == 0 || strcmp(*argv, "-h") == 0)) {
-               usage(more_usage);
-       }
        do {
                if (argc == 0) {
                        file = stdin;
                } else
-                       file = fopen(*argv, "r");
+                       file = xfopen(*argv, "r");
 
-               if (file == NULL) {
-                       perror(*argv);
-                       exit(FALSE);
-               }
                fstat(fileno(file), &st);
 
 #ifdef BB_FEATURE_USE_TERMIOS
@@ -125,15 +118,19 @@ extern int more_main(int argc, char **argv)
 
                                please_display_more_prompt = 0;
                                lines = 0;
-                               len = fprintf(stdout, "--More-- ");
+                               len = printf("--More-- ");
                                if (file != stdin) {
-                                       len += fprintf(stdout, "(%d%% of %ld bytes)",
+#if _FILE_OFFSET_BITS == 64
+                                       len += printf("(%d%% of %lld bytes)",
+#else
+                                       len += printf("(%d%% of %ld bytes)",
+#endif
                                                                   (int) (100 *
                                                                                  ((double) ftell(file) /
                                                                                   (double) st.st_size)),
                                                                   st.st_size);
                                }
-                               len += fprintf(stdout, "%s",
+                               len += printf("%s",
 #ifdef BB_FEATURE_USE_TERMIOS
                                                           ""
 #else