diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-01 16:38:06 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-01 16:42:30 +0200 |
commit | 26f5e9d21ccf10ff447c68e4a28be2e723055356 (patch) | |
tree | 4a6d792bf9158516266ca12fede85499f59abd9d | |
parent | 2a57608f673698ddbde6704ef1f01f2fd443710b (diff) | |
download | busybox-w32-26f5e9d21ccf10ff447c68e4a28be2e723055356.tar.gz busybox-w32-26f5e9d21ccf10ff447c68e4a28be2e723055356.tar.bz2 busybox-w32-26f5e9d21ccf10ff447c68e4a28be2e723055356.zip |
vi: convert more /**/ comments to //
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/vi.c | 118 |
1 files changed, 56 insertions, 62 deletions
diff --git a/editors/vi.c b/editors/vi.c index af23ae7d2..fe907c841 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -5,19 +5,19 @@ | |||
5 | * | 5 | * |
6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
7 | */ | 7 | */ |
8 | /* | 8 | // |
9 | * Things To Do: | 9 | //Things To Do: |
10 | * EXINIT | 10 | // EXINIT |
11 | * $HOME/.exrc and ./.exrc | 11 | // $HOME/.exrc and ./.exrc |
12 | * add magic to search /foo.*bar | 12 | // add magic to search /foo.*bar |
13 | * add :help command | 13 | // add :help command |
14 | * :map macros | 14 | // :map macros |
15 | * if mark[] values were line numbers rather than pointers | 15 | // if mark[] values were line numbers rather than pointers |
16 | * it would be easier to change the mark when add/delete lines | 16 | // it would be easier to change the mark when add/delete lines |
17 | * More intelligence in refresh() | 17 | // More intelligence in refresh() |
18 | * ":r !cmd" and "!cmd" to filter text through an external command | 18 | // ":r !cmd" and "!cmd" to filter text through an external command |
19 | * An "ex" line oriented mode- maybe using "cmdedit" | 19 | // An "ex" line oriented mode- maybe using "cmdedit" |
20 | */ | 20 | |
21 | //config:config VI | 21 | //config:config VI |
22 | //config: bool "vi (23 kb)" | 22 | //config: bool "vi (23 kb)" |
23 | //config: default y | 23 | //config: default y |
@@ -178,12 +178,12 @@ | |||
178 | //usage: "\n -H List available features" | 178 | //usage: "\n -H List available features" |
179 | 179 | ||
180 | #include "libbb.h" | 180 | #include "libbb.h" |
181 | /* Should be after libbb.h: on some systems regex.h needs sys/types.h: */ | 181 | // Should be after libbb.h: on some systems regex.h needs sys/types.h: |
182 | #if ENABLE_FEATURE_VI_REGEX_SEARCH | 182 | #if ENABLE_FEATURE_VI_REGEX_SEARCH |
183 | # include <regex.h> | 183 | # include <regex.h> |
184 | #endif | 184 | #endif |
185 | 185 | ||
186 | /* the CRASHME code is unmaintained, and doesn't currently build */ | 186 | // the CRASHME code is unmaintained, and doesn't currently build |
187 | #define ENABLE_FEATURE_VI_CRASHME 0 | 187 | #define ENABLE_FEATURE_VI_CRASHME 0 |
188 | 188 | ||
189 | 189 | ||
@@ -198,7 +198,7 @@ | |||
198 | 198 | ||
199 | #else | 199 | #else |
200 | 200 | ||
201 | /* 0x9b is Meta-ESC */ | 201 | // 0x9b is Meta-ESC |
202 | #if ENABLE_FEATURE_VI_8BIT | 202 | #if ENABLE_FEATURE_VI_8BIT |
203 | # define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b) | 203 | # define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b) |
204 | #else | 204 | #else |
@@ -218,29 +218,27 @@ enum { | |||
218 | MAX_SCR_ROWS = CONFIG_FEATURE_VI_MAX_LEN, | 218 | MAX_SCR_ROWS = CONFIG_FEATURE_VI_MAX_LEN, |
219 | }; | 219 | }; |
220 | 220 | ||
221 | /* VT102 ESC sequences. | 221 | // VT102 ESC sequences. |
222 | * See "Xterm Control Sequences" | 222 | // See "Xterm Control Sequences" |
223 | * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html | 223 | // http://invisible-island.net/xterm/ctlseqs/ctlseqs.html |
224 | */ | ||
225 | #define ESC "\033" | 224 | #define ESC "\033" |
226 | /* Inverse/Normal text */ | 225 | // Inverse/Normal text |
227 | #define ESC_BOLD_TEXT ESC"[7m" | 226 | #define ESC_BOLD_TEXT ESC"[7m" |
228 | #define ESC_NORM_TEXT ESC"[m" | 227 | #define ESC_NORM_TEXT ESC"[m" |
229 | /* Bell */ | 228 | // Bell |
230 | #define ESC_BELL "\007" | 229 | #define ESC_BELL "\007" |
231 | /* Clear-to-end-of-line */ | 230 | // Clear-to-end-of-line |
232 | #define ESC_CLEAR2EOL ESC"[K" | 231 | #define ESC_CLEAR2EOL ESC"[K" |
233 | /* Clear-to-end-of-screen. | 232 | // Clear-to-end-of-screen. |
234 | * (We use default param here. | 233 | // (We use default param here. |
235 | * Full sequence is "ESC [ <num> J", | 234 | // Full sequence is "ESC [ <num> J", |
236 | * <num> is 0/1/2 = "erase below/above/all".) | 235 | // <num> is 0/1/2 = "erase below/above/all".) |
237 | */ | ||
238 | #define ESC_CLEAR2EOS ESC"[J" | 236 | #define ESC_CLEAR2EOS ESC"[J" |
239 | /* Cursor to given coordinate (1,1: top left) */ | 237 | // Cursor to given coordinate (1,1: top left) |
240 | #define ESC_SET_CURSOR_POS ESC"[%u;%uH" | 238 | #define ESC_SET_CURSOR_POS ESC"[%u;%uH" |
241 | #define ESC_SET_CURSOR_TOPLEFT ESC"[H" | 239 | #define ESC_SET_CURSOR_TOPLEFT ESC"[H" |
242 | //UNUSED | 240 | //UNUSED |
243 | ///* Cursor up and down */ | 241 | //// Cursor up and down |
244 | //#define ESC_CURSOR_UP ESC"[A" | 242 | //#define ESC_CURSOR_UP ESC"[A" |
245 | //#define ESC_CURSOR_DOWN "\n" | 243 | //#define ESC_CURSOR_DOWN "\n" |
246 | 244 | ||
@@ -267,17 +265,17 @@ enum { | |||
267 | }; | 265 | }; |
268 | 266 | ||
269 | 267 | ||
270 | /* vi.c expects chars to be unsigned. */ | 268 | // vi.c expects chars to be unsigned. |
271 | /* busybox build system provides that, but it's better */ | 269 | // busybox build system provides that, but it's better |
272 | /* to audit and fix the source */ | 270 | // to audit and fix the source |
273 | 271 | ||
274 | struct globals { | 272 | struct globals { |
275 | /* many references - keep near the top of globals */ | 273 | // many references - keep near the top of globals |
276 | char *text, *end; // pointers to the user data in memory | 274 | char *text, *end; // pointers to the user data in memory |
277 | char *dot; // where all the action takes place | 275 | char *dot; // where all the action takes place |
278 | int text_size; // size of the allocated buffer | 276 | int text_size; // size of the allocated buffer |
279 | 277 | ||
280 | /* the rest */ | 278 | // the rest |
281 | smallint vi_setops; | 279 | smallint vi_setops; |
282 | #define VI_AUTOINDENT 1 | 280 | #define VI_AUTOINDENT 1 |
283 | #define VI_SHOWMATCH 2 | 281 | #define VI_SHOWMATCH 2 |
@@ -286,7 +284,7 @@ struct globals { | |||
286 | #define autoindent (vi_setops & VI_AUTOINDENT) | 284 | #define autoindent (vi_setops & VI_AUTOINDENT) |
287 | #define showmatch (vi_setops & VI_SHOWMATCH ) | 285 | #define showmatch (vi_setops & VI_SHOWMATCH ) |
288 | #define ignorecase (vi_setops & VI_IGNORECASE) | 286 | #define ignorecase (vi_setops & VI_IGNORECASE) |
289 | /* indicate error with beep or flash */ | 287 | // indicate error with beep or flash |
290 | #define err_method (vi_setops & VI_ERR_METHOD) | 288 | #define err_method (vi_setops & VI_ERR_METHOD) |
291 | 289 | ||
292 | #if ENABLE_FEATURE_VI_READONLY | 290 | #if ENABLE_FEATURE_VI_READONLY |
@@ -334,14 +332,14 @@ struct globals { | |||
334 | char *last_search_pattern; // last pattern from a '/' or '?' search | 332 | char *last_search_pattern; // last pattern from a '/' or '?' search |
335 | #endif | 333 | #endif |
336 | 334 | ||
337 | /* former statics */ | 335 | // former statics |
338 | #if ENABLE_FEATURE_VI_YANKMARK | 336 | #if ENABLE_FEATURE_VI_YANKMARK |
339 | char *edit_file__cur_line; | 337 | char *edit_file__cur_line; |
340 | #endif | 338 | #endif |
341 | int refresh__old_offset; | 339 | int refresh__old_offset; |
342 | int format_edit_status__tot; | 340 | int format_edit_status__tot; |
343 | 341 | ||
344 | /* a few references only */ | 342 | // a few references only |
345 | #if ENABLE_FEATURE_VI_YANKMARK | 343 | #if ENABLE_FEATURE_VI_YANKMARK |
346 | smalluint YDreg;//,Ureg;// default delete register and orig line for "U" | 344 | smalluint YDreg;//,Ureg;// default delete register and orig line for "U" |
347 | #define Ureg 27 | 345 | #define Ureg 27 |
@@ -368,9 +366,10 @@ struct globals { | |||
368 | #if ENABLE_FEATURE_VI_DOT_CMD | 366 | #if ENABLE_FEATURE_VI_DOT_CMD |
369 | char last_modifying_cmd[MAX_INPUT_LEN]; // last modifying cmd for "." | 367 | char last_modifying_cmd[MAX_INPUT_LEN]; // last modifying cmd for "." |
370 | #endif | 368 | #endif |
371 | char get_input_line__buf[MAX_INPUT_LEN]; /* former static */ | 369 | char get_input_line__buf[MAX_INPUT_LEN]; // former static |
372 | 370 | ||
373 | char scr_out_buf[MAX_SCR_COLS + MAX_TABSTOP * 2]; | 371 | char scr_out_buf[MAX_SCR_COLS + MAX_TABSTOP * 2]; |
372 | |||
374 | #if ENABLE_FEATURE_VI_UNDO | 373 | #if ENABLE_FEATURE_VI_UNDO |
375 | // undo_push() operations | 374 | // undo_push() operations |
376 | #define UNDO_INS 0 | 375 | #define UNDO_INS 0 |
@@ -397,7 +396,6 @@ struct globals { | |||
397 | // If undo queuing disabled, don't invoke the missing queue logic | 396 | // If undo queuing disabled, don't invoke the missing queue logic |
398 | #define ALLOW_UNDO_QUEUED 1 | 397 | #define ALLOW_UNDO_QUEUED 1 |
399 | # endif | 398 | # endif |
400 | |||
401 | struct undo_object { | 399 | struct undo_object { |
402 | struct undo_object *prev; // Linking back avoids list traversal (LIFO) | 400 | struct undo_object *prev; // Linking back avoids list traversal (LIFO) |
403 | int start; // Offset where the data should be restored/deleted | 401 | int start; // Offset where the data should be restored/deleted |
@@ -1969,7 +1967,7 @@ static char *char_insert(char *p, char c, int undo) // insert the char c at 'p' | |||
1969 | undo_push_insert(p, 1, undo); | 1967 | undo_push_insert(p, 1, undo); |
1970 | #else | 1968 | #else |
1971 | modified_count++; | 1969 | modified_count++; |
1972 | #endif /* ENABLE_FEATURE_VI_UNDO */ | 1970 | #endif |
1973 | p++; | 1971 | p++; |
1974 | } else if (c == 27) { // Is this an ESC? | 1972 | } else if (c == 27) { // Is this an ESC? |
1975 | cmd_mode = 0; | 1973 | cmd_mode = 0; |
@@ -1997,7 +1995,7 @@ static char *char_insert(char *p, char c, int undo) // insert the char c at 'p' | |||
1997 | undo_push_insert(p, 1, undo); | 1995 | undo_push_insert(p, 1, undo); |
1998 | #else | 1996 | #else |
1999 | modified_count++; | 1997 | modified_count++; |
2000 | #endif /* ENABLE_FEATURE_VI_UNDO */ | 1998 | #endif |
2001 | p += 1 + stupid_insert(p, c); // insert the char | 1999 | p += 1 + stupid_insert(p, c); // insert the char |
2002 | #if ENABLE_FEATURE_VI_SETOPTS | 2000 | #if ENABLE_FEATURE_VI_SETOPTS |
2003 | if (showmatch && strchr(")]}", c) != NULL) { | 2001 | if (showmatch && strchr(")]}", c) != NULL) { |
@@ -2777,7 +2775,7 @@ static void colon(char *buf) | |||
2777 | bias = string_insert(found, R, ALLOW_UNDO_CHAIN); | 2775 | bias = string_insert(found, R, ALLOW_UNDO_CHAIN); |
2778 | found += bias; | 2776 | found += bias; |
2779 | ls += bias; | 2777 | ls += bias; |
2780 | /*q += bias; - recalculated anyway */ | 2778 | //q += bias; - recalculated anyway |
2781 | // check for "global" :s/foo/bar/g | 2779 | // check for "global" :s/foo/bar/g |
2782 | if (gflag == 'g') { | 2780 | if (gflag == 'g') { |
2783 | if ((found + len_R) < end_line(ls)) { | 2781 | if ((found + len_R) < end_line(ls)) { |
@@ -2873,18 +2871,14 @@ static void colon(char *buf) | |||
2873 | #endif /* FEATURE_VI_COLON */ | 2871 | #endif /* FEATURE_VI_COLON */ |
2874 | } | 2872 | } |
2875 | 2873 | ||
2876 | //----- Helper Utility Routines -------------------------------- | ||
2877 | |||
2878 | //---------------------------------------------------------------- | ||
2879 | //----- Char Routines -------------------------------------------- | 2874 | //----- Char Routines -------------------------------------------- |
2880 | /* Chars that are part of a word- | 2875 | // Chars that are part of a word- |
2881 | * 0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz | 2876 | // 0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz |
2882 | * Chars that are Not part of a word (stoppers) | 2877 | // Chars that are Not part of a word (stoppers) |
2883 | * !"#$%&'()*+,-./:;<=>?@[\]^`{|}~ | 2878 | // !"#$%&'()*+,-./:;<=>?@[\]^`{|}~ |
2884 | * Chars that are WhiteSpace | 2879 | // Chars that are WhiteSpace |
2885 | * TAB NEWLINE VT FF RETURN SPACE | 2880 | // TAB NEWLINE VT FF RETURN SPACE |
2886 | * DO NOT COUNT NEWLINE AS WHITESPACE | 2881 | // DO NOT COUNT NEWLINE AS WHITESPACE |
2887 | */ | ||
2888 | 2882 | ||
2889 | static char *new_screen(int ro, int co) | 2883 | static char *new_screen(int ro, int co) |
2890 | { | 2884 | { |
@@ -3242,7 +3236,7 @@ static void do_cmd(int c) | |||
3242 | dot_skip_over_ws(); | 3236 | dot_skip_over_ws(); |
3243 | } while (--cmdcnt > 0); | 3237 | } while (--cmdcnt > 0); |
3244 | break; | 3238 | break; |
3245 | case 21: // ctrl-U scroll up half screen | 3239 | case 21: // ctrl-U scroll up half screen |
3246 | dot_scroll((rows - 2) / 2, -1); | 3240 | dot_scroll((rows - 2) / 2, -1); |
3247 | break; | 3241 | break; |
3248 | case 25: // ctrl-Y scroll up one line | 3242 | case 25: // ctrl-Y scroll up one line |
@@ -3251,7 +3245,7 @@ static void do_cmd(int c) | |||
3251 | case 27: // esc | 3245 | case 27: // esc |
3252 | if (cmd_mode == 0) | 3246 | if (cmd_mode == 0) |
3253 | indicate_error(); | 3247 | indicate_error(); |
3254 | cmd_mode = 0; // stop insrting | 3248 | cmd_mode = 0; // stop inserting |
3255 | undo_queue_commit(); | 3249 | undo_queue_commit(); |
3256 | end_cmd_q(); | 3250 | end_cmd_q(); |
3257 | last_status_cksum = 0; // force status update | 3251 | last_status_cksum = 0; // force status update |
@@ -3948,7 +3942,7 @@ static void do_cmd(int c) | |||
3948 | dot--; | 3942 | dot--; |
3949 | } | 3943 | } |
3950 | 3944 | ||
3951 | /* NB! the CRASHME code is unmaintained, and doesn't currently build */ | 3945 | // NB! the CRASHME code is unmaintained, and doesn't currently build |
3952 | #if ENABLE_FEATURE_VI_CRASHME | 3946 | #if ENABLE_FEATURE_VI_CRASHME |
3953 | static int totalcmds = 0; | 3947 | static int totalcmds = 0; |
3954 | static int Mp = 85; // Movement command Probability | 3948 | static int Mp = 85; // Movement command Probability |
@@ -4253,7 +4247,7 @@ static void edit_file(char *fn) | |||
4253 | crash_dummy(); // generate a random command | 4247 | crash_dummy(); // generate a random command |
4254 | } else { | 4248 | } else { |
4255 | crashme = 0; | 4249 | crashme = 0; |
4256 | string_insert(text, "\n\n##### Ran out of text to work on. #####\n\n", NO_UNDO); // insert the string | 4250 | string_insert(text, "\n\n##### Ran out of text to work on. #####\n\n", NO_UNDO); |
4257 | dot = text; | 4251 | dot = text; |
4258 | refresh(FALSE); | 4252 | refresh(FALSE); |
4259 | } | 4253 | } |
@@ -4268,8 +4262,8 @@ static void edit_file(char *fn) | |||
4268 | } | 4262 | } |
4269 | #endif | 4263 | #endif |
4270 | #if ENABLE_FEATURE_VI_DOT_CMD | 4264 | #if ENABLE_FEATURE_VI_DOT_CMD |
4271 | // These are commands that change text[]. | 4265 | // If c is a command that changes text[], |
4272 | // Remember the input for the "." command | 4266 | // (re)start remembering the input for the "." command. |
4273 | if (!adding2q | 4267 | if (!adding2q |
4274 | && ioq_start == NULL | 4268 | && ioq_start == NULL |
4275 | && cmd_mode == 0 // command mode | 4269 | && cmd_mode == 0 // command mode |
@@ -4310,10 +4304,10 @@ int vi_main(int argc, char **argv) | |||
4310 | INIT_G(); | 4304 | INIT_G(); |
4311 | 4305 | ||
4312 | #if ENABLE_FEATURE_VI_UNDO | 4306 | #if ENABLE_FEATURE_VI_UNDO |
4313 | /* undo_stack_tail = NULL; - already is */ | 4307 | //undo_stack_tail = NULL; - already is |
4314 | # if ENABLE_FEATURE_VI_UNDO_QUEUE | 4308 | # if ENABLE_FEATURE_VI_UNDO_QUEUE |
4315 | undo_queue_state = UNDO_EMPTY; | 4309 | undo_queue_state = UNDO_EMPTY; |
4316 | /* undo_q = 0; - already is */ | 4310 | //undo_q = 0; - already is |
4317 | # endif | 4311 | # endif |
4318 | #endif | 4312 | #endif |
4319 | 4313 | ||