aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-22 17:00:11 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-22 17:00:11 +0000
commite3cbfb91d2c1bd774e4882a220e18aa9e6f54f1e (patch)
tree607404d9e6a23ebd26ede713cf3ffe988dea8878
parent94e3365b8f8eead46ec0b494ce513b7915fb6c04 (diff)
downloadbusybox-w32-e3cbfb91d2c1bd774e4882a220e18aa9e6f54f1e.tar.gz
busybox-w32-e3cbfb91d2c1bd774e4882a220e18aa9e6f54f1e.tar.bz2
busybox-w32-e3cbfb91d2c1bd774e4882a220e18aa9e6f54f1e.zip
vi: introduce FEATURE_VI_8BIT (as vi currently is not Unicode capable,
people may want to disable display of high-bit chars) ip: build fixlet
-rw-r--r--editors/Config.in10
-rw-r--r--editors/vi.c61
-rw-r--r--networking/ip.c2
3 files changed, 51 insertions, 22 deletions
diff --git a/editors/Config.in b/editors/Config.in
index 7c06678fb..58959aa97 100644
--- a/editors/Config.in
+++ b/editors/Config.in
@@ -98,6 +98,16 @@ config FEATURE_VI_MAX_LEN
98 Contrary to what you may think, this is not eating much. 98 Contrary to what you may think, this is not eating much.
99 Make it smaller than 4k only if you are very limited on memory. 99 Make it smaller than 4k only if you are very limited on memory.
100 100
101config FEATURE_VI_8BIT
102 bool "Allow vi to display 8-bit chars (otherwise shows dots)"
103 default y
104 depends on VI
105 help
106 If your terminal can display characters with high bit set,
107 you may want to enable this. Note: vi is not Unicode-capable.
108 If your terminal combines several 8-bit bytes into one character
109 (as in Unicode mode), this will not work properly.
110
101config FEATURE_VI_COLON 111config FEATURE_VI_COLON
102 bool "Enable \":\" colon commands (no \"ex\" mode)" 112 bool "Enable \":\" colon commands (no \"ex\" mode)"
103 default y 113 default y
diff --git a/editors/vi.c b/editors/vi.c
index e1aabab01..65a82b138 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -25,13 +25,27 @@
25 25
26#define ENABLE_FEATURE_VI_CRASHME 0 26#define ENABLE_FEATURE_VI_CRASHME 0
27 27
28
28#if ENABLE_LOCALE_SUPPORT 29#if ENABLE_LOCALE_SUPPORT
29#define Isprint(c) isprint((c)) 30
31#if ENABLE_FEATURE_VI_8BIT
32#define Isprint(c) isprint(c)
33#else
34#define Isprint(c) (isprint(c) && (unsigned char)(c) < 0x7f)
35#endif
36
30#else 37#else
38
31/* 0x9b is Meta-ESC */ 39/* 0x9b is Meta-ESC */
40#if ENABLE_FEATURE_VI_8BIT
32#define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b) 41#define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b)
42#else
43#define Isprint(c) ((unsigned char)(c) >= ' ' && (unsigned char)(c) < 0x7f)
33#endif 44#endif
34 45
46#endif
47
48
35enum { 49enum {
36 MAX_TABSTOP = 32, // sanity limit 50 MAX_TABSTOP = 32, // sanity limit
37 // User input len. Need not be extra big. 51 // User input len. Need not be extra big.
@@ -1162,7 +1176,7 @@ static int next_tabstop(int col)
1162} 1176}
1163 1177
1164//----- Synchronize the cursor to Dot -------------------------- 1178//----- Synchronize the cursor to Dot --------------------------
1165static void sync_cursor(char * d, int *row, int *col) 1179static void sync_cursor(char *d, int *row, int *col)
1166{ 1180{
1167 char *beg_cur; // begin and end of "d" line 1181 char *beg_cur; // begin and end of "d" line
1168 char *end_scr; // begin and end of screen 1182 char *end_scr; // begin and end of screen
@@ -1209,19 +1223,22 @@ static void sync_cursor(char * d, int *row, int *col)
1209 1223
1210 // find out what col "d" is on 1224 // find out what col "d" is on
1211 co = 0; 1225 co = 0;
1212 do { // drive "co" to correct column 1226 while (tp < d) { // drive "co" to correct column
1213 if (*tp == '\n') //vda || *tp == '\0') 1227 if (*tp == '\n') //vda || *tp == '\0')
1214 break; 1228 break;
1215 if (*tp == '\t') { 1229 if (*tp == '\t') {
1216 if (d == tp && cmd_mode) { /* handle tabs like real vi */ 1230 // handle tabs like real vi
1231 if (d == tp && cmd_mode) {
1217 break; 1232 break;
1218 } else { 1233 } else {
1219 co = next_tabstop(co); 1234 co = next_tabstop(co);
1220 } 1235 }
1221 } else if (*tp < ' ' || *tp == 127) { 1236 } else if ((unsigned char)*tp < ' ' || *tp == 0x7f) {
1222 co++; // display as ^X, use 2 columns 1237 co++; // display as ^X, use 2 columns
1223 } 1238 }
1224 } while (tp++ < d && ++co); 1239 co++;
1240 tp++;
1241 }
1225 1242
1226 // "co" is the column where "dot" is. 1243 // "co" is the column where "dot" is.
1227 // The screen has "columns" columns. 1244 // The screen has "columns" columns.
@@ -1367,15 +1384,17 @@ static char *move_to_col(char *p, int l)
1367 1384
1368 p = begin_line(p); 1385 p = begin_line(p);
1369 co = 0; 1386 co = 0;
1370 do { 1387 while (co < l && p < end) {
1371 if (*p == '\n') //vda || *p == '\0') 1388 if (*p == '\n') //vda || *p == '\0')
1372 break; 1389 break;
1373 if (*p == '\t') { 1390 if (*p == '\t') {
1374 co = next_tabstop(co); 1391 co = next_tabstop(co);
1375 } else if (*p < ' ' || *p == 127) { 1392 } else if (*p < ' ' || *p == 127) {
1376 co++; // display as ^X, use 2 columns 1393 co++; // display as ^X, use 2 columns
1377 } 1394 }
1378 } while (++co <= l && p++ < end); 1395 co++;
1396 p++;
1397 }
1379 return p; 1398 return p;
1380} 1399}
1381 1400
@@ -2081,6 +2100,7 @@ static void cookmode(void)
2081#if ENABLE_FEATURE_VI_USE_SIGNALS 2100#if ENABLE_FEATURE_VI_USE_SIGNALS
2082static void winch_sig(int sig ATTRIBUTE_UNUSED) 2101static void winch_sig(int sig ATTRIBUTE_UNUSED)
2083{ 2102{
2103 // FIXME: do it in main loop!!!
2084 signal(SIGWINCH, winch_sig); 2104 signal(SIGWINCH, winch_sig);
2085 if (ENABLE_FEATURE_VI_WIN_RESIZE) { 2105 if (ENABLE_FEATURE_VI_WIN_RESIZE) {
2086 get_terminal_width_height(0, &columns, &rows); 2106 get_terminal_width_height(0, &columns, &rows);
@@ -2735,11 +2755,9 @@ static void redraw(int full_screen)
2735} 2755}
2736 2756
2737//----- Format a text[] line into a buffer --------------------- 2757//----- Format a text[] line into a buffer ---------------------
2738// Returns number of leading chars which should be ignored
2739// (return value is always <= offset)
2740static char* format_line(char *src, int li) 2758static char* format_line(char *src, int li)
2741{ 2759{
2742 char c; 2760 unsigned char c;
2743 int co; 2761 int co;
2744 int ofs = offset; 2762 int ofs = offset;
2745 char *dest = scr_out_buf; // [MAX_SCR_COLS + MAX_TABSTOP * 2] 2763 char *dest = scr_out_buf; // [MAX_SCR_COLS + MAX_TABSTOP * 2]
@@ -2747,8 +2765,8 @@ static char* format_line(char *src, int li)
2747 memset(dest, ' ', MAX_SCR_COLS + MAX_TABSTOP * 2); 2765 memset(dest, ' ', MAX_SCR_COLS + MAX_TABSTOP * 2);
2748 2766
2749 c = '~'; // char in col 0 in non-existent lines is '~' 2767 c = '~'; // char in col 0 in non-existent lines is '~'
2750 for (co = 0; co < MAX_SCR_COLS + MAX_TABSTOP; co++) { 2768 for (co = 0; co < columns + MAX_TABSTOP; co++) {
2751 // are there chars in text[] and have we gone past the end 2769 // have we gone past the end?
2752 if (src < end) { 2770 if (src < end) {
2753 c = *src++; 2771 c = *src++;
2754 if (c == '\n') 2772 if (c == '\n')
@@ -2756,7 +2774,7 @@ static char* format_line(char *src, int li)
2756 if ((c & 0x80) && !Isprint(c)) { 2774 if ((c & 0x80) && !Isprint(c)) {
2757 c = '.'; 2775 c = '.';
2758 } 2776 }
2759 if ((unsigned char)c < ' ' || c == 0x7f) { 2777 if (c < ' ' || c == 0x7f) {
2760 if (c == '\t') { 2778 if (c == '\t') {
2761 c = ' '; 2779 c = ' ';
2762 // co % 8 != 7 2780 // co % 8 != 7
@@ -2907,14 +2925,15 @@ static void refresh(int full_screen)
2907//----- Execute a Vi Command ----------------------------------- 2925//----- Execute a Vi Command -----------------------------------
2908static void do_cmd(char c) 2926static void do_cmd(char c)
2909{ 2927{
2910 const char *msg; 2928 const char *msg = msg; // for compiler
2911 char c1, *p, *q, *save_dot; 2929 char c1, *p, *q, *save_dot;
2912 char buf[12]; 2930 char buf[12];
2913 int cnt, i, j, dir, yf; 2931 int dir = dir; // for compiler
2932 int cnt, i, j, yf;
2914 2933
2915// c1 = c; // quiet the compiler 2934// c1 = c; // quiet the compiler
2916// cnt = yf = dir = 0; // quiet the compiler 2935// cnt = yf = 0; // quiet the compiler
2917// msg = p = q = save_dot = buf; // quiet the compiler 2936// msg = p = q = save_dot = buf; // quiet the compiler
2918 memset(buf, '\0', 12); 2937 memset(buf, '\0', 12);
2919 2938
2920 show_status_line(); 2939 show_status_line();
diff --git a/networking/ip.c b/networking/ip.c
index 182813d4e..5d9785194 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -90,7 +90,7 @@ int ip_main(int argc, char **argv)
90 USE_FEATURE_IP_RULE(IP_rule,) 90 USE_FEATURE_IP_RULE(IP_rule,)
91 IP_none 91 IP_none
92 }; 92 };
93 int (*ip_func)(char **argv) = ip_print_help; 93 int (*ip_func)(char**) = ip_print_help;
94 94
95 argv = ip_parse_common_args(argv + 1); 95 argv = ip_parse_common_args(argv + 1);
96 if (*argv) { 96 if (*argv) {