diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-04-21 01:26:49 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-04-21 01:26:49 +0000 |
commit | 1d1d95051a288b6bf64498aac9fb20047f384b7d (patch) | |
tree | 2c99ce8ba7d4d592806fbf81899e663bc884676b | |
parent | cf8d38a3eb46f4f9c4e674d43cff486cd79c9c0f (diff) | |
download | busybox-w32-1d1d95051a288b6bf64498aac9fb20047f384b7d.tar.gz busybox-w32-1d1d95051a288b6bf64498aac9fb20047f384b7d.tar.bz2 busybox-w32-1d1d95051a288b6bf64498aac9fb20047f384b7d.zip |
More Doc updates. cmdedit and more termio fixes.
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | archival/tar.c | 2 | ||||
-rw-r--r-- | basename.c | 6 | ||||
-rw-r--r-- | busybox.def.h | 5 | ||||
-rw-r--r-- | cat.c | 6 | ||||
-rw-r--r-- | chmod_chown_chgrp.c | 30 | ||||
-rw-r--r-- | chroot.c | 8 | ||||
-rw-r--r-- | chvt.c | 7 | ||||
-rw-r--r-- | cmdedit.c | 74 | ||||
-rw-r--r-- | cmdedit.h | 2 | ||||
-rw-r--r-- | console-tools/chvt.c | 7 | ||||
-rw-r--r-- | coreutils/basename.c | 6 | ||||
-rw-r--r-- | coreutils/cat.c | 6 | ||||
-rw-r--r-- | coreutils/chroot.c | 8 | ||||
-rw-r--r-- | coreutils/date.c | 14 | ||||
-rw-r--r-- | coreutils/length.c | 2 | ||||
-rw-r--r-- | cp_mv.c | 21 | ||||
-rw-r--r-- | date.c | 14 | ||||
-rw-r--r-- | init.c | 17 | ||||
-rw-r--r-- | init/init.c | 17 | ||||
-rw-r--r-- | lash.c | 1 | ||||
-rw-r--r-- | length.c | 2 | ||||
-rw-r--r-- | modutils/rmmod.c | 4 | ||||
-rw-r--r-- | more.c | 21 | ||||
-rw-r--r-- | networking/ping.c | 6 | ||||
-rw-r--r-- | ping.c | 6 | ||||
-rw-r--r-- | rmmod.c | 4 | ||||
-rw-r--r-- | sh.c | 1 | ||||
-rw-r--r-- | shell/cmdedit.c | 74 | ||||
-rw-r--r-- | shell/cmdedit.h | 2 | ||||
-rw-r--r-- | shell/lash.c | 1 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 3 | ||||
-rw-r--r-- | syslogd.c | 3 | ||||
-rw-r--r-- | tar.c | 2 | ||||
-rw-r--r-- | util-linux/more.c | 21 |
35 files changed, 278 insertions, 133 deletions
@@ -95,17 +95,19 @@ ifdef BB_INIT_SCRIPT | |||
95 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' | 95 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' |
96 | endif | 96 | endif |
97 | 97 | ||
98 | all: busybox busybox.links | 98 | all: busybox busybox.links docs |
99 | 99 | ||
100 | busybox: $(OBJECTS) | 100 | busybox: $(OBJECTS) |
101 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) | 101 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) |
102 | $(STRIP) | 102 | $(STRIP) |
103 | $(MAKE) -C docs | ||
104 | 103 | ||
104 | docs: | ||
105 | $(MAKE) -C docs | ||
106 | |||
105 | busybox.links: busybox.def.h | 107 | busybox.links: busybox.def.h |
106 | - ./busybox.mkll | sort >$@ | 108 | - ./busybox.mkll | sort >$@ |
107 | 109 | ||
108 | regexp.o nfsmount.o: %.o: %.h | 110 | regexp.o nfsmount.o cmdedit.o: %.o: %.h |
109 | $(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile | 111 | $(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile |
110 | 112 | ||
111 | test tests: | 113 | test tests: |
diff --git a/archival/tar.c b/archival/tar.c index 2284fd06d..0177d5188 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -608,7 +608,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag, | |||
608 | len1=snprintf(buf, sizeof(buf), "%ld,%-ld ", | 608 | len1=snprintf(buf, sizeof(buf), "%ld,%-ld ", |
609 | header.devmajor, header.devminor); | 609 | header.devmajor, header.devminor); |
610 | } else { | 610 | } else { |
611 | len1=snprintf(buf, sizeof(buf), "%d ", header.size); | 611 | len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size); |
612 | } | 612 | } |
613 | /* Jump through some hoops to make the columns match up */ | 613 | /* Jump through some hoops to make the columns match up */ |
614 | for(;(len+len1)<31;len++) | 614 | for(;(len+len1)<31;len++) |
diff --git a/basename.c b/basename.c index 5fe5e0f03..efd07e272 100644 --- a/basename.c +++ b/basename.c | |||
@@ -29,7 +29,11 @@ extern int basename_main(int argc, char **argv) | |||
29 | char* s, *s1; | 29 | char* s, *s1; |
30 | 30 | ||
31 | if ((argc < 2) || (**(argv + 1) == '-')) { | 31 | if ((argc < 2) || (**(argv + 1) == '-')) { |
32 | usage("basename [file ...]\n"); | 32 | usage("basename [FILE ...]\n" |
33 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
34 | "\nStrips directory path and suffixes from FILE(s).\n" | ||
35 | #endif | ||
36 | ); | ||
33 | } | 37 | } |
34 | argv++; | 38 | argv++; |
35 | 39 | ||
diff --git a/busybox.def.h b/busybox.def.h index f1c7b4f13..786b1a5d1 100644 --- a/busybox.def.h +++ b/busybox.def.h | |||
@@ -130,8 +130,9 @@ | |||
130 | // normal strings. | 130 | // normal strings. |
131 | #define BB_FEATURE_FULL_REGULAR_EXPRESSIONS | 131 | #define BB_FEATURE_FULL_REGULAR_EXPRESSIONS |
132 | // | 132 | // |
133 | // Use only simple command help | 133 | // This compiles out everything but the most |
134 | #define BB_FEATURE_TRIVIAL_HELP | 134 | // trivial --help usage information (i.e. reduces binary size) |
135 | //#define BB_FEATURE_TRIVIAL_HELP | ||
135 | // | 136 | // |
136 | // Use termios to manipulate the screen ('more' is prettier with this on) | 137 | // Use termios to manipulate the screen ('more' is prettier with this on) |
137 | #define BB_FEATURE_USE_TERMIOS | 138 | #define BB_FEATURE_USE_TERMIOS |
@@ -45,7 +45,11 @@ extern int cat_main(int argc, char **argv) | |||
45 | } | 45 | } |
46 | 46 | ||
47 | if (**(argv + 1) == '-') { | 47 | if (**(argv + 1) == '-') { |
48 | usage("cat [file ...]\n"); | 48 | usage("cat [FILE ...]\n" |
49 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
50 | "\nConcatenates FILE(s) and prints them to the standard output.\n" | ||
51 | #endif | ||
52 | ); | ||
49 | } | 53 | } |
50 | argc--; | 54 | argc--; |
51 | 55 | ||
diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c index fb93f3ff8..d5c21a220 100644 --- a/chmod_chown_chgrp.c +++ b/chmod_chown_chgrp.c | |||
@@ -43,21 +43,27 @@ static char *theMode = NULL; | |||
43 | #define CHOWN_APP 2 | 43 | #define CHOWN_APP 2 |
44 | #define CHMOD_APP 3 | 44 | #define CHMOD_APP 3 |
45 | 45 | ||
46 | static const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n\n" | 46 | static const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n" |
47 | "Change the group membership of each FILE to GROUP.\n" | 47 | #ifndef BB_FEATURE_TRIVIAL_HELP |
48 | 48 | "\nChange the group membership of each FILE to GROUP.\n" | |
49 | "\nOptions:\n\t-R\tchange files and directories recursively\n"; | 49 | "\nOptions:\n\t-R\tChanges files and directories recursively.\n" |
50 | #endif | ||
51 | ; | ||
50 | static const char chown_usage[] = | 52 | static const char chown_usage[] = |
51 | "chown [OPTION]... OWNER[<.|:>[GROUP] FILE...\n\n" | 53 | "chown [OPTION]... OWNER[<.|:>[GROUP] FILE...\n" |
52 | "Change the owner and/or group of each FILE to OWNER and/or GROUP.\n" | 54 | #ifndef BB_FEATURE_TRIVIAL_HELP |
53 | 55 | "\nChange the owner and/or group of each FILE to OWNER and/or GROUP.\n" | |
54 | "\nOptions:\n\t-R\tchange files and directories recursively\n"; | 56 | "\nOptions:\n\t-R\tChanges files and directories recursively.\n" |
57 | #endif | ||
58 | ; | ||
55 | static const char chmod_usage[] = | 59 | static const char chmod_usage[] = |
56 | "chmod [-R] MODE[,MODE]... FILE...\n\n" | 60 | "chmod [-R] MODE[,MODE]... FILE...\n" |
57 | "Each MODE is one or more of the letters ugoa, one of the symbols +-= and\n" | 61 | #ifndef BB_FEATURE_TRIVIAL_HELP |
58 | 62 | "\nEach MODE is one or more of the letters ugoa, one of the symbols +-= and\n" | |
59 | "one or more of the letters rwxst.\n\n" | 63 | "one or more of the letters rwxst.\n\n" |
60 | "\nOptions:\n\t-R\tchange files and directories recursively.\n"; | 64 | "\nOptions:\n\t-R\tChanges files and directories recursively.\n" |
65 | #endif | ||
66 | ; | ||
61 | 67 | ||
62 | 68 | ||
63 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | 69 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) |
@@ -28,9 +28,11 @@ | |||
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | 29 | ||
30 | 30 | ||
31 | static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n" | 31 | static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n" |
32 | 32 | #ifndef BB_FEATURE_TRIVIAL_HELP | |
33 | "Run COMMAND with root directory set to NEWROOT.\n"; | 33 | "\nRun COMMAND with root directory set to NEWROOT.\n" |
34 | #endif | ||
35 | ; | ||
34 | 36 | ||
35 | 37 | ||
36 | 38 | ||
@@ -19,8 +19,11 @@ int chvt_main(int argc, char **argv) | |||
19 | int fd, num; | 19 | int fd, num; |
20 | 20 | ||
21 | if ((argc != 2) || (**(argv + 1) == '-')) { | 21 | if ((argc != 2) || (**(argv + 1) == '-')) { |
22 | usage | 22 | usage ("chvt N\n" |
23 | ("chvt N\n\nChange foreground virtual terminal to /dev/ttyN\n"); | 23 | #ifndef BB_FEATURE_TRIVIAL_HELP |
24 | "\nChanges the foreground virtual terminal to /dev/ttyN\n" | ||
25 | #endif | ||
26 | ); | ||
24 | } | 27 | } |
25 | fd = get_console_fd("/dev/console"); | 28 | fd = get_console_fd("/dev/console"); |
26 | num = atoi(argv[1]); | 29 | num = atoi(argv[1]); |
@@ -39,7 +39,7 @@ | |||
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | #include <stdlib.h> | 40 | #include <stdlib.h> |
41 | #include <string.h> | 41 | #include <string.h> |
42 | #include <termio.h> | 42 | #include <sys/ioctl.h> |
43 | #include <ctype.h> | 43 | #include <ctype.h> |
44 | #include <signal.h> | 44 | #include <signal.h> |
45 | 45 | ||
@@ -53,7 +53,26 @@ | |||
53 | 53 | ||
54 | static struct history *his_front = NULL; /* First element in command line list */ | 54 | static struct history *his_front = NULL; /* First element in command line list */ |
55 | static struct history *his_end = NULL; /* Last element in command line list */ | 55 | static struct history *his_end = NULL; /* Last element in command line list */ |
56 | static struct termio old_term, new_term; /* Current termio and the previous termio before starting ash */ | 56 | |
57 | /* ED: sparc termios is broken: revert back to old termio handling. */ | ||
58 | #ifdef BB_FEATURE_USE_TERMIOS | ||
59 | |||
60 | #if #cpu(sparc) | ||
61 | # include <termio.h> | ||
62 | # define termios termio | ||
63 | # define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp) | ||
64 | # define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp) | ||
65 | #else | ||
66 | # include <termios.h> | ||
67 | # define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp) | ||
68 | # define getTermSettings(fd,argp) tcgetattr(fd, argp); | ||
69 | #endif | ||
70 | |||
71 | /* Current termio and the previous termio before starting sh */ | ||
72 | struct termios initial_settings, new_settings; | ||
73 | #endif | ||
74 | |||
75 | |||
57 | 76 | ||
58 | static int cmdedit_termw = 80; /* actual terminal width */ | 77 | static int cmdedit_termw = 80; /* actual terminal width */ |
59 | static int cmdedit_scroll = 27; /* width of EOL scrolling region */ | 78 | static int cmdedit_scroll = 27; /* width of EOL scrolling region */ |
@@ -84,14 +103,15 @@ void cmdedit_reset_term(void) | |||
84 | { | 103 | { |
85 | if (reset_term) | 104 | if (reset_term) |
86 | /* sparc and other have broken termios support: use old termio handling. */ | 105 | /* sparc and other have broken termios support: use old termio handling. */ |
87 | ioctl(fileno(stdin), TCSETA, (void *) &old_term); | 106 | setTermSettings(fileno(stdin), (void*) &initial_settings); |
88 | } | 107 | } |
89 | 108 | ||
90 | void clean_up_and_die(int sig) | 109 | void clean_up_and_die(int sig) |
91 | { | 110 | { |
92 | cmdedit_reset_term(); | 111 | cmdedit_reset_term(); |
93 | fprintf(stdout, "\n"); | 112 | fprintf(stdout, "\n"); |
94 | exit(TRUE); | 113 | if (sig!=SIGINT) |
114 | exit(TRUE); | ||
95 | } | 115 | } |
96 | 116 | ||
97 | /* Go to HOME position */ | 117 | /* Go to HOME position */ |
@@ -233,7 +253,7 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches) | |||
233 | return (matches); | 253 | return (matches); |
234 | } | 254 | } |
235 | 255 | ||
236 | void input_tab(char* command, int outputFd, int *cursor, int *len) | 256 | void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len) |
237 | { | 257 | { |
238 | /* Do TAB completion */ | 258 | /* Do TAB completion */ |
239 | static int num_matches=0; | 259 | static int num_matches=0; |
@@ -379,19 +399,17 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
379 | 399 | ||
380 | memset(command, 0, sizeof(command)); | 400 | memset(command, 0, sizeof(command)); |
381 | if (!reset_term) { | 401 | if (!reset_term) { |
382 | /* sparc and other have broken termios support: use old termio handling. */ | 402 | |
383 | ioctl(inputFd, TCGETA, (void *) &old_term); | 403 | getTermSettings(inputFd, (void*) &initial_settings); |
384 | memcpy(&new_term, &old_term, sizeof(struct termio)); | 404 | memcpy(&new_settings, &initial_settings, sizeof(struct termios)); |
385 | 405 | new_settings.c_cc[VMIN] = 1; | |
386 | new_term.c_cc[VMIN] = 1; | 406 | new_settings.c_cc[VTIME] = 0; |
387 | new_term.c_cc[VTIME] = 0; | 407 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; /* Turn off CTRL-C, so we can trap it */ |
388 | new_term.c_lflag &= ~ICANON; /* unbuffered input */ | 408 | new_settings.c_lflag &= ~ICANON; /* unbuffered input */ |
389 | new_term.c_lflag &= ~ECHO; | 409 | new_settings.c_lflag &= ~(ECHO|ECHOCTL|ECHONL); /* Turn off echoing */ |
390 | reset_term = 1; | 410 | reset_term = 1; |
391 | ioctl(inputFd, TCSETA, (void *) &new_term); | ||
392 | } else { | ||
393 | ioctl(inputFd, TCSETA, (void *) &new_term); | ||
394 | } | 411 | } |
412 | setTermSettings(inputFd, (void*) &new_settings); | ||
395 | 413 | ||
396 | memset(command, 0, BUFSIZ); | 414 | memset(command, 0, BUFSIZ); |
397 | 415 | ||
@@ -399,6 +417,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
399 | 417 | ||
400 | if ((ret = read(inputFd, &c, 1)) < 1) | 418 | if ((ret = read(inputFd, &c, 1)) < 1) |
401 | return; | 419 | return; |
420 | //fprintf(stderr, "got a '%c' (%d)\n", c, c); | ||
402 | 421 | ||
403 | switch (c) { | 422 | switch (c) { |
404 | case '\n': | 423 | case '\n': |
@@ -415,6 +434,21 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
415 | /* Control-b -- Move back one character */ | 434 | /* Control-b -- Move back one character */ |
416 | input_backward(outputFd, &cursor); | 435 | input_backward(outputFd, &cursor); |
417 | break; | 436 | break; |
437 | case 3: | ||
438 | /* Control-c -- leave the current line, | ||
439 | * and start over on the next line */ | ||
440 | |||
441 | /* Go to the next line */ | ||
442 | xwrite(outputFd, "\n", 1); | ||
443 | |||
444 | /* Rewrite the prompt */ | ||
445 | xwrite(outputFd, prompt, strlen(prompt)); | ||
446 | |||
447 | /* Reset the command string */ | ||
448 | memset(command, 0, sizeof(command)); | ||
449 | len = cursor = 0; | ||
450 | |||
451 | break; | ||
418 | case 4: | 452 | case 4: |
419 | /* Control-d -- Delete one character, or exit | 453 | /* Control-d -- Delete one character, or exit |
420 | * if the len=0 and no chars to delete */ | 454 | * if the len=0 and no chars to delete */ |
@@ -435,12 +469,12 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
435 | break; | 469 | break; |
436 | case '\b': | 470 | case '\b': |
437 | case DEL: | 471 | case DEL: |
438 | /* control-h and DEL */ | 472 | /* Control-h and DEL */ |
439 | input_backspace(command, outputFd, &cursor, &len); | 473 | input_backspace(command, outputFd, &cursor, &len); |
440 | break; | 474 | break; |
441 | case '\t': | 475 | case '\t': |
442 | #ifdef BB_FEATURE_SH_TAB_COMPLETION | 476 | #ifdef BB_FEATURE_SH_TAB_COMPLETION |
443 | input_tab(command, outputFd, &cursor, &len); | 477 | input_tab(command, prompt, outputFd, &cursor, &len); |
444 | #endif | 478 | #endif |
445 | break; | 479 | break; |
446 | case 14: | 480 | case 14: |
@@ -591,8 +625,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
591 | } | 625 | } |
592 | 626 | ||
593 | nr = len + 1; | 627 | nr = len + 1; |
594 | /* sparc and other have broken termios support: use old termio handling. */ | 628 | setTermSettings(inputFd, (void *) &initial_settings); |
595 | ioctl(inputFd, TCSETA, (void *) &old_term); | ||
596 | reset_term = 0; | 629 | reset_term = 0; |
597 | 630 | ||
598 | 631 | ||
@@ -644,6 +677,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
644 | extern void cmdedit_init(void) | 677 | extern void cmdedit_init(void) |
645 | { | 678 | { |
646 | atexit(cmdedit_reset_term); | 679 | atexit(cmdedit_reset_term); |
680 | signal(SIGKILL, clean_up_and_die); | ||
647 | signal(SIGINT, clean_up_and_die); | 681 | signal(SIGINT, clean_up_and_die); |
648 | signal(SIGQUIT, clean_up_and_die); | 682 | signal(SIGQUIT, clean_up_and_die); |
649 | signal(SIGTERM, clean_up_and_die); | 683 | signal(SIGTERM, clean_up_and_die); |
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | typedef size_t (*cmdedit_strwidth_proc)(char *); | 11 | typedef size_t (*cmdedit_strwidth_proc)(char *); |
12 | 12 | ||
13 | void cmdedit_init(void); | ||
13 | void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */ | 14 | void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */ |
14 | void cmdedit_setwidth(int); /* specify width of screen */ | 15 | void cmdedit_setwidth(int); /* specify width of screen */ |
15 | void cmdedit_histadd(char *); /* adds entries to hist */ | 16 | void cmdedit_histadd(char *); /* adds entries to hist */ |
@@ -21,6 +22,7 @@ extern int (*cmdedit_tab_hook)(char *, int, int *); | |||
21 | 22 | ||
22 | #else /* not __STDC__ */ | 23 | #else /* not __STDC__ */ |
23 | 24 | ||
25 | void cmdedit_init(void); | ||
24 | void cmdedit_read_input(char* promptStr, char* command); | 26 | void cmdedit_read_input(char* promptStr, char* command); |
25 | void cmdedit_setwidth(); | 27 | void cmdedit_setwidth(); |
26 | void cmdedit_histadd(); | 28 | void cmdedit_histadd(); |
diff --git a/console-tools/chvt.c b/console-tools/chvt.c index 635022a57..bf1ed609b 100644 --- a/console-tools/chvt.c +++ b/console-tools/chvt.c | |||
@@ -19,8 +19,11 @@ int chvt_main(int argc, char **argv) | |||
19 | int fd, num; | 19 | int fd, num; |
20 | 20 | ||
21 | if ((argc != 2) || (**(argv + 1) == '-')) { | 21 | if ((argc != 2) || (**(argv + 1) == '-')) { |
22 | usage | 22 | usage ("chvt N\n" |
23 | ("chvt N\n\nChange foreground virtual terminal to /dev/ttyN\n"); | 23 | #ifndef BB_FEATURE_TRIVIAL_HELP |
24 | "\nChanges the foreground virtual terminal to /dev/ttyN\n" | ||
25 | #endif | ||
26 | ); | ||
24 | } | 27 | } |
25 | fd = get_console_fd("/dev/console"); | 28 | fd = get_console_fd("/dev/console"); |
26 | num = atoi(argv[1]); | 29 | num = atoi(argv[1]); |
diff --git a/coreutils/basename.c b/coreutils/basename.c index 5fe5e0f03..efd07e272 100644 --- a/coreutils/basename.c +++ b/coreutils/basename.c | |||
@@ -29,7 +29,11 @@ extern int basename_main(int argc, char **argv) | |||
29 | char* s, *s1; | 29 | char* s, *s1; |
30 | 30 | ||
31 | if ((argc < 2) || (**(argv + 1) == '-')) { | 31 | if ((argc < 2) || (**(argv + 1) == '-')) { |
32 | usage("basename [file ...]\n"); | 32 | usage("basename [FILE ...]\n" |
33 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
34 | "\nStrips directory path and suffixes from FILE(s).\n" | ||
35 | #endif | ||
36 | ); | ||
33 | } | 37 | } |
34 | argv++; | 38 | argv++; |
35 | 39 | ||
diff --git a/coreutils/cat.c b/coreutils/cat.c index f7a6bfa7b..561b24f3f 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c | |||
@@ -45,7 +45,11 @@ extern int cat_main(int argc, char **argv) | |||
45 | } | 45 | } |
46 | 46 | ||
47 | if (**(argv + 1) == '-') { | 47 | if (**(argv + 1) == '-') { |
48 | usage("cat [file ...]\n"); | 48 | usage("cat [FILE ...]\n" |
49 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
50 | "\nConcatenates FILE(s) and prints them to the standard output.\n" | ||
51 | #endif | ||
52 | ); | ||
49 | } | 53 | } |
50 | argc--; | 54 | argc--; |
51 | 55 | ||
diff --git a/coreutils/chroot.c b/coreutils/chroot.c index 63fa4d146..34116a60e 100644 --- a/coreutils/chroot.c +++ b/coreutils/chroot.c | |||
@@ -28,9 +28,11 @@ | |||
28 | #include <errno.h> | 28 | #include <errno.h> |
29 | 29 | ||
30 | 30 | ||
31 | static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n" | 31 | static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n" |
32 | 32 | #ifndef BB_FEATURE_TRIVIAL_HELP | |
33 | "Run COMMAND with root directory set to NEWROOT.\n"; | 33 | "\nRun COMMAND with root directory set to NEWROOT.\n" |
34 | #endif | ||
35 | ; | ||
34 | 36 | ||
35 | 37 | ||
36 | 38 | ||
diff --git a/coreutils/date.c b/coreutils/date.c index 25ce05d2d..dd054be66 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
@@ -40,12 +40,14 @@ | |||
40 | mail commands */ | 40 | mail commands */ |
41 | 41 | ||
42 | static const char date_usage[] = "date [OPTION]... [+FORMAT]\n" | 42 | static const char date_usage[] = "date [OPTION]... [+FORMAT]\n" |
43 | " or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n\n" | 43 | " or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n" |
44 | "Display the current time in the given FORMAT, or set the system date.\n" | 44 | #ifndef BB_FEATURE_TRIVIAL_HELP |
45 | "\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n" | 45 | "\nDisplays the current time in the given FORMAT, or sets the system date.\n" |
46 | "\t-s\t\tset time described by STRING\n" | 46 | "\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n" |
47 | 47 | "\t-s\tSets time described by STRING\n" | |
48 | "\t-u\t\tprint or set Coordinated Universal Time\n"; | 48 | "\t-u\tPrints or sets Coordinated Universal Time\n" |
49 | #endif | ||
50 | ; | ||
49 | 51 | ||
50 | 52 | ||
51 | /* Input parsing code is always bulky - used heavy duty libc stuff as | 53 | /* Input parsing code is always bulky - used heavy duty libc stuff as |
diff --git a/coreutils/length.c b/coreutils/length.c index 00e5a171b..4cbe7e17b 100644 --- a/coreutils/length.c +++ b/coreutils/length.c | |||
@@ -9,6 +9,6 @@ extern int length_main(int argc, char **argv) | |||
9 | if (argc != 2 || **(argv + 1) == '-') { | 9 | if (argc != 2 || **(argv + 1) == '-') { |
10 | usage("length string\n"); | 10 | usage("length string\n"); |
11 | } | 11 | } |
12 | printf("%d\n", strlen(argv[1])); | 12 | printf("%lu\n", (long)strlen(argv[1])); |
13 | return (TRUE); | 13 | return (TRUE); |
14 | } | 14 | } |
@@ -49,16 +49,21 @@ static const char *dz; /* dollar zero, .bss */ | |||
49 | static const char *cp_mv_usage[] = /* .rodata */ | 49 | static const char *cp_mv_usage[] = /* .rodata */ |
50 | { | 50 | { |
51 | "cp [OPTION]... SOURCE DEST\n" | 51 | "cp [OPTION]... SOURCE DEST\n" |
52 | " or: cp [OPTION]... SOURCE... DIRECTORY\n\n" | 52 | " or: cp [OPTION]... SOURCE... DIRECTORY\n" |
53 | "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n" | 53 | #ifndef BB_FEATURE_TRIVIAL_HELP |
54 | "\nCopies SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n" | ||
54 | "\n" | 55 | "\n" |
55 | "\t-a\tsame as -dpR\n" | 56 | "\t-a\tSame as -dpR\n" |
56 | "\t-d\tpreserve links\n" | 57 | "\t-d\tPreserves links\n" |
57 | "\t-p\tpreserve file attributes if possible\n" | 58 | "\t-p\tPreserves file attributes if possible\n" |
58 | "\t-R\tcopy directories recursively\n", | 59 | "\t-R\tCopies directories recursively\n" |
60 | #endif | ||
61 | , | ||
59 | "mv SOURCE DEST\n" | 62 | "mv SOURCE DEST\n" |
60 | " or: mv SOURCE... DIRECTORY\n\n" | 63 | " or: mv SOURCE... DIRECTORY\n" |
61 | "Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n" | 64 | #ifndef BB_FEATURE_TRIVIAL_HELP |
65 | "\nRename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n" | ||
66 | #endif | ||
62 | }; | 67 | }; |
63 | 68 | ||
64 | static int recursiveFlag; | 69 | static int recursiveFlag; |
@@ -40,12 +40,14 @@ | |||
40 | mail commands */ | 40 | mail commands */ |
41 | 41 | ||
42 | static const char date_usage[] = "date [OPTION]... [+FORMAT]\n" | 42 | static const char date_usage[] = "date [OPTION]... [+FORMAT]\n" |
43 | " or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n\n" | 43 | " or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n" |
44 | "Display the current time in the given FORMAT, or set the system date.\n" | 44 | #ifndef BB_FEATURE_TRIVIAL_HELP |
45 | "\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n" | 45 | "\nDisplays the current time in the given FORMAT, or sets the system date.\n" |
46 | "\t-s\t\tset time described by STRING\n" | 46 | "\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n" |
47 | 47 | "\t-s\tSets time described by STRING\n" | |
48 | "\t-u\t\tprint or set Coordinated Universal Time\n"; | 48 | "\t-u\tPrints or sets Coordinated Universal Time\n" |
49 | #endif | ||
50 | ; | ||
49 | 51 | ||
50 | 52 | ||
51 | /* Input parsing code is always bulky - used heavy duty libc stuff as | 53 | /* Input parsing code is always bulky - used heavy duty libc stuff as |
@@ -201,6 +201,7 @@ static void message(int device, char *fmt, ...) | |||
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | #define CTRLCHAR(ch) ((ch)&0x1f) | ||
204 | 205 | ||
205 | /* Set terminal settings to reasonable defaults */ | 206 | /* Set terminal settings to reasonable defaults */ |
206 | void set_term(int fd) | 207 | void set_term(int fd) |
@@ -210,14 +211,14 @@ void set_term(int fd) | |||
210 | tcgetattr(fd, &tty); | 211 | tcgetattr(fd, &tty); |
211 | 212 | ||
212 | /* set control chars */ | 213 | /* set control chars */ |
213 | tty.c_cc[VINTR] = 3; /* C-c */ | 214 | tty.c_cc[VINTR] = CTRLCHAR('C'); /* Ctrl-C */ |
214 | tty.c_cc[VQUIT] = 28; /* C-\ */ | 215 | tty.c_cc[VQUIT] = CTRLCHAR('\\'); /* Ctrl-\ */ |
215 | tty.c_cc[VERASE] = 127; /* C-? */ | 216 | tty.c_cc[VERASE] = CTRLCHAR('?'); /* Ctrl-? */ |
216 | tty.c_cc[VKILL] = 21; /* C-u */ | 217 | tty.c_cc[VKILL] = CTRLCHAR('U'); /* Ctrl-U */ |
217 | tty.c_cc[VEOF] = 4; /* C-d */ | 218 | tty.c_cc[VEOF] = CTRLCHAR('D'); /* Ctrl-D */ |
218 | tty.c_cc[VSTART] = 17; /* C-q */ | 219 | tty.c_cc[VSTOP] = CTRLCHAR('S'); /* Ctrl-S */ |
219 | tty.c_cc[VSTOP] = 19; /* C-s */ | 220 | tty.c_cc[VSTART] = CTRLCHAR('Q'); /* Ctrl-Q */ |
220 | tty.c_cc[VSUSP] = 26; /* C-z */ | 221 | tty.c_cc[VSUSP] = CTRLCHAR('Z'); /* Ctrl-Z */ |
221 | 222 | ||
222 | /* use line dicipline 0 */ | 223 | /* use line dicipline 0 */ |
223 | tty.c_line = 0; | 224 | tty.c_line = 0; |
diff --git a/init/init.c b/init/init.c index e8a5f74d3..af10f98f0 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -201,6 +201,7 @@ static void message(int device, char *fmt, ...) | |||
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | #define CTRLCHAR(ch) ((ch)&0x1f) | ||
204 | 205 | ||
205 | /* Set terminal settings to reasonable defaults */ | 206 | /* Set terminal settings to reasonable defaults */ |
206 | void set_term(int fd) | 207 | void set_term(int fd) |
@@ -210,14 +211,14 @@ void set_term(int fd) | |||
210 | tcgetattr(fd, &tty); | 211 | tcgetattr(fd, &tty); |
211 | 212 | ||
212 | /* set control chars */ | 213 | /* set control chars */ |
213 | tty.c_cc[VINTR] = 3; /* C-c */ | 214 | tty.c_cc[VINTR] = CTRLCHAR('C'); /* Ctrl-C */ |
214 | tty.c_cc[VQUIT] = 28; /* C-\ */ | 215 | tty.c_cc[VQUIT] = CTRLCHAR('\\'); /* Ctrl-\ */ |
215 | tty.c_cc[VERASE] = 127; /* C-? */ | 216 | tty.c_cc[VERASE] = CTRLCHAR('?'); /* Ctrl-? */ |
216 | tty.c_cc[VKILL] = 21; /* C-u */ | 217 | tty.c_cc[VKILL] = CTRLCHAR('U'); /* Ctrl-U */ |
217 | tty.c_cc[VEOF] = 4; /* C-d */ | 218 | tty.c_cc[VEOF] = CTRLCHAR('D'); /* Ctrl-D */ |
218 | tty.c_cc[VSTART] = 17; /* C-q */ | 219 | tty.c_cc[VSTOP] = CTRLCHAR('S'); /* Ctrl-S */ |
219 | tty.c_cc[VSTOP] = 19; /* C-s */ | 220 | tty.c_cc[VSTART] = CTRLCHAR('Q'); /* Ctrl-Q */ |
220 | tty.c_cc[VSUSP] = 26; /* C-z */ | 221 | tty.c_cc[VSUSP] = CTRLCHAR('Z'); /* Ctrl-Z */ |
221 | 222 | ||
222 | /* use line dicipline 0 */ | 223 | /* use line dicipline 0 */ |
223 | tty.c_line = 0; | 224 | tty.c_line = 0; |
@@ -947,6 +947,7 @@ int shell_main(int argc, char **argv) | |||
947 | getcwd(cwd, sizeof(cwd)); | 947 | getcwd(cwd, sizeof(cwd)); |
948 | 948 | ||
949 | #ifdef BB_FEATURE_SH_COMMAND_EDITING | 949 | #ifdef BB_FEATURE_SH_COMMAND_EDITING |
950 | cmdedit_init(); | ||
950 | signal(SIGWINCH, win_changed); | 951 | signal(SIGWINCH, win_changed); |
951 | win_changed(0); | 952 | win_changed(0); |
952 | #endif | 953 | #endif |
@@ -9,6 +9,6 @@ extern int length_main(int argc, char **argv) | |||
9 | if (argc != 2 || **(argv + 1) == '-') { | 9 | if (argc != 2 || **(argv + 1) == '-') { |
10 | usage("length string\n"); | 10 | usage("length string\n"); |
11 | } | 11 | } |
12 | printf("%d\n", strlen(argv[1])); | 12 | printf("%lu\n", (long)strlen(argv[1])); |
13 | return (TRUE); | 13 | return (TRUE); |
14 | } | 14 | } |
diff --git a/modutils/rmmod.c b/modutils/rmmod.c index d01725329..bc5c03e62 100644 --- a/modutils/rmmod.c +++ b/modutils/rmmod.c | |||
@@ -25,7 +25,9 @@ | |||
25 | #include <stdio.h> | 25 | #include <stdio.h> |
26 | #include <errno.h> | 26 | #include <errno.h> |
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <sys/syscall.h> | 28 | #define __LIBRARY__ |
29 | #include <asm/unistd.h> | ||
30 | /* #include <sys/syscall.h> */ | ||
29 | 31 | ||
30 | 32 | ||
31 | 33 | ||
@@ -33,17 +33,26 @@ | |||
33 | 33 | ||
34 | static const char more_usage[] = "more [file ...]\n"; | 34 | static const char more_usage[] = "more [file ...]\n"; |
35 | 35 | ||
36 | /* ED: sparc termios is broken: revert back to old termio handling. */ | ||
36 | #ifdef BB_FEATURE_USE_TERMIOS | 37 | #ifdef BB_FEATURE_USE_TERMIOS |
37 | 38 | ||
38 | #include <termio.h> | 39 | #if #cpu(sparc) |
40 | # include <termio.h> | ||
41 | # define termios termio | ||
42 | # define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp) | ||
43 | # define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp) | ||
44 | #else | ||
45 | # include <termios.h> | ||
46 | # define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp) | ||
47 | # define getTermSettings(fd,argp) tcgetattr(fd, argp); | ||
48 | #endif | ||
39 | 49 | ||
40 | FILE *cin; | 50 | FILE *cin; |
41 | /* sparc and other have broken termios support: use old termio handling. */ | 51 | struct termios initial_settings, new_settings; |
42 | struct termio initial_settings, new_settings; | ||
43 | 52 | ||
44 | void gotsig(int sig) | 53 | void gotsig(int sig) |
45 | { | 54 | { |
46 | ioctl(fileno(cin), TCSETAF, &initial_settings); | 55 | setTermSettings(fileno(cin), &initial_settings); |
47 | fprintf(stdout, "\n"); | 56 | fprintf(stdout, "\n"); |
48 | exit(TRUE); | 57 | exit(TRUE); |
49 | } | 58 | } |
@@ -98,11 +107,11 @@ extern int more_main(int argc, char **argv) | |||
98 | cin = fopen("/dev/tty", "r"); | 107 | cin = fopen("/dev/tty", "r"); |
99 | if (!cin) | 108 | if (!cin) |
100 | cin = fopen("/dev/console", "r"); | 109 | cin = fopen("/dev/console", "r"); |
101 | ioctl(fileno(cin), TCGETA, &initial_settings); | 110 | getTermSettings(fileno(cin), &initial_settings); |
102 | new_settings = initial_settings; | 111 | new_settings = initial_settings; |
103 | new_settings.c_lflag &= ~ICANON; | 112 | new_settings.c_lflag &= ~ICANON; |
104 | new_settings.c_lflag &= ~ECHO; | 113 | new_settings.c_lflag &= ~ECHO; |
105 | ioctl(fileno(cin), TCSETAF, &new_settings); | 114 | setTermSettings(fileno(cin), &new_settings); |
106 | 115 | ||
107 | #ifdef BB_FEATURE_AUTOWIDTH | 116 | #ifdef BB_FEATURE_AUTOWIDTH |
108 | ioctl(fileno(stdout), TIOCGWINSZ, &win); | 117 | ioctl(fileno(stdout), TIOCGWINSZ, &win); |
diff --git a/networking/ping.c b/networking/ping.c index ef6503aeb..dca4c3cfe 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * $Id: ping.c,v 1.12 2000/04/13 18:49:43 erik Exp $ | 3 | * $Id: ping.c,v 1.13 2000/04/21 01:26:49 erik Exp $ |
4 | * Mini ping implementation for busybox | 4 | * Mini ping implementation for busybox |
5 | * | 5 | * |
6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
@@ -248,7 +248,7 @@ static void sendping(int ign) | |||
248 | if (i < 0) | 248 | if (i < 0) |
249 | perror("ping"); | 249 | perror("ping"); |
250 | fprintf(stderr, "ping wrote %d chars; %d expected\n", i, | 250 | fprintf(stderr, "ping wrote %d chars; %d expected\n", i, |
251 | sizeof(packet)); | 251 | (int)sizeof(packet)); |
252 | exit(1); | 252 | exit(1); |
253 | } | 253 | } |
254 | 254 | ||
@@ -393,7 +393,7 @@ static void ping(char *host) | |||
393 | /* listen for replies */ | 393 | /* listen for replies */ |
394 | while (1) { | 394 | while (1) { |
395 | struct sockaddr_in from; | 395 | struct sockaddr_in from; |
396 | size_t fromlen = sizeof(from); | 396 | socklen_t fromlen = (socklen_t) sizeof(from); |
397 | int c; | 397 | int c; |
398 | 398 | ||
399 | if ((c = recvfrom(pingsock, packet, sizeof(packet), 0, | 399 | if ((c = recvfrom(pingsock, packet, sizeof(packet), 0, |
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * $Id: ping.c,v 1.12 2000/04/13 18:49:43 erik Exp $ | 3 | * $Id: ping.c,v 1.13 2000/04/21 01:26:49 erik Exp $ |
4 | * Mini ping implementation for busybox | 4 | * Mini ping implementation for busybox |
5 | * | 5 | * |
6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
@@ -248,7 +248,7 @@ static void sendping(int ign) | |||
248 | if (i < 0) | 248 | if (i < 0) |
249 | perror("ping"); | 249 | perror("ping"); |
250 | fprintf(stderr, "ping wrote %d chars; %d expected\n", i, | 250 | fprintf(stderr, "ping wrote %d chars; %d expected\n", i, |
251 | sizeof(packet)); | 251 | (int)sizeof(packet)); |
252 | exit(1); | 252 | exit(1); |
253 | } | 253 | } |
254 | 254 | ||
@@ -393,7 +393,7 @@ static void ping(char *host) | |||
393 | /* listen for replies */ | 393 | /* listen for replies */ |
394 | while (1) { | 394 | while (1) { |
395 | struct sockaddr_in from; | 395 | struct sockaddr_in from; |
396 | size_t fromlen = sizeof(from); | 396 | socklen_t fromlen = (socklen_t) sizeof(from); |
397 | int c; | 397 | int c; |
398 | 398 | ||
399 | if ((c = recvfrom(pingsock, packet, sizeof(packet), 0, | 399 | if ((c = recvfrom(pingsock, packet, sizeof(packet), 0, |
@@ -25,7 +25,9 @@ | |||
25 | #include <stdio.h> | 25 | #include <stdio.h> |
26 | #include <errno.h> | 26 | #include <errno.h> |
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <sys/syscall.h> | 28 | #define __LIBRARY__ |
29 | #include <asm/unistd.h> | ||
30 | /* #include <sys/syscall.h> */ | ||
29 | 31 | ||
30 | 32 | ||
31 | 33 | ||
@@ -947,6 +947,7 @@ int shell_main(int argc, char **argv) | |||
947 | getcwd(cwd, sizeof(cwd)); | 947 | getcwd(cwd, sizeof(cwd)); |
948 | 948 | ||
949 | #ifdef BB_FEATURE_SH_COMMAND_EDITING | 949 | #ifdef BB_FEATURE_SH_COMMAND_EDITING |
950 | cmdedit_init(); | ||
950 | signal(SIGWINCH, win_changed); | 951 | signal(SIGWINCH, win_changed); |
951 | win_changed(0); | 952 | win_changed(0); |
952 | #endif | 953 | #endif |
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index ebc6b9696..e4c88c265 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | #include <stdlib.h> | 40 | #include <stdlib.h> |
41 | #include <string.h> | 41 | #include <string.h> |
42 | #include <termio.h> | 42 | #include <sys/ioctl.h> |
43 | #include <ctype.h> | 43 | #include <ctype.h> |
44 | #include <signal.h> | 44 | #include <signal.h> |
45 | 45 | ||
@@ -53,7 +53,26 @@ | |||
53 | 53 | ||
54 | static struct history *his_front = NULL; /* First element in command line list */ | 54 | static struct history *his_front = NULL; /* First element in command line list */ |
55 | static struct history *his_end = NULL; /* Last element in command line list */ | 55 | static struct history *his_end = NULL; /* Last element in command line list */ |
56 | static struct termio old_term, new_term; /* Current termio and the previous termio before starting ash */ | 56 | |
57 | /* ED: sparc termios is broken: revert back to old termio handling. */ | ||
58 | #ifdef BB_FEATURE_USE_TERMIOS | ||
59 | |||
60 | #if #cpu(sparc) | ||
61 | # include <termio.h> | ||
62 | # define termios termio | ||
63 | # define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp) | ||
64 | # define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp) | ||
65 | #else | ||
66 | # include <termios.h> | ||
67 | # define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp) | ||
68 | # define getTermSettings(fd,argp) tcgetattr(fd, argp); | ||
69 | #endif | ||
70 | |||
71 | /* Current termio and the previous termio before starting sh */ | ||
72 | struct termios initial_settings, new_settings; | ||
73 | #endif | ||
74 | |||
75 | |||
57 | 76 | ||
58 | static int cmdedit_termw = 80; /* actual terminal width */ | 77 | static int cmdedit_termw = 80; /* actual terminal width */ |
59 | static int cmdedit_scroll = 27; /* width of EOL scrolling region */ | 78 | static int cmdedit_scroll = 27; /* width of EOL scrolling region */ |
@@ -84,14 +103,15 @@ void cmdedit_reset_term(void) | |||
84 | { | 103 | { |
85 | if (reset_term) | 104 | if (reset_term) |
86 | /* sparc and other have broken termios support: use old termio handling. */ | 105 | /* sparc and other have broken termios support: use old termio handling. */ |
87 | ioctl(fileno(stdin), TCSETA, (void *) &old_term); | 106 | setTermSettings(fileno(stdin), (void*) &initial_settings); |
88 | } | 107 | } |
89 | 108 | ||
90 | void clean_up_and_die(int sig) | 109 | void clean_up_and_die(int sig) |
91 | { | 110 | { |
92 | cmdedit_reset_term(); | 111 | cmdedit_reset_term(); |
93 | fprintf(stdout, "\n"); | 112 | fprintf(stdout, "\n"); |
94 | exit(TRUE); | 113 | if (sig!=SIGINT) |
114 | exit(TRUE); | ||
95 | } | 115 | } |
96 | 116 | ||
97 | /* Go to HOME position */ | 117 | /* Go to HOME position */ |
@@ -233,7 +253,7 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches) | |||
233 | return (matches); | 253 | return (matches); |
234 | } | 254 | } |
235 | 255 | ||
236 | void input_tab(char* command, int outputFd, int *cursor, int *len) | 256 | void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len) |
237 | { | 257 | { |
238 | /* Do TAB completion */ | 258 | /* Do TAB completion */ |
239 | static int num_matches=0; | 259 | static int num_matches=0; |
@@ -379,19 +399,17 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
379 | 399 | ||
380 | memset(command, 0, sizeof(command)); | 400 | memset(command, 0, sizeof(command)); |
381 | if (!reset_term) { | 401 | if (!reset_term) { |
382 | /* sparc and other have broken termios support: use old termio handling. */ | 402 | |
383 | ioctl(inputFd, TCGETA, (void *) &old_term); | 403 | getTermSettings(inputFd, (void*) &initial_settings); |
384 | memcpy(&new_term, &old_term, sizeof(struct termio)); | 404 | memcpy(&new_settings, &initial_settings, sizeof(struct termios)); |
385 | 405 | new_settings.c_cc[VMIN] = 1; | |
386 | new_term.c_cc[VMIN] = 1; | 406 | new_settings.c_cc[VTIME] = 0; |
387 | new_term.c_cc[VTIME] = 0; | 407 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; /* Turn off CTRL-C, so we can trap it */ |
388 | new_term.c_lflag &= ~ICANON; /* unbuffered input */ | 408 | new_settings.c_lflag &= ~ICANON; /* unbuffered input */ |
389 | new_term.c_lflag &= ~ECHO; | 409 | new_settings.c_lflag &= ~(ECHO|ECHOCTL|ECHONL); /* Turn off echoing */ |
390 | reset_term = 1; | 410 | reset_term = 1; |
391 | ioctl(inputFd, TCSETA, (void *) &new_term); | ||
392 | } else { | ||
393 | ioctl(inputFd, TCSETA, (void *) &new_term); | ||
394 | } | 411 | } |
412 | setTermSettings(inputFd, (void*) &new_settings); | ||
395 | 413 | ||
396 | memset(command, 0, BUFSIZ); | 414 | memset(command, 0, BUFSIZ); |
397 | 415 | ||
@@ -399,6 +417,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
399 | 417 | ||
400 | if ((ret = read(inputFd, &c, 1)) < 1) | 418 | if ((ret = read(inputFd, &c, 1)) < 1) |
401 | return; | 419 | return; |
420 | //fprintf(stderr, "got a '%c' (%d)\n", c, c); | ||
402 | 421 | ||
403 | switch (c) { | 422 | switch (c) { |
404 | case '\n': | 423 | case '\n': |
@@ -415,6 +434,21 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
415 | /* Control-b -- Move back one character */ | 434 | /* Control-b -- Move back one character */ |
416 | input_backward(outputFd, &cursor); | 435 | input_backward(outputFd, &cursor); |
417 | break; | 436 | break; |
437 | case 3: | ||
438 | /* Control-c -- leave the current line, | ||
439 | * and start over on the next line */ | ||
440 | |||
441 | /* Go to the next line */ | ||
442 | xwrite(outputFd, "\n", 1); | ||
443 | |||
444 | /* Rewrite the prompt */ | ||
445 | xwrite(outputFd, prompt, strlen(prompt)); | ||
446 | |||
447 | /* Reset the command string */ | ||
448 | memset(command, 0, sizeof(command)); | ||
449 | len = cursor = 0; | ||
450 | |||
451 | break; | ||
418 | case 4: | 452 | case 4: |
419 | /* Control-d -- Delete one character, or exit | 453 | /* Control-d -- Delete one character, or exit |
420 | * if the len=0 and no chars to delete */ | 454 | * if the len=0 and no chars to delete */ |
@@ -435,12 +469,12 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
435 | break; | 469 | break; |
436 | case '\b': | 470 | case '\b': |
437 | case DEL: | 471 | case DEL: |
438 | /* control-h and DEL */ | 472 | /* Control-h and DEL */ |
439 | input_backspace(command, outputFd, &cursor, &len); | 473 | input_backspace(command, outputFd, &cursor, &len); |
440 | break; | 474 | break; |
441 | case '\t': | 475 | case '\t': |
442 | #ifdef BB_FEATURE_SH_TAB_COMPLETION | 476 | #ifdef BB_FEATURE_SH_TAB_COMPLETION |
443 | input_tab(command, outputFd, &cursor, &len); | 477 | input_tab(command, prompt, outputFd, &cursor, &len); |
444 | #endif | 478 | #endif |
445 | break; | 479 | break; |
446 | case 14: | 480 | case 14: |
@@ -591,8 +625,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
591 | } | 625 | } |
592 | 626 | ||
593 | nr = len + 1; | 627 | nr = len + 1; |
594 | /* sparc and other have broken termios support: use old termio handling. */ | 628 | setTermSettings(inputFd, (void *) &initial_settings); |
595 | ioctl(inputFd, TCSETA, (void *) &old_term); | ||
596 | reset_term = 0; | 629 | reset_term = 0; |
597 | 630 | ||
598 | 631 | ||
@@ -644,6 +677,7 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ]) | |||
644 | extern void cmdedit_init(void) | 677 | extern void cmdedit_init(void) |
645 | { | 678 | { |
646 | atexit(cmdedit_reset_term); | 679 | atexit(cmdedit_reset_term); |
680 | signal(SIGKILL, clean_up_and_die); | ||
647 | signal(SIGINT, clean_up_and_die); | 681 | signal(SIGINT, clean_up_and_die); |
648 | signal(SIGQUIT, clean_up_and_die); | 682 | signal(SIGQUIT, clean_up_and_die); |
649 | signal(SIGTERM, clean_up_and_die); | 683 | signal(SIGTERM, clean_up_and_die); |
diff --git a/shell/cmdedit.h b/shell/cmdedit.h index 0e465e50e..9ac7daca3 100644 --- a/shell/cmdedit.h +++ b/shell/cmdedit.h | |||
@@ -10,6 +10,7 @@ | |||
10 | 10 | ||
11 | typedef size_t (*cmdedit_strwidth_proc)(char *); | 11 | typedef size_t (*cmdedit_strwidth_proc)(char *); |
12 | 12 | ||
13 | void cmdedit_init(void); | ||
13 | void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */ | 14 | void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */ |
14 | void cmdedit_setwidth(int); /* specify width of screen */ | 15 | void cmdedit_setwidth(int); /* specify width of screen */ |
15 | void cmdedit_histadd(char *); /* adds entries to hist */ | 16 | void cmdedit_histadd(char *); /* adds entries to hist */ |
@@ -21,6 +22,7 @@ extern int (*cmdedit_tab_hook)(char *, int, int *); | |||
21 | 22 | ||
22 | #else /* not __STDC__ */ | 23 | #else /* not __STDC__ */ |
23 | 24 | ||
25 | void cmdedit_init(void); | ||
24 | void cmdedit_read_input(char* promptStr, char* command); | 26 | void cmdedit_read_input(char* promptStr, char* command); |
25 | void cmdedit_setwidth(); | 27 | void cmdedit_setwidth(); |
26 | void cmdedit_histadd(); | 28 | void cmdedit_histadd(); |
diff --git a/shell/lash.c b/shell/lash.c index 97db8afaf..b96b46456 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -947,6 +947,7 @@ int shell_main(int argc, char **argv) | |||
947 | getcwd(cwd, sizeof(cwd)); | 947 | getcwd(cwd, sizeof(cwd)); |
948 | 948 | ||
949 | #ifdef BB_FEATURE_SH_COMMAND_EDITING | 949 | #ifdef BB_FEATURE_SH_COMMAND_EDITING |
950 | cmdedit_init(); | ||
950 | signal(SIGWINCH, win_changed); | 951 | signal(SIGWINCH, win_changed); |
951 | win_changed(0); | 952 | win_changed(0); |
952 | #endif | 953 | #endif |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 4ebd2a28a..0d400e535 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -171,7 +171,8 @@ static void doSyslogd (void) __attribute__ ((noreturn)); | |||
171 | static void doSyslogd (void) | 171 | static void doSyslogd (void) |
172 | { | 172 | { |
173 | struct sockaddr_un sunx; | 173 | struct sockaddr_un sunx; |
174 | size_t addrLength; | 174 | socklen_t addrLength; |
175 | |||
175 | 176 | ||
176 | int sock_fd; | 177 | int sock_fd; |
177 | fd_set fds; | 178 | fd_set fds; |
@@ -171,7 +171,8 @@ static void doSyslogd (void) __attribute__ ((noreturn)); | |||
171 | static void doSyslogd (void) | 171 | static void doSyslogd (void) |
172 | { | 172 | { |
173 | struct sockaddr_un sunx; | 173 | struct sockaddr_un sunx; |
174 | size_t addrLength; | 174 | socklen_t addrLength; |
175 | |||
175 | 176 | ||
176 | int sock_fd; | 177 | int sock_fd; |
177 | fd_set fds; | 178 | fd_set fds; |
@@ -608,7 +608,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag, | |||
608 | len1=snprintf(buf, sizeof(buf), "%ld,%-ld ", | 608 | len1=snprintf(buf, sizeof(buf), "%ld,%-ld ", |
609 | header.devmajor, header.devminor); | 609 | header.devmajor, header.devminor); |
610 | } else { | 610 | } else { |
611 | len1=snprintf(buf, sizeof(buf), "%d ", header.size); | 611 | len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size); |
612 | } | 612 | } |
613 | /* Jump through some hoops to make the columns match up */ | 613 | /* Jump through some hoops to make the columns match up */ |
614 | for(;(len+len1)<31;len++) | 614 | for(;(len+len1)<31;len++) |
diff --git a/util-linux/more.c b/util-linux/more.c index f84214905..20aa37095 100644 --- a/util-linux/more.c +++ b/util-linux/more.c | |||
@@ -33,17 +33,26 @@ | |||
33 | 33 | ||
34 | static const char more_usage[] = "more [file ...]\n"; | 34 | static const char more_usage[] = "more [file ...]\n"; |
35 | 35 | ||
36 | /* ED: sparc termios is broken: revert back to old termio handling. */ | ||
36 | #ifdef BB_FEATURE_USE_TERMIOS | 37 | #ifdef BB_FEATURE_USE_TERMIOS |
37 | 38 | ||
38 | #include <termio.h> | 39 | #if #cpu(sparc) |
40 | # include <termio.h> | ||
41 | # define termios termio | ||
42 | # define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp) | ||
43 | # define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp) | ||
44 | #else | ||
45 | # include <termios.h> | ||
46 | # define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp) | ||
47 | # define getTermSettings(fd,argp) tcgetattr(fd, argp); | ||
48 | #endif | ||
39 | 49 | ||
40 | FILE *cin; | 50 | FILE *cin; |
41 | /* sparc and other have broken termios support: use old termio handling. */ | 51 | struct termios initial_settings, new_settings; |
42 | struct termio initial_settings, new_settings; | ||
43 | 52 | ||
44 | void gotsig(int sig) | 53 | void gotsig(int sig) |
45 | { | 54 | { |
46 | ioctl(fileno(cin), TCSETAF, &initial_settings); | 55 | setTermSettings(fileno(cin), &initial_settings); |
47 | fprintf(stdout, "\n"); | 56 | fprintf(stdout, "\n"); |
48 | exit(TRUE); | 57 | exit(TRUE); |
49 | } | 58 | } |
@@ -98,11 +107,11 @@ extern int more_main(int argc, char **argv) | |||
98 | cin = fopen("/dev/tty", "r"); | 107 | cin = fopen("/dev/tty", "r"); |
99 | if (!cin) | 108 | if (!cin) |
100 | cin = fopen("/dev/console", "r"); | 109 | cin = fopen("/dev/console", "r"); |
101 | ioctl(fileno(cin), TCGETA, &initial_settings); | 110 | getTermSettings(fileno(cin), &initial_settings); |
102 | new_settings = initial_settings; | 111 | new_settings = initial_settings; |
103 | new_settings.c_lflag &= ~ICANON; | 112 | new_settings.c_lflag &= ~ICANON; |
104 | new_settings.c_lflag &= ~ECHO; | 113 | new_settings.c_lflag &= ~ECHO; |
105 | ioctl(fileno(cin), TCSETAF, &new_settings); | 114 | setTermSettings(fileno(cin), &new_settings); |
106 | 115 | ||
107 | #ifdef BB_FEATURE_AUTOWIDTH | 116 | #ifdef BB_FEATURE_AUTOWIDTH |
108 | ioctl(fileno(stdout), TIOCGWINSZ, &win); | 117 | ioctl(fileno(stdout), TIOCGWINSZ, &win); |