aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/vi.c86
1 files changed, 37 insertions, 49 deletions
diff --git a/editors/vi.c b/editors/vi.c
index d9124fd76..9b050e115 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -793,7 +793,7 @@ static void colon(char *buf)
793 // 793 //
794 794
795 if (!buf[0]) 795 if (!buf[0])
796 goto vc1; 796 goto ret;
797 if (*buf == ':') 797 if (*buf == ':')
798 buf++; // move past the ':' 798 buf++; // move past the ':'
799 799
@@ -881,7 +881,7 @@ static void colon(char *buf)
881 // don't edit, if the current file has been modified 881 // don't edit, if the current file has been modified
882 if (file_modified && !useforce) { 882 if (file_modified && !useforce) {
883 status_line_bold("No write since last change (:edit! overrides)"); 883 status_line_bold("No write since last change (:edit! overrides)");
884 goto vc1; 884 goto ret;
885 } 885 }
886 if (args[0]) { 886 if (args[0]) {
887 // the user supplied a file name 887 // the user supplied a file name
@@ -892,11 +892,11 @@ static void colon(char *buf)
892 } else { 892 } else {
893 // no user file name, no current name- punt 893 // no user file name, no current name- punt
894 status_line_bold("No current filename"); 894 status_line_bold("No current filename");
895 goto vc1; 895 goto ret;
896 } 896 }
897 897
898 if (init_text_buffer(fn) < 0) 898 if (init_text_buffer(fn) < 0)
899 goto vc1; 899 goto ret;
900 900
901#if ENABLE_FEATURE_VI_YANKMARK 901#if ENABLE_FEATURE_VI_YANKMARK
902 if (Ureg >= 0 && Ureg < 28 && reg[Ureg] != 0) { 902 if (Ureg >= 0 && Ureg < 28 && reg[Ureg] != 0) {
@@ -921,7 +921,7 @@ static void colon(char *buf)
921 } else if (strncmp(cmd, "file", i) == 0) { // what File is this 921 } else if (strncmp(cmd, "file", i) == 0) { // what File is this
922 if (b != -1 || e != -1) { 922 if (b != -1 || e != -1) {
923 status_line_bold("No address allowed on this command"); 923 status_line_bold("No address allowed on this command");
924 goto vc1; 924 goto ret;
925 } 925 }
926 if (args[0]) { 926 if (args[0]) {
927 // user wants a new filename 927 // user wants a new filename
@@ -967,11 +967,8 @@ static void colon(char *buf)
967 if (c_is_no_print) 967 if (c_is_no_print)
968 standout_end(); 968 standout_end();
969 } 969 }
970#if ENABLE_FEATURE_VI_SET
971 vc2:
972#endif
973 Hit_Return(); 970 Hit_Return();
974 } else if (strncmp(cmd, "quit", i) == 0 // Quit 971 } else if (strncmp(cmd, "quit", i) == 0 // quit
975 || strncmp(cmd, "next", i) == 0 // edit next file 972 || strncmp(cmd, "next", i) == 0 // edit next file
976 ) { 973 ) {
977 int n; 974 int n;
@@ -981,30 +978,30 @@ static void colon(char *buf)
981 optind = save_argc; 978 optind = save_argc;
982 } 979 }
983 editing = 0; 980 editing = 0;
984 goto vc1; 981 goto ret;
985 } 982 }
986 // don't exit if the file been modified 983 // don't exit if the file been modified
987 if (file_modified) { 984 if (file_modified) {
988 status_line_bold("No write since last change (:%s! overrides)", 985 status_line_bold("No write since last change (:%s! overrides)",
989 (*cmd == 'q' ? "quit" : "next")); 986 (*cmd == 'q' ? "quit" : "next"));
990 goto vc1; 987 goto ret;
991 } 988 }
992 // are there other file to edit 989 // are there other file to edit
993 n = save_argc - optind - 1; 990 n = save_argc - optind - 1;
994 if (*cmd == 'q' && n > 0) { 991 if (*cmd == 'q' && n > 0) {
995 status_line_bold("%d more file(s) to edit", n); 992 status_line_bold("%d more file(s) to edit", n);
996 goto vc1; 993 goto ret;
997 } 994 }
998 if (*cmd == 'n' && n <= 0) { 995 if (*cmd == 'n' && n <= 0) {
999 status_line_bold("No more files to edit"); 996 status_line_bold("No more files to edit");
1000 goto vc1; 997 goto ret;
1001 } 998 }
1002 editing = 0; 999 editing = 0;
1003 } else if (strncmp(cmd, "read", i) == 0) { // read file into text[] 1000 } else if (strncmp(cmd, "read", i) == 0) { // read file into text[]
1004 fn = args; 1001 fn = args;
1005 if (!fn[0]) { 1002 if (!fn[0]) {
1006 status_line_bold("No filename given"); 1003 status_line_bold("No filename given");
1007 goto vc1; 1004 goto ret;
1008 } 1005 }
1009 if (b < 0) { // no addr given- use defaults 1006 if (b < 0) { // no addr given- use defaults
1010 q = begin_line(dot); // assume "dot" 1007 q = begin_line(dot); // assume "dot"
@@ -1018,7 +1015,7 @@ static void colon(char *buf)
1018 q = text + ofs; 1015 q = text + ofs;
1019 } 1016 }
1020 if (ch < 0) 1017 if (ch < 0)
1021 goto vc1; // nothing was inserted 1018 goto ret; // nothing was inserted
1022 // how many lines in text[]? 1019 // how many lines in text[]?
1023 li = count_lines(q, q + ch - 1); 1020 li = count_lines(q, q + ch - 1);
1024 status_line("\"%s\"" 1021 status_line("\"%s\""
@@ -1049,25 +1046,21 @@ static void colon(char *buf)
1049 // only blank is regarded as args delmiter. What about tab '\t' ? 1046 // only blank is regarded as args delmiter. What about tab '\t' ?
1050 if (!args[0] || strcasecmp(args, "all") == 0) { 1047 if (!args[0] || strcasecmp(args, "all") == 0) {
1051 // print out values of all options 1048 // print out values of all options
1052 go_bottom_and_clear_to_eol();
1053 printf("----------------------------------------\r\n");
1054#if ENABLE_FEATURE_VI_SETOPTS 1049#if ENABLE_FEATURE_VI_SETOPTS
1055 if (!autoindent) 1050 status_line_bold(
1056 printf("no"); 1051 "%sautoindent "
1057 printf("autoindent "); 1052 "%sflash "
1058 if (!err_method) 1053 "%signorecase "
1059 printf("no"); 1054 "%sshowmatch "
1060 printf("flash "); 1055 "tabstop=%u",
1061 if (!ignorecase) 1056 autoindent ? "" : "no",
1062 printf("no"); 1057 err_method ? "" : "no",
1063 printf("ignorecase "); 1058 ignorecase ? "" : "no",
1064 if (!showmatch) 1059 showmatch ? "" : "no",
1065 printf("no"); 1060 tabstop
1066 printf("showmatch "); 1061 );
1067 printf("tabstop=%d ", tabstop); 1062#endif
1068#endif 1063 goto ret;
1069 printf("\r\n");
1070 goto vc2;
1071 } 1064 }
1072#if ENABLE_FEATURE_VI_SETOPTS 1065#if ENABLE_FEATURE_VI_SETOPTS
1073 argp = args; 1066 argp = args;
@@ -1075,19 +1068,17 @@ static void colon(char *buf)
1075 if (strncmp(argp, "no", 2) == 0) 1068 if (strncmp(argp, "no", 2) == 0)
1076 i = 2; // ":set noautoindent" 1069 i = 2; // ":set noautoindent"
1077 setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT); 1070 setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT);
1078 setops(argp, "flash ", i, "fl", VI_ERR_METHOD); 1071 setops(argp, "flash " , i, "fl", VI_ERR_METHOD);
1079 setops(argp, "ignorecase ", i, "ic", VI_IGNORECASE); 1072 setops(argp, "ignorecase ", i, "ic", VI_IGNORECASE);
1080 setops(argp, "showmatch ", i, "ic", VI_SHOWMATCH); 1073 setops(argp, "showmatch " , i, "sm", VI_SHOWMATCH );
1081 /* tabstopXXXX */ 1074 if (strncmp(argp + i, "tabstop=", 8) == 0) {
1082 if (strncmp(argp + i, "tabstop=%d ", 7) == 0) { 1075 int t = 0;
1083 sscanf(strchr(argp + i, '='), "tabstop=%d" + 7, &ch); 1076 sscanf(argp + i+8, "%u", &t);
1084 if (ch > 0 && ch <= MAX_TABSTOP) 1077 if (t > 0 && t <= MAX_TABSTOP)
1085 tabstop = ch; 1078 tabstop = t;
1086 } 1079 }
1087 while (*argp && *argp != ' ') 1080 argp = skip_non_whitespace(argp);
1088 argp++; // skip to arg delimiter (i.e. blank) 1081 argp = skip_whitespace(argp);
1089 while (*argp && *argp == ' ')
1090 argp++; // skip all delimiting blanks
1091 } 1082 }
1092#endif /* FEATURE_VI_SETOPTS */ 1083#endif /* FEATURE_VI_SETOPTS */
1093#endif /* FEATURE_VI_SET */ 1084#endif /* FEATURE_VI_SET */
@@ -1159,7 +1150,7 @@ static void colon(char *buf)
1159#if ENABLE_FEATURE_VI_READONLY 1150#if ENABLE_FEATURE_VI_READONLY
1160 if (readonly_mode && !useforce) { 1151 if (readonly_mode && !useforce) {
1161 status_line_bold("\"%s\" File is read only", fn); 1152 status_line_bold("\"%s\" File is read only", fn);
1162 goto vc3; 1153 goto ret;
1163 } 1154 }
1164#endif 1155#endif
1165 // how many lines in text[]? 1156 // how many lines in text[]?
@@ -1196,9 +1187,6 @@ static void colon(char *buf)
1196 editing = 0; 1187 editing = 0;
1197 } 1188 }
1198 } 1189 }
1199#if ENABLE_FEATURE_VI_READONLY
1200 vc3:;
1201#endif
1202#if ENABLE_FEATURE_VI_YANKMARK 1190#if ENABLE_FEATURE_VI_YANKMARK
1203 } else if (strncmp(cmd, "yank", i) == 0) { // yank lines 1191 } else if (strncmp(cmd, "yank", i) == 0) { // yank lines
1204 if (b < 0) { // no addr given- use defaults 1192 if (b < 0) { // no addr given- use defaults
@@ -1214,7 +1202,7 @@ static void colon(char *buf)
1214 // cmd unknown 1202 // cmd unknown
1215 not_implemented(cmd); 1203 not_implemented(cmd);
1216 } 1204 }
1217 vc1: 1205 ret:
1218 dot = bound_dot(dot); // make sure "dot" is valid 1206 dot = bound_dot(dot); // make sure "dot" is valid
1219 return; 1207 return;
1220#if ENABLE_FEATURE_VI_SEARCH 1208#if ENABLE_FEATURE_VI_SEARCH