[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

another patch for busybox (more)



Hello,

  here is a patch for more.  The main problem is that more is starting to read
from stdin after the last file was finished to read.  Another problem was that
options were not parsed correctly (tested against argv[0] instead of argv[1]).

Regards.

PS: I still don't have easy access to cvs (I'm behind a router that don't
    forward dynamic ppp addresses) therefore I prefer to post the patch to the
    mailing list instead of commiting in myself.  I hope it's not too annoying.


--- ../../../boot-floppies-991107.orig/utilities/busybox/more.c	Fri Oct 22 19:42:24 1999
+++ more.c	Sun Nov  7 16:13:11 1999
@@ -42,7 +42,7 @@
 #ifdef BB_MORE_TERM
 
 
-#if defined (__sparc__)
+#if #cpu(sparc)
 #      define USE_OLD_TERMIO
 #      include <termio.h>
 #      include <sys/ioctl.h>
@@ -69,13 +69,14 @@
     struct stat st;	
     FILE *file;
 
-    if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
-	usage (more_usage);
-    }
     argc--;
     argv++;
 
-    while (argc >= 0) {
+    if ( argc > 0 && (strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0) ) {
+	usage (more_usage);
+    }
+
+    do {
 	if (argc==0) {
 	    file = stdin;
 	}
@@ -103,6 +104,8 @@
 	stty(fileno(cin), &new_settings);
 	
 	(void) signal(SIGINT, gotsig);
+	(void) signal(SIGQUIT, gotsig);
+	(void) signal(SIGTERM, gotsig);
 
 #endif
 	while ((c = getc(file)) != EOF) {
@@ -141,9 +144,9 @@
 	    }
 	    if (input=='q')
 		goto end;
-	    if (input==' ' &&  c == '\n' )
+	    if (input=='\n' &&  c == '\n' )
 		next_page = 1;
-	    if ( c == '\n' && ++lines == 24 )
+	    if ( c == ' ' && ++lines == 24 )
 		next_page = 1;
 	    putc(c, stdout);
 	}
@@ -152,7 +155,7 @@
 
 	argc--;
 	argv++;
-    }
+    } while (argc > 0);
 end:
 #ifdef BB_MORE_TERM
     gotsig(0);

-- 
 Eric Delaunay                 | "La guerre justifie l'existence des militaires.
 delaunay@lix.polytechnique.fr | En les supprimant." Henri Jeanson (1900-1970)


Reply to: