From 695b5d37da8b7d6e17e1b4960101231edb775b50 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 19 Jul 2021 20:50:32 +0800 Subject: [PATCH] Tag most view mode incompatible functions in function names table. --- file.c | 14 +++++++---- line.c | 23 +++++++++++------ names.c | 56 ++++++++++++++++++++--------------------- random.c | 76 +++++++++++++++++++++++++++++++++++++------------------- region.c | 19 +++++++++----- search.c | 8 +++--- spawn.c | 6 +++-- word.c | 22 ++++++++++------ 8 files changed, 138 insertions(+), 86 deletions(-) diff --git a/file.c b/file.c index 323f3c6..fbdfe84 100644 --- a/file.c +++ b/file.c @@ -11,6 +11,7 @@ * modified by Petri Kutvonen */ +#include #include #include #include @@ -101,8 +102,9 @@ int insfile( int f, int n) { if( restflag) /* don't allow this command if restricted */ return resterr() ; - if( curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly() ; /* we are in read only mode */ +// if( curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly() ; /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; status = newmlarg( &fname, "Insert file: ", sizeof( fname_t)) ; if( status == TRUE) { @@ -119,7 +121,7 @@ int insfile( int f, int n) { /* * Select a file for editing. * Look around to see if you can find the - * fine in another buffer; if you can find it + * file in another buffer; if you can find it * just switch to the buffer. If you cannot find * the file, create a new buffer, read in the * text, and switch to the new buffer. @@ -476,8 +478,10 @@ int filewrite( int f, int n) { * get called by "C-Z". */ int filesave( int f, int n) { - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */ return TRUE; if (curbp->b_fname[0] == 0) { /* Must have a name. */ diff --git a/line.c b/line.c index 436d9a7..30bcb98 100644 --- a/line.c +++ b/line.c @@ -251,6 +251,7 @@ void lchange(int flag) */ int insspace(int f, int n) { + assert( !(curbp->b_mode & MDVIEW)) ; linsert(n, ' '); backchar(f, n); return TRUE; @@ -373,8 +374,9 @@ boolean linsert_byte( int n, int c) { int linsert( int n, unicode_t c) { assert( n >= 0) ; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; if( n > 0) { char utf8[ 4] ; @@ -453,8 +455,10 @@ int lnewline(void) int doto; struct window *wp; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + #if SCROLLCODE lchange(WFHARD | WFINS); #else @@ -540,8 +544,9 @@ boolean ldelete( long n, boolean kflag) { int chunk; struct window *wp; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; while( n > 0) { dotp = curwp->w_dotp; @@ -792,8 +797,10 @@ int yank(int f, int n) char *sp; /* pointer into string to insert */ struct kill *kp; /* pointer into kill buffer */ - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + if (n < 0) return FALSE; /* make sure there is something to yank */ diff --git a/names.c b/names.c index 6530670..85d7ffe 100644 --- a/names.c +++ b/names.c @@ -38,11 +38,11 @@ const name_bind names[] = { {"beginning-of-line", (fnp_t) gotobol, 0} , {"bind-to-key", bindtokey, 0} , {"buffer-position", showcpos, 0} , - {"case-region-lower", lowerregion, 0} , - {"case-region-upper", upperregion, 0} , - {"case-word-capitalize", capword, 0} , - {"case-word-lower", lowerword, 0} , - {"case-word-upper", upperword, 0} , + {"case-region-lower", lowerregion, 1} , + {"case-region-upper", upperregion, 1} , + {"case-word-capitalize", capword, 1} , + {"case-word-lower", lowerword, 1} , + {"case-word-upper", upperword, 1} , {"change-file-name", filename, 0} , {"change-screen-size", newsize, 0} , {"change-screen-width", newwidth, 0} , @@ -53,26 +53,26 @@ const name_bind names[] = { {"count-words", wordcount, 0} , #endif {"ctlx-prefix", cex, 0} , - {"delete-blank-lines", deblank, 0} , + {"delete-blank-lines", deblank, 1} , {"delete-buffer", killbuffer, 0} , {"delete-mode", delmode, 0} , {"delete-global-mode", delgmode, 0} , - {"delete-next-character", forwdel, 0} , - {"delete-next-word", delfword, 0} , + {"delete-next-character", forwdel, 1} , + {"delete-next-word", delfword, 1} , {"delete-other-windows", onlywind, 0} , - {"delete-previous-character", backdel, 0} , - {"delete-previous-word", delbword, 0} , + {"delete-previous-character", backdel, 1} , + {"delete-previous-word", delbword, 1} , {"delete-window", delwind, 0} , {"describe-bindings", desbind, 0} , {"describe-key", deskey, 0} , #if AEDIT - {"detab-line", detab, 0} , + {"detab-line", detab, 1} , #endif {"end-macro", ctlxrp, 0} , {"end-of-file", (fnp_t) gotoeob, 0} , {"end-of-line", (fnp_t) gotoeol, 0} , #if AEDIT - {"entab-line", entab, 0} , + {"entab-line", entab, 1} , #endif {"exchange-point-and-mark", (fnp_t) swapmark, 0} , {"execute-buffer", execbuf, 0} , @@ -128,7 +128,7 @@ const name_bind names[] = { #if WORDPRO {"fill-paragraph", fillpara, 1} , #endif - {"filter-buffer", filter_buffer, 0} , + {"filter-buffer", filter_buffer, 1} , {"find-file", filefind, 0} , {"forward-character", (fnp_t) forwchar, 0} , {"goto-line", gotoline, 0} , @@ -144,8 +144,8 @@ const name_bind names[] = { #if ISRCH {"incremental-search", fisearch, 0} , #endif - {"insert-file", insfile, 0} , - {"insert-space", insspace, 0} , + {"insert-file", insfile, 1} , + {"insert-space", insspace, 1} , {"insert-string", istring, 1} , #if WORDPRO #if PKCODE @@ -153,15 +153,15 @@ const name_bind names[] = { #endif {"kill-paragraph", killpara, 1} , #endif - {"kill-region", killregion, 0} , - {"kill-to-end-of-line", killtext, 0} , + {"kill-region", killregion, 1} , + {"kill-to-end-of-line", killtext, 1} , {"list-buffers", listbuffers, 0} , {"meta-prefix", metafn, 0} , {"move-window-down", mvdnwind, 0} , {"move-window-up", mvupwind, 0} , {"name-buffer", namebuffer, 0} , - {"newline", insert_newline, 0} , - {"newline-and-indent", indent, 0} , + {"newline", insert_newline, 1} , + {"newline-and-indent", indent, 1} , {"next-buffer", nextbuffer, 0} , {"next-line", (fnp_t) forwline, 0} , {"next-page", (fnp_t) forwpage, 0} , @@ -171,7 +171,7 @@ const name_bind names[] = { {"next-window", nextwind, 0} , {"next-word", forwword, 0} , {"nop", nullproc, 0} , - {"open-line", openline, 0} , + {"open-line", openline, 1} , {"overwrite-string", ovstring, 0} , {"pipe-command", pipecmd, 0} , {"previous-line", (fnp_t) backline, 0} , @@ -181,21 +181,21 @@ const name_bind names[] = { #endif {"previous-window", prevwind, 0} , {"previous-word", backword, 0} , - {"query-replace-string", qreplace, 0} , + {"query-replace-string", qreplace, 1} , {"quick-exit", quickexit, 0} , - {"quote-character", quote, 0} , - {"read-file", fileread, 0} , + {"quote-character", quote, 1} , + {"read-file", fileread, 1} , {"redraw-display", reposition, 0} , {"resize-window", resize, 0} , {"restore-window", restwnd, 0} , - {"replace-string", sreplace, 0} , + {"replace-string", sreplace, 1} , #if ISRCH {"reverse-incremental-search", risearch, 0} , #endif #if PROC {"run", execproc, 0} , #endif - {"save-file", filesave, 0} , + {"save-file", filesave, 1} , {"save-window", savewnd, 0} , {"scroll-next-up", scrnextup, 0} , {"scroll-next-down", scrnextdw, 0} , @@ -215,9 +215,9 @@ const name_bind names[] = { #if BSD | SVR4 {"suspend-emacs", bktoshell, 0} , #endif - {"transpose-characters", (fnp_t) twiddle, 0} , + {"transpose-characters", (fnp_t) twiddle, 1} , #if AEDIT - {"trim-line", trim, 0} , + {"trim-line", trim, 1} , #endif {"unbind-key", unbindkey, 0} , {"universal-argument", unarg, 0} , @@ -227,7 +227,7 @@ const name_bind names[] = { {"wrap-word", wrapword, 0} , {"write-file", filewrite, 0} , {"write-message", writemsg, 0} , - {"yank", yank, 0} , + {"yank", yank, 1} , {"", NULL, 0} }; diff --git a/random.c b/random.c index e8d8def..957a785 100644 --- a/random.c +++ b/random.c @@ -9,6 +9,7 @@ * Modified by Petri Kutvonen */ +#include #include #include #include @@ -226,8 +227,9 @@ boolean twiddle( int f, int n) { int len ; boolean eof_f = FALSE ; - if( curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly() ; /* we are in read only mode */ +// if( curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly() ; /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; len = llength( curwp->w_dotp) ; if( len < 2 || curwp->w_doto == 0) /* at least 2 chars & not bol */ @@ -261,11 +263,13 @@ boolean twiddle( int f, int n) { */ int quote(int f, int n) { - int c; +// int c; +// +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ - c = tgetc(); + int c = tgetc(); if (n < 0) return FALSE; if (n == 0) @@ -315,8 +319,10 @@ int detab(int f, int n) { int inc; /* increment to next line [sgn(n)] */ - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + + assert( !(curbp->b_mode & MDVIEW)) ; if (f == FALSE) n = 1; @@ -363,8 +369,10 @@ int entab(int f, int n) int inc; /* increment to next line [sgn(n)] */ - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + + assert( !(curbp->b_mode & MDVIEW)) ; if (f == FALSE) n = 1; @@ -436,8 +444,10 @@ int trim(int f, int n) { int inc; /* increment to next line [sgn(n)] */ - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + + assert( !(curbp->b_mode & MDVIEW)) ; if (f == FALSE) n = 1; @@ -483,8 +493,10 @@ int openline(int f, int n) int i; int s; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + if (n < 0) return FALSE; if (n == 0) @@ -504,8 +516,10 @@ int openline(int f, int n) */ int insert_newline(int f, int n) { - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + if (n < 0) return FALSE; @@ -610,8 +624,10 @@ int deblank(int f, int n) struct line *lp2; long nld; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + lp1 = curwp->w_dotp; while (llength(lp1) == 0 && (lp2 = lback(lp1)) != curbp->b_linep) lp1 = lp2; @@ -638,8 +654,10 @@ int indent( int f, int n) { int nicol ; int i ; - if( curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly() ; /* we are in read only mode */ +// if( curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly() ; /* we are in read only mode */ + + assert( !(curbp->b_mode & MDVIEW)) ; if( n < 0) return FALSE ; @@ -676,8 +694,10 @@ int indent( int f, int n) { * of text if typed with a big argument. Normally bound to "C-D". */ int forwdel( int f, int n) { - if( curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly() ; /* we are in read only mode */ +// if( curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly() ; /* we are in read only mode */ + + assert( !(curbp->b_mode & MDVIEW)) ; if( n == 0) return TRUE ; @@ -700,8 +720,10 @@ int forwdel( int f, int n) { * both "RUBOUT" and "C-H". */ int backdel( int f, int n) { - if( curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly() ; /* we are in read only mode */ +// if( curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly() ; /* we are in read only mode */ + + assert( !(curbp->b_mode & MDVIEW)) ; if( n == 0) return TRUE ; @@ -730,8 +752,10 @@ int killtext(int f, int n) struct line *nextp; long chunk; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */ kdelete(); /* last wasn't a kill. */ thisflag |= CFKILL; diff --git a/region.c b/region.c index de6c164..fcf5d71 100644 --- a/region.c +++ b/region.c @@ -10,6 +10,7 @@ * Modified by Petri Kutvonen */ +#include #include #include "buffer.h" @@ -30,8 +31,10 @@ int killregion(int f, int n) int s; struct region region; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + if ((s = getregion(®ion)) != TRUE) return s; if ((lastflag & CFKILL) == 0) /* This is a kill type */ @@ -94,8 +97,10 @@ int lowerregion(int f, int n) int s; struct region region; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + if ((s = getregion(®ion)) != TRUE) return s; lchange(WFHARD); @@ -131,8 +136,10 @@ int upperregion(int f, int n) int s; struct region region; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; + if ((s = getregion(®ion)) != TRUE) return s; lchange(WFHARD); diff --git a/search.c b/search.c index 6aa13ef..029becf 100644 --- a/search.c +++ b/search.c @@ -60,6 +60,7 @@ * Modified by Petri Kutvonen */ +#include #include #include #include @@ -832,12 +833,13 @@ static int replaces(int kind, int f, int n) struct line *lastline; /* position of last replace and */ int lastoff; /* offset (for 'u' query option) */ -/* rfi */ +///* rfi */ lastline = NULL ; lastoff = 0 ; - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly(); /* we are in read only mode */ +// if (curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly(); /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; /* Check for negative repetitions. */ diff --git a/spawn.c b/spawn.c index 30ccc69..a073159 100644 --- a/spawn.c +++ b/spawn.c @@ -8,6 +8,7 @@ * Modified by Petri Kutvonen */ +#include #include #include #include @@ -289,8 +290,9 @@ int filter_buffer( int f, int n) { if( restflag) return resterr() ; - if( curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly() ; /* we are in read only mode */ +// if( curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly() ; /* we are in read only mode */ + assert( !(curbp->b_mode & MDVIEW)) ; /* get the filter name and its args */ s = newmlarg( &mlarg, "#", 0) ; diff --git a/word.c b/word.c index 8f1d83c..52f2e0e 100644 --- a/word.c +++ b/word.c @@ -152,8 +152,10 @@ static boolean uniflip( boolean toupper_f) { /* flip unicode case and forward */ } static boolean capcapword( int n, boolean first_f, boolean rest_f) { - if( curbp->b_mode & MDVIEW) /* don't allow this command if */ - return rdonly() ; /* we are in read only mode */ +// if( curbp->b_mode & MDVIEW) /* don't allow this command if */ +// return rdonly() ; /* we are in read only mode */ + + assert( !(curbp->b_mode & MDVIEW)) ; if( n < 0) return FALSE ; @@ -213,9 +215,11 @@ int delfword(int f, int n) int c; /* temp char */ long size; /* # of chars to delete */ - /* don't allow this command if we are in read only mode */ - if (curbp->b_mode & MDVIEW) - return rdonly(); +// /* don't allow this command if we are in read only mode */ +// if (curbp->b_mode & MDVIEW) +// return rdonly(); + + assert( !(curbp->b_mode & MDVIEW)) ; /* ignore the command if there is a negative argument */ if (n < 0) @@ -299,9 +303,11 @@ int delbword(int f, int n) { long size; - /* don't allow this command if we are in read only mode */ - if (curbp->b_mode & MDVIEW) - return rdonly(); +// /* don't allow this command if we are in read only mode */ +// if (curbp->b_mode & MDVIEW) +// return rdonly(); + + assert( !(curbp->b_mode & MDVIEW)) ; /* ignore the command if there is a nonpositive argument */ if (n <= 0)