aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/vi.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 852e16340..a187c6dd0 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21static const char vi_Version[] = 21static const char vi_Version[] =
22 "$Id: vi.c,v 1.19 2001/11/17 07:14:06 andersen Exp $"; 22 "$Id: vi.c,v 1.20 2001/12/20 23:12:47 kraai Exp $";
23 23
24/* 24/*
25 * To compile for standalone use: 25 * To compile for standalone use:
@@ -1219,7 +1219,7 @@ key_cmd_mode:
1219 break; 1219 break;
1220 if (strncasecmp((char *) p, "quit", cnt) == 0 || 1220 if (strncasecmp((char *) p, "quit", cnt) == 0 ||
1221 strncasecmp((char *) p, "q!", cnt) == 0) { // delete lines 1221 strncasecmp((char *) p, "q!", cnt) == 0) { // delete lines
1222 if (file_modified == TRUE && p[1] != '!') { 1222 if (file_modified && p[1] != '!') {
1223 psbs("No write since last change (:quit! overrides)"); 1223 psbs("No write since last change (:quit! overrides)");
1224 } else { 1224 } else {
1225 editing = 0; 1225 editing = 0;
@@ -1410,10 +1410,10 @@ key_cmd_mode:
1410 indicate_error(c); 1410 indicate_error(c);
1411 break; 1411 break;
1412 } 1412 }
1413 if (file_modified == TRUE 1413 if (file_modified
1414#ifdef CONFIG_FEATURE_VI_READONLY 1414#ifdef CONFIG_FEATURE_VI_READONLY
1415 && vi_readonly == FALSE 1415 && ! vi_readonly
1416 && readonly == FALSE 1416 && ! readonly
1417#endif /* CONFIG_FEATURE_VI_READONLY */ 1417#endif /* CONFIG_FEATURE_VI_READONLY */
1418 ) { 1418 ) {
1419 cnt = file_write(cfn, text, end - 1); 1419 cnt = file_write(cfn, text, end - 1);
@@ -1829,7 +1829,7 @@ static void colon(Byte * buf)
1829 int sr; 1829 int sr;
1830 sr= 0; 1830 sr= 0;
1831 // don't edit, if the current file has been modified 1831 // don't edit, if the current file has been modified
1832 if (file_modified == TRUE && useforce != TRUE) { 1832 if (file_modified && ! useforce) {
1833 psbs("No write since last change (:edit! overrides)"); 1833 psbs("No write since last change (:edit! overrides)");
1834 goto vc1; 1834 goto vc1;
1835 } 1835 }
@@ -1908,7 +1908,7 @@ static void colon(Byte * buf)
1908 " %dL, %dC", cfn, 1908 " %dL, %dC", cfn,
1909 (sr < 0 ? " [New file]" : ""), 1909 (sr < 0 ? " [New file]" : ""),
1910#ifdef CONFIG_FEATURE_VI_READONLY 1910#ifdef CONFIG_FEATURE_VI_READONLY
1911 ((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""), 1911 ((vi_readonly || readonly) ? " [Read only]" : ""),
1912#endif /* CONFIG_FEATURE_VI_READONLY */ 1912#endif /* CONFIG_FEATURE_VI_READONLY */
1913 li, ch); 1913 li, ch);
1914 } else if (strncasecmp((char *) cmd, "file", i) == 0) { // what File is this 1914 } else if (strncasecmp((char *) cmd, "file", i) == 0) { // what File is this
@@ -1961,7 +1961,7 @@ static void colon(Byte * buf)
1961 Hit_Return(); 1961 Hit_Return();
1962 } else if ((strncasecmp((char *) cmd, "quit", i) == 0) || // Quit 1962 } else if ((strncasecmp((char *) cmd, "quit", i) == 0) || // Quit
1963 (strncasecmp((char *) cmd, "next", i) == 0)) { // edit next file 1963 (strncasecmp((char *) cmd, "next", i) == 0)) { // edit next file
1964 if (useforce == TRUE) { 1964 if (useforce) {
1965 // force end of argv list 1965 // force end of argv list
1966 if (*cmd == 'q') { 1966 if (*cmd == 'q') {
1967 optind = save_argc; 1967 optind = save_argc;
@@ -1970,7 +1970,7 @@ static void colon(Byte * buf)
1970 goto vc1; 1970 goto vc1;
1971 } 1971 }
1972 // don't exit if the file been modified 1972 // don't exit if the file been modified
1973 if (file_modified == TRUE) { 1973 if (file_modified) {
1974 psbs("No write since last change (:%s! overrides)", 1974 psbs("No write since last change (:%s! overrides)",
1975 (*cmd == 'q' ? "quit" : "next")); 1975 (*cmd == 'q' ? "quit" : "next"));
1976 goto vc1; 1976 goto vc1;
@@ -2014,7 +2014,7 @@ static void colon(Byte * buf)
2014#endif /* CONFIG_FEATURE_VI_READONLY */ 2014#endif /* CONFIG_FEATURE_VI_READONLY */
2015 " %dL, %dC", fn, 2015 " %dL, %dC", fn,
2016#ifdef CONFIG_FEATURE_VI_READONLY 2016#ifdef CONFIG_FEATURE_VI_READONLY
2017 ((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""), 2017 ((vi_readonly || readonly) ? " [Read only]" : ""),
2018#endif /* CONFIG_FEATURE_VI_READONLY */ 2018#endif /* CONFIG_FEATURE_VI_READONLY */
2019 li, ch); 2019 li, ch);
2020 if (ch > 0) { 2020 if (ch > 0) {
@@ -2024,7 +2024,7 @@ static void colon(Byte * buf)
2024 file_modified = TRUE; 2024 file_modified = TRUE;
2025 } 2025 }
2026 } else if (strncasecmp((char *) cmd, "rewind", i) == 0) { // rewind cmd line args 2026 } else if (strncasecmp((char *) cmd, "rewind", i) == 0) { // rewind cmd line args
2027 if (file_modified == TRUE && useforce != TRUE) { 2027 if (file_modified && ! useforce) {
2028 psbs("No write since last change (:rewind! overrides)"); 2028 psbs("No write since last change (:rewind! overrides)");
2029 } else { 2029 } else {
2030 // reset the filenames to edit 2030 // reset the filenames to edit
@@ -2140,7 +2140,7 @@ static void colon(Byte * buf)
2140 fn = args; 2140 fn = args;
2141 } 2141 }
2142#ifdef CONFIG_FEATURE_VI_READONLY 2142#ifdef CONFIG_FEATURE_VI_READONLY
2143 if ((vi_readonly == TRUE || readonly == TRUE) && useforce == FALSE) { 2143 if ((vi_readonly || readonly) && ! useforce) {
2144 psbs("\"%s\" File is read only", fn); 2144 psbs("\"%s\" File is read only", fn);
2145 goto vc3; 2145 goto vc3;
2146 } 2146 }
@@ -2149,14 +2149,14 @@ static void colon(Byte * buf)
2149 li = count_lines(q, r); 2149 li = count_lines(q, r);
2150 ch = r - q + 1; 2150 ch = r - q + 1;
2151 // see if file exists- if not, its just a new file request 2151 // see if file exists- if not, its just a new file request
2152 if (useforce == TRUE) { 2152 if (useforce) {
2153 // if "fn" is not write-able, chmod u+w 2153 // if "fn" is not write-able, chmod u+w
2154 // sprintf(syscmd, "chmod u+w %s", fn); 2154 // sprintf(syscmd, "chmod u+w %s", fn);
2155 // system(syscmd); 2155 // system(syscmd);
2156 forced = TRUE; 2156 forced = TRUE;
2157 } 2157 }
2158 l = file_write(fn, q, r); 2158 l = file_write(fn, q, r);
2159 if (useforce == TRUE && forced == TRUE) { 2159 if (useforce && forced) {
2160 // chmod u-w 2160 // chmod u-w
2161 // sprintf(syscmd, "chmod u-w %s", fn); 2161 // sprintf(syscmd, "chmod u-w %s", fn);
2162 // system(syscmd); 2162 // system(syscmd);
@@ -3527,7 +3527,7 @@ static int file_insert(Byte * fn, Byte * p, int size)
3527 3527
3528 // see if we can open the file 3528 // see if we can open the file
3529#ifdef CONFIG_FEATURE_VI_READONLY 3529#ifdef CONFIG_FEATURE_VI_READONLY
3530 if (vi_readonly == TRUE) goto fi1; // do not try write-mode 3530 if (vi_readonly) goto fi1; // do not try write-mode
3531#endif 3531#endif
3532 fd = open((char *) fn, O_RDWR); // assume read & write 3532 fd = open((char *) fn, O_RDWR); // assume read & write
3533 if (fd < 0) { 3533 if (fd < 0) {
@@ -3623,7 +3623,7 @@ static void place_cursor(int row, int col, int opti)
3623 //----- 1. Try the standard terminal ESC sequence 3623 //----- 1. Try the standard terminal ESC sequence
3624 sprintf((char *) cm1, CMrc, row + 1, col + 1); 3624 sprintf((char *) cm1, CMrc, row + 1, col + 1);
3625 cm= cm1; 3625 cm= cm1;
3626 if (opti == FALSE) goto pc0; 3626 if (! opti) goto pc0;
3627 3627
3628#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR 3628#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
3629 //----- find the minimum # of chars to move cursor ------------- 3629 //----- find the minimum # of chars to move cursor -------------
@@ -3798,9 +3798,9 @@ static void edit_status(void) // show file status on status line
3798 "%s line %d of %d --%d%%--", 3798 "%s line %d of %d --%d%%--",
3799 (cfn != 0 ? (char *) cfn : "No file"), 3799 (cfn != 0 ? (char *) cfn : "No file"),
3800#ifdef CONFIG_FEATURE_VI_READONLY 3800#ifdef CONFIG_FEATURE_VI_READONLY
3801 ((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""), 3801 ((vi_readonly || readonly) ? " [Read only]" : ""),
3802#endif /* CONFIG_FEATURE_VI_READONLY */ 3802#endif /* CONFIG_FEATURE_VI_READONLY */
3803 (file_modified == TRUE ? " [modified]" : ""), 3803 (file_modified ? " [modified]" : ""),
3804 cur, tot, percent); 3804 cur, tot, percent);
3805} 3805}
3806 3806
@@ -3888,7 +3888,7 @@ static void refresh(int full_screen)
3888 cs= 0; 3888 cs= 0;
3889 ce= columns-1; 3889 ce= columns-1;
3890 sp = &screen[li * columns]; // start of screen line 3890 sp = &screen[li * columns]; // start of screen line
3891 if (full_screen == TRUE) { 3891 if (full_screen) {
3892 // force re-draw of every single column from 0 - columns-1 3892 // force re-draw of every single column from 0 - columns-1
3893 goto re0; 3893 goto re0;
3894 } 3894 }
@@ -3921,7 +3921,7 @@ static void refresh(int full_screen)
3921 if (ce > columns-1) ce= columns-1; 3921 if (ce > columns-1) ce= columns-1;
3922 if (cs > ce) { cs= 0; ce= columns-1; } 3922 if (cs > ce) { cs= 0; ce= columns-1; }
3923 // is there a change between vitual screen and buf 3923 // is there a change between vitual screen and buf
3924 if (changed == TRUE) { 3924 if (changed) {
3925 // copy changed part of buffer to virtual screen 3925 // copy changed part of buffer to virtual screen
3926 memmove(sp+cs, buf+(cs+offset), ce-cs+1); 3926 memmove(sp+cs, buf+(cs+offset), ce-cs+1);
3927 3927