[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BusyBox] [patch] Vi usage message
From:       Aaron Lehmann <aaronl () vitelus ! com>
Date:       2001-06-30 18:15:45
[Download RAW message or body]

Currently, the vi applet spits out a help message when it is passed an
invalid argument, and then immediately draws the vi screen over it.
This patch makes it exit after displaying the message. It also uses a
nifty preprocessor trick to save nearly 200 bytes of code that were
present in the old version.

In other places in the source, I tried changing printf("FOO\n") to
puts("FOO"), but even though I changed about two dozen occurences, the
size of the binary never improved! I'm wondering why. I was using gcc
3.0, which seems to ouput a smaller excecutable for busybox than
2.95.4.

["vi.diff" (text/plain)]

Index: vi.c
===================================================================
RCS file: /var/cvs/busybox/vi.c,v
retrieving revision 1.10
diff -u -r1.10 vi.c
--- vi.c	2001/06/26 02:06:08	1.10
+++ vi.c	2001/07/01 00:10:03
@@ -367,7 +367,7 @@
 			//case 'h':	// help -- just use default
 		default:
 			show_help();
-			break;
+			return 1;
 		}
 	}
 
@@ -2958,34 +2958,35 @@
 
 static void show_help(void)
 {
-	printf("These features are available:\n");
+	puts("These features are available:"
 #ifdef BB_FEATURE_VI_SEARCH
-	printf("\tPattern searches with / and ?\n");
+	"\n\tPattern searches with / and ?"
 #endif							/* BB_FEATURE_VI_SEARCH */
 #ifdef BB_FEATURE_VI_DOT_CMD
-	printf("\tLast command repeat with \'.\'\n");
+	"\n\tLast command repeat with \'.\'"
 #endif							/* BB_FEATURE_VI_DOT_CMD */
 #ifdef BB_FEATURE_VI_YANKMARK
-	printf("\tLine marking with  'x\n");
-	printf("\tNamed buffers with  \"x\n");
+	"\n\tLine marking with  'x"
+	"\n\tNamed buffers with  \"x"
 #endif							/* BB_FEATURE_VI_YANKMARK */
 #ifdef BB_FEATURE_VI_READONLY
-	printf("\tReadonly if vi is called as \"view\"\n");
-	printf("\tReadonly with -R command line arg\n");
+	"\n\tReadonly if vi is called as \"view\""
+	"\n\tReadonly with -R command line arg"
 #endif							/* BB_FEATURE_VI_READONLY */
 #ifdef BB_FEATURE_VI_SET
-	printf("\tSome colon mode commands with \':\'\n");
+	"\n\tSome colon mode commands with \':\'"
 #endif							/* BB_FEATURE_VI_SET */
 #ifdef BB_FEATURE_VI_SETOPTS
-	printf("\tSettable options with \":set\"\n");
+	"\n\tSettable options with \":set\""
 #endif							/* BB_FEATURE_VI_SETOPTS */
 #ifdef BB_FEATURE_VI_USE_SIGNALS
-	printf("\tSignal catching- ^C\n");
-	printf("\tJob suspend and resume with ^Z\n");
+	"\n\tSignal catching- ^C"
+	"\n\tJob suspend and resume with ^Z"
 #endif							/* BB_FEATURE_VI_USE_SIGNALS */
 #ifdef BB_FEATURE_VI_WIN_RESIZE
-	printf("\tAdapt to window re-sizes\n");
+	"\n\tAdapt to window re-sizes"
 #endif							/* BB_FEATURE_VI_WIN_RESIZE */
+	);
 }
 
 static void print_literal(Byte * buf, Byte * s) // copy s to buf, convert unprintable


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic