vi: convert more /**/ comments to //
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
2a57608f67
commit
26f5e9d21c
118
editors/vi.c
118
editors/vi.c
@ -5,19 +5,19 @@
|
|||||||
*
|
*
|
||||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||||
*/
|
*/
|
||||||
/*
|
//
|
||||||
* Things To Do:
|
//Things To Do:
|
||||||
* EXINIT
|
// EXINIT
|
||||||
* $HOME/.exrc and ./.exrc
|
// $HOME/.exrc and ./.exrc
|
||||||
* add magic to search /foo.*bar
|
// add magic to search /foo.*bar
|
||||||
* add :help command
|
// add :help command
|
||||||
* :map macros
|
// :map macros
|
||||||
* if mark[] values were line numbers rather than pointers
|
// if mark[] values were line numbers rather than pointers
|
||||||
* it would be easier to change the mark when add/delete lines
|
// it would be easier to change the mark when add/delete lines
|
||||||
* More intelligence in refresh()
|
// More intelligence in refresh()
|
||||||
* ":r !cmd" and "!cmd" to filter text through an external command
|
// ":r !cmd" and "!cmd" to filter text through an external command
|
||||||
* An "ex" line oriented mode- maybe using "cmdedit"
|
// An "ex" line oriented mode- maybe using "cmdedit"
|
||||||
*/
|
|
||||||
//config:config VI
|
//config:config VI
|
||||||
//config: bool "vi (23 kb)"
|
//config: bool "vi (23 kb)"
|
||||||
//config: default y
|
//config: default y
|
||||||
@ -178,12 +178,12 @@
|
|||||||
//usage: "\n -H List available features"
|
//usage: "\n -H List available features"
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
/* Should be after libbb.h: on some systems regex.h needs sys/types.h: */
|
// Should be after libbb.h: on some systems regex.h needs sys/types.h:
|
||||||
#if ENABLE_FEATURE_VI_REGEX_SEARCH
|
#if ENABLE_FEATURE_VI_REGEX_SEARCH
|
||||||
# include <regex.h>
|
# include <regex.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* the CRASHME code is unmaintained, and doesn't currently build */
|
// the CRASHME code is unmaintained, and doesn't currently build
|
||||||
#define ENABLE_FEATURE_VI_CRASHME 0
|
#define ENABLE_FEATURE_VI_CRASHME 0
|
||||||
|
|
||||||
|
|
||||||
@ -198,7 +198,7 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* 0x9b is Meta-ESC */
|
// 0x9b is Meta-ESC
|
||||||
#if ENABLE_FEATURE_VI_8BIT
|
#if ENABLE_FEATURE_VI_8BIT
|
||||||
# define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b)
|
# define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b)
|
||||||
#else
|
#else
|
||||||
@ -218,29 +218,27 @@ enum {
|
|||||||
MAX_SCR_ROWS = CONFIG_FEATURE_VI_MAX_LEN,
|
MAX_SCR_ROWS = CONFIG_FEATURE_VI_MAX_LEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* VT102 ESC sequences.
|
// VT102 ESC sequences.
|
||||||
* See "Xterm Control Sequences"
|
// See "Xterm Control Sequences"
|
||||||
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
// http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
||||||
*/
|
|
||||||
#define ESC "\033"
|
#define ESC "\033"
|
||||||
/* Inverse/Normal text */
|
// Inverse/Normal text
|
||||||
#define ESC_BOLD_TEXT ESC"[7m"
|
#define ESC_BOLD_TEXT ESC"[7m"
|
||||||
#define ESC_NORM_TEXT ESC"[m"
|
#define ESC_NORM_TEXT ESC"[m"
|
||||||
/* Bell */
|
// Bell
|
||||||
#define ESC_BELL "\007"
|
#define ESC_BELL "\007"
|
||||||
/* Clear-to-end-of-line */
|
// Clear-to-end-of-line
|
||||||
#define ESC_CLEAR2EOL ESC"[K"
|
#define ESC_CLEAR2EOL ESC"[K"
|
||||||
/* Clear-to-end-of-screen.
|
// Clear-to-end-of-screen.
|
||||||
* (We use default param here.
|
// (We use default param here.
|
||||||
* Full sequence is "ESC [ <num> J",
|
// Full sequence is "ESC [ <num> J",
|
||||||
* <num> is 0/1/2 = "erase below/above/all".)
|
// <num> is 0/1/2 = "erase below/above/all".)
|
||||||
*/
|
|
||||||
#define ESC_CLEAR2EOS ESC"[J"
|
#define ESC_CLEAR2EOS ESC"[J"
|
||||||
/* Cursor to given coordinate (1,1: top left) */
|
// Cursor to given coordinate (1,1: top left)
|
||||||
#define ESC_SET_CURSOR_POS ESC"[%u;%uH"
|
#define ESC_SET_CURSOR_POS ESC"[%u;%uH"
|
||||||
#define ESC_SET_CURSOR_TOPLEFT ESC"[H"
|
#define ESC_SET_CURSOR_TOPLEFT ESC"[H"
|
||||||
//UNUSED
|
//UNUSED
|
||||||
///* Cursor up and down */
|
//// Cursor up and down
|
||||||
//#define ESC_CURSOR_UP ESC"[A"
|
//#define ESC_CURSOR_UP ESC"[A"
|
||||||
//#define ESC_CURSOR_DOWN "\n"
|
//#define ESC_CURSOR_DOWN "\n"
|
||||||
|
|
||||||
@ -267,17 +265,17 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* vi.c expects chars to be unsigned. */
|
// vi.c expects chars to be unsigned.
|
||||||
/* busybox build system provides that, but it's better */
|
// busybox build system provides that, but it's better
|
||||||
/* to audit and fix the source */
|
// to audit and fix the source
|
||||||
|
|
||||||
struct globals {
|
struct globals {
|
||||||
/* many references - keep near the top of globals */
|
// many references - keep near the top of globals
|
||||||
char *text, *end; // pointers to the user data in memory
|
char *text, *end; // pointers to the user data in memory
|
||||||
char *dot; // where all the action takes place
|
char *dot; // where all the action takes place
|
||||||
int text_size; // size of the allocated buffer
|
int text_size; // size of the allocated buffer
|
||||||
|
|
||||||
/* the rest */
|
// the rest
|
||||||
smallint vi_setops;
|
smallint vi_setops;
|
||||||
#define VI_AUTOINDENT 1
|
#define VI_AUTOINDENT 1
|
||||||
#define VI_SHOWMATCH 2
|
#define VI_SHOWMATCH 2
|
||||||
@ -286,7 +284,7 @@ struct globals {
|
|||||||
#define autoindent (vi_setops & VI_AUTOINDENT)
|
#define autoindent (vi_setops & VI_AUTOINDENT)
|
||||||
#define showmatch (vi_setops & VI_SHOWMATCH )
|
#define showmatch (vi_setops & VI_SHOWMATCH )
|
||||||
#define ignorecase (vi_setops & VI_IGNORECASE)
|
#define ignorecase (vi_setops & VI_IGNORECASE)
|
||||||
/* indicate error with beep or flash */
|
// indicate error with beep or flash
|
||||||
#define err_method (vi_setops & VI_ERR_METHOD)
|
#define err_method (vi_setops & VI_ERR_METHOD)
|
||||||
|
|
||||||
#if ENABLE_FEATURE_VI_READONLY
|
#if ENABLE_FEATURE_VI_READONLY
|
||||||
@ -334,14 +332,14 @@ struct globals {
|
|||||||
char *last_search_pattern; // last pattern from a '/' or '?' search
|
char *last_search_pattern; // last pattern from a '/' or '?' search
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* former statics */
|
// former statics
|
||||||
#if ENABLE_FEATURE_VI_YANKMARK
|
#if ENABLE_FEATURE_VI_YANKMARK
|
||||||
char *edit_file__cur_line;
|
char *edit_file__cur_line;
|
||||||
#endif
|
#endif
|
||||||
int refresh__old_offset;
|
int refresh__old_offset;
|
||||||
int format_edit_status__tot;
|
int format_edit_status__tot;
|
||||||
|
|
||||||
/* a few references only */
|
// a few references only
|
||||||
#if ENABLE_FEATURE_VI_YANKMARK
|
#if ENABLE_FEATURE_VI_YANKMARK
|
||||||
smalluint YDreg;//,Ureg;// default delete register and orig line for "U"
|
smalluint YDreg;//,Ureg;// default delete register and orig line for "U"
|
||||||
#define Ureg 27
|
#define Ureg 27
|
||||||
@ -368,9 +366,10 @@ struct globals {
|
|||||||
#if ENABLE_FEATURE_VI_DOT_CMD
|
#if ENABLE_FEATURE_VI_DOT_CMD
|
||||||
char last_modifying_cmd[MAX_INPUT_LEN]; // last modifying cmd for "."
|
char last_modifying_cmd[MAX_INPUT_LEN]; // last modifying cmd for "."
|
||||||
#endif
|
#endif
|
||||||
char get_input_line__buf[MAX_INPUT_LEN]; /* former static */
|
char get_input_line__buf[MAX_INPUT_LEN]; // former static
|
||||||
|
|
||||||
char scr_out_buf[MAX_SCR_COLS + MAX_TABSTOP * 2];
|
char scr_out_buf[MAX_SCR_COLS + MAX_TABSTOP * 2];
|
||||||
|
|
||||||
#if ENABLE_FEATURE_VI_UNDO
|
#if ENABLE_FEATURE_VI_UNDO
|
||||||
// undo_push() operations
|
// undo_push() operations
|
||||||
#define UNDO_INS 0
|
#define UNDO_INS 0
|
||||||
@ -397,7 +396,6 @@ struct globals {
|
|||||||
// If undo queuing disabled, don't invoke the missing queue logic
|
// If undo queuing disabled, don't invoke the missing queue logic
|
||||||
#define ALLOW_UNDO_QUEUED 1
|
#define ALLOW_UNDO_QUEUED 1
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
struct undo_object {
|
struct undo_object {
|
||||||
struct undo_object *prev; // Linking back avoids list traversal (LIFO)
|
struct undo_object *prev; // Linking back avoids list traversal (LIFO)
|
||||||
int start; // Offset where the data should be restored/deleted
|
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'
|
|||||||
undo_push_insert(p, 1, undo);
|
undo_push_insert(p, 1, undo);
|
||||||
#else
|
#else
|
||||||
modified_count++;
|
modified_count++;
|
||||||
#endif /* ENABLE_FEATURE_VI_UNDO */
|
#endif
|
||||||
p++;
|
p++;
|
||||||
} else if (c == 27) { // Is this an ESC?
|
} else if (c == 27) { // Is this an ESC?
|
||||||
cmd_mode = 0;
|
cmd_mode = 0;
|
||||||
@ -1997,7 +1995,7 @@ static char *char_insert(char *p, char c, int undo) // insert the char c at 'p'
|
|||||||
undo_push_insert(p, 1, undo);
|
undo_push_insert(p, 1, undo);
|
||||||
#else
|
#else
|
||||||
modified_count++;
|
modified_count++;
|
||||||
#endif /* ENABLE_FEATURE_VI_UNDO */
|
#endif
|
||||||
p += 1 + stupid_insert(p, c); // insert the char
|
p += 1 + stupid_insert(p, c); // insert the char
|
||||||
#if ENABLE_FEATURE_VI_SETOPTS
|
#if ENABLE_FEATURE_VI_SETOPTS
|
||||||
if (showmatch && strchr(")]}", c) != NULL) {
|
if (showmatch && strchr(")]}", c) != NULL) {
|
||||||
@ -2777,7 +2775,7 @@ static void colon(char *buf)
|
|||||||
bias = string_insert(found, R, ALLOW_UNDO_CHAIN);
|
bias = string_insert(found, R, ALLOW_UNDO_CHAIN);
|
||||||
found += bias;
|
found += bias;
|
||||||
ls += bias;
|
ls += bias;
|
||||||
/*q += bias; - recalculated anyway */
|
//q += bias; - recalculated anyway
|
||||||
// check for "global" :s/foo/bar/g
|
// check for "global" :s/foo/bar/g
|
||||||
if (gflag == 'g') {
|
if (gflag == 'g') {
|
||||||
if ((found + len_R) < end_line(ls)) {
|
if ((found + len_R) < end_line(ls)) {
|
||||||
@ -2873,18 +2871,14 @@ static void colon(char *buf)
|
|||||||
#endif /* FEATURE_VI_COLON */
|
#endif /* FEATURE_VI_COLON */
|
||||||
}
|
}
|
||||||
|
|
||||||
//----- Helper Utility Routines --------------------------------
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
|
||||||
//----- Char Routines --------------------------------------------
|
//----- Char Routines --------------------------------------------
|
||||||
/* Chars that are part of a word-
|
// Chars that are part of a word-
|
||||||
* 0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
// 0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||||
* Chars that are Not part of a word (stoppers)
|
// Chars that are Not part of a word (stoppers)
|
||||||
* !"#$%&'()*+,-./:;<=>?@[\]^`{|}~
|
// !"#$%&'()*+,-./:;<=>?@[\]^`{|}~
|
||||||
* Chars that are WhiteSpace
|
// Chars that are WhiteSpace
|
||||||
* TAB NEWLINE VT FF RETURN SPACE
|
// TAB NEWLINE VT FF RETURN SPACE
|
||||||
* DO NOT COUNT NEWLINE AS WHITESPACE
|
// DO NOT COUNT NEWLINE AS WHITESPACE
|
||||||
*/
|
|
||||||
|
|
||||||
static char *new_screen(int ro, int co)
|
static char *new_screen(int ro, int co)
|
||||||
{
|
{
|
||||||
@ -3242,7 +3236,7 @@ static void do_cmd(int c)
|
|||||||
dot_skip_over_ws();
|
dot_skip_over_ws();
|
||||||
} while (--cmdcnt > 0);
|
} while (--cmdcnt > 0);
|
||||||
break;
|
break;
|
||||||
case 21: // ctrl-U scroll up half screen
|
case 21: // ctrl-U scroll up half screen
|
||||||
dot_scroll((rows - 2) / 2, -1);
|
dot_scroll((rows - 2) / 2, -1);
|
||||||
break;
|
break;
|
||||||
case 25: // ctrl-Y scroll up one line
|
case 25: // ctrl-Y scroll up one line
|
||||||
@ -3251,7 +3245,7 @@ static void do_cmd(int c)
|
|||||||
case 27: // esc
|
case 27: // esc
|
||||||
if (cmd_mode == 0)
|
if (cmd_mode == 0)
|
||||||
indicate_error();
|
indicate_error();
|
||||||
cmd_mode = 0; // stop insrting
|
cmd_mode = 0; // stop inserting
|
||||||
undo_queue_commit();
|
undo_queue_commit();
|
||||||
end_cmd_q();
|
end_cmd_q();
|
||||||
last_status_cksum = 0; // force status update
|
last_status_cksum = 0; // force status update
|
||||||
@ -3948,7 +3942,7 @@ static void do_cmd(int c)
|
|||||||
dot--;
|
dot--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NB! the CRASHME code is unmaintained, and doesn't currently build */
|
// NB! the CRASHME code is unmaintained, and doesn't currently build
|
||||||
#if ENABLE_FEATURE_VI_CRASHME
|
#if ENABLE_FEATURE_VI_CRASHME
|
||||||
static int totalcmds = 0;
|
static int totalcmds = 0;
|
||||||
static int Mp = 85; // Movement command Probability
|
static int Mp = 85; // Movement command Probability
|
||||||
@ -4253,7 +4247,7 @@ static void edit_file(char *fn)
|
|||||||
crash_dummy(); // generate a random command
|
crash_dummy(); // generate a random command
|
||||||
} else {
|
} else {
|
||||||
crashme = 0;
|
crashme = 0;
|
||||||
string_insert(text, "\n\n##### Ran out of text to work on. #####\n\n", NO_UNDO); // insert the string
|
string_insert(text, "\n\n##### Ran out of text to work on. #####\n\n", NO_UNDO);
|
||||||
dot = text;
|
dot = text;
|
||||||
refresh(FALSE);
|
refresh(FALSE);
|
||||||
}
|
}
|
||||||
@ -4268,8 +4262,8 @@ static void edit_file(char *fn)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_VI_DOT_CMD
|
#if ENABLE_FEATURE_VI_DOT_CMD
|
||||||
// These are commands that change text[].
|
// If c is a command that changes text[],
|
||||||
// Remember the input for the "." command
|
// (re)start remembering the input for the "." command.
|
||||||
if (!adding2q
|
if (!adding2q
|
||||||
&& ioq_start == NULL
|
&& ioq_start == NULL
|
||||||
&& cmd_mode == 0 // command mode
|
&& cmd_mode == 0 // command mode
|
||||||
@ -4310,10 +4304,10 @@ int vi_main(int argc, char **argv)
|
|||||||
INIT_G();
|
INIT_G();
|
||||||
|
|
||||||
#if ENABLE_FEATURE_VI_UNDO
|
#if ENABLE_FEATURE_VI_UNDO
|
||||||
/* undo_stack_tail = NULL; - already is */
|
//undo_stack_tail = NULL; - already is
|
||||||
# if ENABLE_FEATURE_VI_UNDO_QUEUE
|
# if ENABLE_FEATURE_VI_UNDO_QUEUE
|
||||||
undo_queue_state = UNDO_EMPTY;
|
undo_queue_state = UNDO_EMPTY;
|
||||||
/* undo_q = 0; - already is */
|
//undo_q = 0; - already is
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user