svn commit: trunk/busybox: miscutils util-linux
vda at busybox.net
vda at busybox.net
Thu May 31 21:32:01 UTC 2007
Author: vda
Date: 2007-05-31 14:31:56 -0700 (Thu, 31 May 2007)
New Revision: 18715
Log:
more: stop using bss
# make && make bloatcheck
function old new delta
gotsig 86 107 +21
more_main 777 781 +4
cin_fileno 4 - -4
set_tty_to_initial_mode 25 - -25
new_settings 120 60 -60
initial_settings 120 60 -60
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/2 up/down: 25/-149) Total: -124 bytes
Modified:
trunk/busybox/miscutils/less.c
trunk/busybox/util-linux/more.c
Changeset:
Modified: trunk/busybox/miscutils/less.c
===================================================================
--- trunk/busybox/miscutils/less.c 2007-05-31 15:56:10 UTC (rev 18714)
+++ trunk/busybox/miscutils/less.c 2007-05-31 21:31:56 UTC (rev 18715)
@@ -209,6 +209,8 @@
* Has to deal with EOF and EPIPE on input,
* with line wrapping, with last line not ending in '\n'
* (possibly not ending YET!), with backspace and tabs.
+ * It reads input again if last time we got an EOF (thus supporting
+ * growing files) or EPIPE (watching output of slow process like make).
*
* Variables used:
* flines[] - array of lines already read. Linewrap may cause
Modified: trunk/busybox/util-linux/more.c
===================================================================
--- trunk/busybox/util-linux/more.c 2007-05-31 15:56:10 UTC (rev 18714)
+++ trunk/busybox/util-linux/more.c 2007-05-31 21:31:56 UTC (rev 18715)
@@ -15,26 +15,39 @@
*/
#include "libbb.h"
+#if ENABLE_FEATURE_USE_TERMIOS
+#include <termios.h>
+#endif /* FEATURE_USE_TERMIOS */
#if ENABLE_FEATURE_USE_TERMIOS
-static int cin_fileno;
-#include <termios.h>
-#define setTermSettings(fd, argp) tcsetattr(fd, TCSANOW, argp)
-#define getTermSettings(fd, argp) tcgetattr(fd, argp);
-static struct termios initial_settings, new_settings;
+struct globals {
+ int cin_fileno;
+ struct termios initial_settings;
+ struct termios new_settings;
+};
+#define G (*(struct globals*)bb_common_bufsiz1)
+//#define G (*ptr_to_globals)
+#define initial_settings (G.initial_settings)
+#define new_settings (G.new_settings )
+#define cin_fileno (G.cin_fileno )
+#define INIT_G() ((void)0)
+//#define INIT_G() PTR_TO_GLOBALS = xzalloc(sizeof(G))
-static void set_tty_to_initial_mode(void)
-{
- setTermSettings(cin_fileno, &initial_settings);
-}
+#define setTermSettings(fd, argp) tcsetattr(fd, TCSANOW, argp)
+#define getTermSettings(fd, argp) tcgetattr(fd, argp)
static void gotsig(int sig)
{
putchar('\n');
+ setTermSettings(cin_fileno, &initial_settings);
exit(EXIT_FAILURE);
}
+
+#else /* !FEATURE_USE_TERMIOS */
+#define INIT_G() ((void)0)
+#define setTermSettings(fd, argp) ((void)0)
#endif /* FEATURE_USE_TERMIOS */
@@ -50,6 +63,8 @@
int terminal_width;
int terminal_height;
+ INIT_G();
+
argv++;
/* Another popular pager, most, detects when stdout
* is not a tty and turns into cat. This makes sense. */
@@ -68,7 +83,6 @@
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
setTermSettings(cin_fileno, &new_settings);
- atexit(set_tty_to_initial_mode);
signal(SIGINT, gotsig);
signal(SIGQUIT, gotsig);
signal(SIGTERM, gotsig);
@@ -95,7 +109,6 @@
lines = 0;
page_height = terminal_height;
while ((c = getc(file)) != EOF) {
-
if ((please_display_more_prompt & 3) == 3) {
len = printf("--More-- ");
if (/*file != stdin &&*/ st.st_size > 0) {
@@ -129,8 +142,8 @@
/*
* There are two input streams to worry about here:
*
- * c : the character we are reading from the file being "mored"
- * input : a character received from the keyboard
+ * c : the character we are reading from the file being "mored"
+ * input: a character received from the keyboard
*
* If we hit a newline in the _file_ stream, we want to test and
* see if any characters have been hit in the _input_ stream. This
@@ -169,5 +182,6 @@
fflush(stdout);
} while (*argv && *++argv);
end:
+ setTermSettings(cin_fileno, &initial_settings);
return 0;
}
More information about the busybox-cvs
mailing list