# vile 9.4f - patch 2004/4/11 - T.Dickey # ------------------------------------------------------------------------------ # CHANGES | 49 ++ # MANIFEST | 2 # csrch.c | 251 ++++++------ # doc/macros.doc | 20 - # doc/modes.doc | 12 # eval.c | 15 # exec.c | 17 # filters/filters.rc | 153 ++++--- # filters/makefile.in | 3 # filters/makelist.sh | 4 # filters/pas-filt.l | 3 # globals.c | 193 ++++----- # main.c | 4 # makefile.in | 5 # map.c | 988 ++++++++++++++++++++++++-------------------------- # modes.c | 93 +++- # modetbl | 10 # ntwinio.c | 4 # oneliner.c | 5 # patchlev.h | 2 # perl.xs | 9 # revlist | 50 +- # vile-9.4.spec | 14 # vile.hlp | 399 +++++++++++++++----- # wordmov.c | 628 +++++++++++++++++-------------- # 25 files changed, 1671 insertions(+), 1262 deletions(-) # ------------------------------------------------------------------------------ Index: CHANGES --- vile-9.4e+/CHANGES 2004-03-21 18:30:55.000000000 -0500 +++ vile-9.4f/CHANGES 2004-04-11 20:13:30.000000000 -0400 @@ -1,5 +1,54 @@ Changes for vile 9.5 (released ??? ??? ?? ????) + 20040411 (f) + > Clark Morgan: + + modify vilemode, adding "sections" expression. + + vile.hlp changes: + + modify syntax coloring topic to remove prerequisites that refer to + features from long, long ago ("nocmode" and old copies of c syntax + coloring files) that most users won't remember or encounter. + + revamped "Editor modes" section, in particular, moving discussion + of majormodes to a point in the help file that directly follows + syntax coloring. + + added mode flavor tags (B, U, W, M) to modes that lacked same. + + documented that "suffixes" is tested against a filename's complete + path. + + stripped c-tabstop from vile startup example. + + explicitly emphasized ignoresuffix's behavior. + + for cindent, tabstop and shiftwidth modes, documented cmode's + default local mode values. + + added a "Majormodes" section. Added a subsection entitled + "cmode: the original vile builtin majormode" + > Tom Dickey: + + indent'd csrch.c, globals.c, map.c, wordmov.c + + modify logic for RS_AUTO to treat it consistently as the "default" + keyword for record separator (report by Clark Morgan). + + remove an unnecessary message from makelist.sh (report by Clark + Morgan). + + modify mac_tokval() to avoid calling tb_scopy() if the result from + tokval() is the original pointer plus one (for stripping a leading + quote), fixes an overlapping memcpy warning from valgrind. + + correct logic in test_by_suffix(), which was not obtaining the + submode value for "ignoresuffix" as intended (discussion with Clark + Morgan). + + modify comparison for maplength to use at least 25. Very small + values make vile unusable (report by Clark Morgan). + + revert part of the initialization in substreg1() so the replacement + pattern is reset rather than copied (report by Brendan O'Dea, 9.3n). + + make "TODO" a txtmode file. + + add ".shar" to shmode suffixes. + + add "&match" and "&cmatch" functions for checking if a given regular + expression matches a string (request by Clark Morgan). + + split up the majormode "suffixes" into suffixes, mode-filename and + mode-pathname to make it clearer how to associated regular + expressions with the filename for majormodes (discussion with Clark + Morgan). + + remove explicit assignment to DESTDIR in makefile.in's, since newer + GNU make program does not allow command-line to override it (it + apparently did work with some version of GNU make in 1999 for 8.3i). + + correct logic in perl.xs from 9.4d which parses $VILE_LIBDIR_PATH; + it used the wrong variable for storing an intermediate result. + 20040321 (e) > Clark Morgan: + document set-highlighting macro in vile.hlp Index: MANIFEST --- vile-9.4e+/MANIFEST 2004-03-21 20:42:42.000000000 -0500 +++ vile-9.4f/MANIFEST 2004-04-11 20:45:53.000000000 -0400 @@ -1,4 +1,4 @@ -MANIFEST for vile, version v9_4e +MANIFEST for vile, version v9_4f -------------------------------------------------------------------------------- MANIFEST this file CHANGES Change-log for VILE Index: csrch.c Prereq: 1.31 --- vile-9.4e+/csrch.c 2002-08-27 18:40:15.000000000 -0400 +++ vile-9.4f/csrch.c 2004-04-11 19:23:13.000000000 -0400 @@ -2,7 +2,7 @@ * These functions perform vi's on-this-line character scanning functions. * written for vile: Copyright (c) 1990, 1995-2002 by Paul Fox * - * $Header: /usr/build/vile/vile/RCS/csrch.c,v 1.31 2002/08/27 22:40:15 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/csrch.c,v 1.32 2004/04/11 23:23:13 tom Exp $ * */ @@ -10,194 +10,197 @@ #include "edef.h" static USHORT lstscan; -static int lstchar; -#define BACK 0 -#define FORW 1 -#define DIREC 1 - -#define F 0 -#define T 2 -#define TYPE 2 +static int lstchar; + +#define BACK 0 +#define FORW 1 +#define DIREC 1 + +#define F 0 +#define T 2 +#define TYPE 2 static int fscan(int f, int n, int c) { - int i; - int doto; + int i; + int doto; - if (!f || n <= 0) - n = 1; + if (!f || n <= 0) + n = 1; - lstchar = c; - lstscan = FORW; + lstchar = c; + lstscan = FORW; - doto = DOT.o; - - i = doto+1; - while(i < llength(DOT.l)) { - if ( c == lgetc(DOT.l,i)) { - doto = i; - n--; - if (!n) break; - } - i++; - } - - if ( i >= llength(DOT.l)) { - return(FALSE); - } - if (doingopcmd && !doingsweep) - doto++; - else if (doingsweep) - sweephack = TRUE; - - DOT.o = doto; - curwp->w_flag |= WFMOVE; - return(TRUE); + doto = DOT.o; + + i = doto + 1; + while (i < llength(DOT.l)) { + if (c == lgetc(DOT.l, i)) { + doto = i; + n--; + if (!n) + break; + } + i++; + } + + if (i >= llength(DOT.l)) { + return (FALSE); + } + if (doingopcmd && !doingsweep) + doto++; + else if (doingsweep) + sweephack = TRUE; + + DOT.o = doto; + curwp->w_flag |= WFMOVE; + return (TRUE); } static int bscan(int f, int n, int c) { - int i; - int doto; + int i; + int doto; - if (!f || n <= 0) - n = 1; + if (!f || n <= 0) + n = 1; - lstchar = c; - lstscan = BACK; + lstchar = c; + lstscan = BACK; - doto = DOT.o; - - i = doto-1; - while(i >= w_left_margin(curwp)) { - if ( c == lgetc(DOT.l,i)) { - doto = i; - n--; - if (!n) break; - } - i--; - } - - if ( i < w_left_margin(curwp) ) { - return(FALSE); - } - - DOT.o = doto; - curwp->w_flag |= WFMOVE; - return(TRUE); + doto = DOT.o; + + i = doto - 1; + while (i >= w_left_margin(curwp)) { + if (c == lgetc(DOT.l, i)) { + doto = i; + n--; + if (!n) + break; + } + i--; + } + + if (i < w_left_margin(curwp)) { + return (FALSE); + } + + DOT.o = doto; + curwp->w_flag |= WFMOVE; + return (TRUE); } static int get_csrch_char(int *cp) { - int c; + int c; - if (clexec || isnamedcmd) { - int status; - static char cbuf[2]; - if ((status=mlreply("Scan for: ", cbuf, 2)) != TRUE) - return status; - c = cbuf[0]; - } else { - c = keystroke(); - if (c == quotec) - c = keystroke_raw8(); - else if (ABORTED(c)) - return FALSE; - } + if (clexec || isnamedcmd) { + int status; + static char cbuf[2]; + if ((status = mlreply("Scan for: ", cbuf, 2)) != TRUE) + return status; + c = cbuf[0]; + } else { + c = keystroke(); + if (c == quotec) + c = keystroke_raw8(); + else if (ABORTED(c)) + return FALSE; + } - *cp = c; - return TRUE; + *cp = c; + return TRUE; } /* f */ int fcsrch(int f, int n) { - int c, s; + int c, s; - s = get_csrch_char(&c); - if (s != TRUE) - return s; + s = get_csrch_char(&c); + if (s != TRUE) + return s; - return(fscan(f,n,c)); + return (fscan(f, n, c)); } /* F */ int bcsrch(int f, int n) { - int c, s; + int c, s; - s = get_csrch_char(&c); - if (s != TRUE) - return s; + s = get_csrch_char(&c); + if (s != TRUE) + return s; - return(bscan(f,n,c)); + return (bscan(f, n, c)); } /* t */ int fcsrch_to(int f, int n) { - int s; - s = fcsrch(f,n); - if (s == TRUE) - s = backchar(FALSE,1); - lstscan |= T; - return(s); + int s; + s = fcsrch(f, n); + if (s == TRUE) + s = backchar(FALSE, 1); + lstscan |= T; + return (s); } /* T */ int bcsrch_to(int f, int n) { - int s; - s = bcsrch(f,n); - if (s == TRUE) - s = forwchar(FALSE,1); - lstscan |= T; - return(s); + int s; + s = bcsrch(f, n); + if (s == TRUE) + s = forwchar(FALSE, 1); + lstscan |= T; + return (s); } /* ; */ int rep_csrch(int f, int n) { - int s; - USHORT ls = lstscan; + int s; + USHORT ls = lstscan; - if ((ls & DIREC) == FORW) { - s = fscan(f,n,lstchar); - if ((ls & TYPE) == T) { - if (s == TRUE) - s = backchar(FALSE,1); - lstscan |= T; - } - return(s); - } else { - s = bscan(f,n,lstchar); - if ((ls & TYPE) == T) { - if (s == TRUE) - s = forwchar(FALSE,1); - lstscan |= T; - } - return(s); + if ((ls & DIREC) == FORW) { + s = fscan(f, n, lstchar); + if ((ls & TYPE) == T) { + if (s == TRUE) + s = backchar(FALSE, 1); + lstscan |= T; + } + return (s); + } else { + s = bscan(f, n, lstchar); + if ((ls & TYPE) == T) { + if (s == TRUE) + s = forwchar(FALSE, 1); + lstscan |= T; } + return (s); + } } /* , */ int rev_csrch(int f, int n) { - int s; + int s; - lstscan ^= DIREC; - s = rep_csrch(f,n); - lstscan ^= DIREC; - return(s); + lstscan ^= DIREC; + s = rep_csrch(f, n); + lstscan ^= DIREC; + return (s); } Index: doc/macros.doc Prereq: 1.89 --- vile-9.4e+/doc/macros.doc 2003-05-05 17:56:12.000000000 -0400 +++ vile-9.4f/doc/macros.doc 2004-04-11 13:20:38.000000000 -0400 @@ -830,14 +830,20 @@ &writable "S" Is the named file "S" writable? &execable "S" Is the named file "S" exec'able? - &filter "M" Does the given majormode have a built-in - highlighting filter? + &cmatch "R" "V" Does the given regular expression "R" + match the value "V" (ignoring case)? + + &error "S" Was the string set with the ERROR token? + For example, a &query that is aborted + will return an ERROR result. - &error "S" Was the string set with the ERROR token? - For example, a &query that is aborted - will return an ERROR result. + &match "R" "V" Does the given regular expression "R" + match the value "V"? + + &filter "M" Does the given majormode have a built-in + highlighting filter? - &stoken "T" "D" "S" Is token "T" in string "S", given + &stoken "T" "D" "S" Is token "T" in string "S", given delimiters "D"? @@ -1450,6 +1456,6 @@ ========================= end vile.rc ======================= ----------------------------------- - $Header: /usr/build/vile/vile/doc/RCS/macros.doc,v 1.89 2003/05/05 21:56:12 tom Exp $ + $Header: /usr/build/vile/vile/doc/RCS/macros.doc,v 1.91 2004/04/11 17:20:38 tom Exp $ ----------------------------------- Index: doc/modes.doc Prereq: 1.13 --- vile-9.4e+/doc/modes.doc 2004-03-18 15:47:56.000000000 -0500 +++ vile-9.4f/doc/modes.doc 2004-04-11 19:30:15.000000000 -0400 @@ -41,7 +41,7 @@ The search is in normally alphabetic order, by majormode name. The first match each, of suffixes and preamble terminate the - search, but a match of preamble overrides a match of suffixes. + search, but a match of suffixes overrides a match of preamble. Use "after" and "before" qualifiers to handle special cases. In rare circumstances, both suffixes and preamble are needed to @@ -216,6 +216,14 @@ The following are keywords that aren't minor modes, but are recognized solely by the define-submode command: + mode-pathname + The full pathname which is tested to trigger association with a + majormode, e.g., "RCS/*,v". + + mode-filename + The filename which is tested to trigger association with a + majormode, e.g., "Makefile". + suffixes The filename suffix which is tested to trigger association with a majormode (e.g., c-suffixes) @@ -360,5 +368,5 @@ define-submode c tabstop=8 ------------------------------- -$Header: /usr/build/vile/vile/doc/RCS/modes.doc,v 1.13 2004/03/18 20:47:56 tom Exp $ +$Header: /usr/build/vile/vile/doc/RCS/modes.doc,v 1.16 2004/04/11 23:30:15 tom Exp $ ------------------------------- Index: eval.c Prereq: 1.322 --- vile-9.4e+/eval.c 2003-05-25 19:34:52.000000000 -0400 +++ vile-9.4f/eval.c 2004-04-11 13:18:48.000000000 -0400 @@ -2,7 +2,7 @@ * eval.c -- function and variable evaluation * original by Daniel Lawrence * - * $Header: /usr/build/vile/vile/RCS/eval.c,v 1.322 2003/05/25 23:34:52 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/eval.c,v 1.324 2004/04/11 17:18:48 tom Exp $ * */ @@ -741,6 +741,7 @@ { static TBUFF *result; /* function result */ + REGEXVAL *exp; BUFFER *bp; TBUFF *args[MAXARGS]; char *arg[MAXARGS]; /* function arguments */ @@ -923,6 +924,18 @@ (void) kcod2escape_seq(kbd_seq_nomap(), tb_values(result)); result->tb_used = strlen(tb_values(result)); break; + case UFCMATCH: + if ((exp = new_regexval(arg[0], TRUE)) != 0) { + int save_flag = ignorecase; + ignorecase = TRUE; + value = regexec(exp->reg, arg[1], (char *) 0, 0, -1); + ignorecase = save_flag; + } + break; + case UFMATCH: + if ((exp = new_regexval(arg[0], TRUE)) != 0) + value = regexec(exp->reg, arg[1], (char *) 0, 0, -1); + break; case UFRANDOM: /* FALLTHRU */ case UFRND: if (!is_error) Index: exec.c Prereq: 1.260 --- vile-9.4e+/exec.c 2004-03-21 12:25:43.000000000 -0500 +++ vile-9.4f/exec.c 2004-04-11 19:10:22.000000000 -0400 @@ -4,7 +4,7 @@ * original by Daniel Lawrence, but * much modified since then. assign no blame to him. -pgf * - * $Header: /usr/build/vile/vile/RCS/exec.c,v 1.260 2004/03/21 17:25:43 tom Exp $ + * $Header: /usr/build/vile/vile/RCS/exec.c,v 1.261 2004/04/11 23:10:22 tom Exp $ * */ @@ -1163,7 +1163,20 @@ const char *newvalue = tokval(previous); /* evaluate the token */ if ((const char *) previous != newvalue) { - (void) tb_scopy(tok, newvalue); + /* + * Check for the special case where we're just shifting the result + * down by one since we're stripping a leading quote. I don't want + * to use memmove() in tb_buff.c just for this instance since it's + * less portable -TD + */ + if (((const char *) previous) + 1 == newvalue) { + TBUFF *fix = 0; + tb_scopy(&fix, newvalue); + tb_free(tok); + *tok = fix; + } else { + (void) tb_scopy(tok, newvalue); + } } return (tb_values(*tok)); } Index: filters/filters.rc Prereq: 1.180 --- vile-9.4e+/filters/filters.rc 2004-03-18 19:37:48.000000000 -0500 +++ vile-9.4f/filters/filters.rc 2004-04-11 15:29:50.000000000 -0400 @@ -1,10 +1,10 @@ -; $Id: filters.rc,v 1.180 2004/03/19 00:37:48 tom Exp $ +; $Id: filters.rc,v 1.186 2004/04/11 19:29:50 tom Exp $ ; majormodes in this file are ordered alphabetically for convenience - the ; precedence used by vile is strictly alphabetic, counting case. define-mode ada ~with define-submode ada - suf '\.\(\\|\\|\\)$' + suffixes '\.\(ada\|ads\|adb\)$' comment-prefix '^\s*--' comments '^\s*--\s*$' fence-if '^\s*\' @@ -21,13 +21,13 @@ ; GNU assembler (a Byzantine elaboration of AT&T) define-mode as ~with define-submode as - suf '\.[sS]$' + suffixes '\.[sS]$' ~endwith ; M$ assembler (a Byzantine elaboration of Intel) define-mode asm ~with define-submode asm - suf '\.asm$' + suffixes '\.asm$' fence-if '^\s*\<\(if\|ifdef\|ifndef\)\>' fence-elif '^\s*\' fence-else '^\s*\' @@ -36,7 +36,7 @@ define-mode awk ~with define-submode awk - suf '\.awk$' + suffixes '\.awk$' pre '^#!\s*\/.*awk\>\(\s*-[\a]\+\)*\s*$' cindent cindent-chars $fences @@ -46,7 +46,7 @@ define-mode basic ~with define-submode basic - suf '\.bas$' + suffixes '\.bas$' comment-prefix '^\s*\'' comments '^\s*\'\s\+\s*$' ignorecase @@ -55,7 +55,7 @@ define-mode bat ~with define-submode bat - suf '\.\(bat\|cmd\)$' + suffixes '\.\(bat\|cmd\)$' pre '\s*\(@\)\?echo\s*\(on\|off\)\?$' dos ignorecase @@ -63,9 +63,15 @@ comments '^\s*rem\>\s\+\s*$' ~endwith +; we normally use the builtin values, but this is useful for looking at +; autoconf templates: +~with define-submode c + ignoresuffix '\.\(in\|orig\|~\)$' +~endwith + define-mode cfg ~with define-submode cfg - suf '\.cfg$' + suffixes '\.cfg$' comment-prefix '^\s*#' comments '^\s*#\s*$' ~endwith @@ -73,7 +79,7 @@ define-mode cpp ~with define-submode cpp before "c" - suf '\(\.\(C\|CC\|cc\|cpp\|cxx\|hxx\|hh\)$\)' + suffixes '\.\(C\|CC\|cc\|cpp\|cxx\|hxx\|hh\)$' cindent cindent-chars &cat ':#' $fences filtername 'vile-c-filt -k cpp' @@ -81,7 +87,7 @@ define-mode csh ~with define-submode csh - suf '\.\(csh[^/]*\|login\|logout\)$' + suffixes '\.\(csh.*\|login\|logout\)$' pre '^#!\s*\/.*csh\>\(\s*-[\a]\+\)*\s*$' filtername 'vile-sh-filt -k csh' comment-prefix '^\s*#' @@ -102,7 +108,7 @@ define-mode cweb ~with define-submode cweb - suf '\(\.w\|\.web\)$' + suffixes '\.\(w\|web\)$' ~endwith ; Fences in DCL do not work well because we really want a fence-if which @@ -111,7 +117,7 @@ ; excludes the if-block. define-mode dcl ~with define-submode dcl - suf '\.\(com\|tpu\)$' + suffixes '\.\(com\|tpu\)$' comment-prefix '^\s*\$!' comments '^\s*\$!\s*$' ignorecase @@ -125,35 +131,35 @@ define-mode def ~with define-submode def - suf '\.\(def\)$' + suffixes '\.\(def\)$' ignorecase dos ~endwith define-mode diff ~with define-submode diff - suf '\.\(patch\|dif\|diff\|diffs\|rej\)$' + suffixes '\.\(patch\|dif\|diff\|diffs\|rej\)$' pre '^\' ~endwith ; ECLiPSe (a dialect of Prolog) define-mode ecl ~with define-submode ecl - suf '\.\(ecl\|pro\)$' + suffixes '\.\(ecl\|pro\)$' ~endwith ; Syntax descriptions for enscript ; NOTE: Smalltalk files also may have ".st" suffix. define-mode est ~with define-submode est - suf '\.st$' + suffixes '\.st$' cindent ~endwith ; Embedded SQL in C/C++ define-mode esql ~with define-submode esql - suf '\.\(ec\|pc\|ppc\)$' + suffixes '\.\(ec\|pc\|ppc\)$' cindent cindent-chars &cat ':#' $fences ~endwith @@ -162,7 +168,7 @@ ; FIXME: The groups should not nest (extend the syntax) define-mode fdl ~with define-submode fdl - suf '\.\$' + suffixes '\.\$' comment-prefix '^\s*$rem\>' comments '^\(\|$rem\)$' fence-if '^\$\s*if\>' @@ -198,7 +204,7 @@ ; Inherit the C-style fences for JavaScript, but add new ones for HTML define-mode html ~with define-submode html - suf '\.\(html\|htm\)$' + suffixes '\.\(html\|htm\)$' pre '\(\|