diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1996-09-21 06:23:56 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1996-09-21 06:23:56 +0000 |
commit | e8e01073071369d33ab4cf61be05bebe5a65566e (patch) | |
tree | 2c29b23bfb933e0fa40619f7d1fae430ff2c247e /usr.bin/vim/help.c | |
parent | 584e4bbf452da2934dbaf4b9dc09bd131a1d4cd7 (diff) |
update to vim 4.4beta
Diffstat (limited to 'usr.bin/vim/help.c')
-rw-r--r-- | usr.bin/vim/help.c | 79 |
1 files changed, 51 insertions, 28 deletions
diff --git a/usr.bin/vim/help.c b/usr.bin/vim/help.c index b3d3a8cd4de..f7f71f924ae 100644 --- a/usr.bin/vim/help.c +++ b/usr.bin/vim/help.c @@ -1,4 +1,4 @@ -/* $OpenBSD: help.c,v 1.1 1996/09/07 21:40:26 downsj Exp $ */ +/* $OpenBSD: help.c,v 1.2 1996/09/21 06:23:04 downsj Exp $ */ /* vi:set ts=4 sw=4: * * VIM - Vi IMproved by Bram Moolenaar @@ -40,7 +40,7 @@ do_help(arg) return; } - /* The first file is the best match */ + /* The first match is the best match */ arg = strsave(matches[0]); need_free = TRUE; FreeWild(num_matches, matches); @@ -98,7 +98,8 @@ do_help(arg) * open help file (do_ecmd() will set b_help flag, readfile() will * set b_p_ro flag) */ - (void)do_ecmd(0, fnamep, NULL, NULL, TRUE, (linenr_t)0, TRUE); + (void)do_ecmd(0, fnamep, NULL, NULL, (linenr_t)0, + ECMD_HIDE + ECMD_SET_HELP); /* save the values of the options we change */ vim_free(help_save_isk); @@ -202,34 +203,42 @@ find_help_tags(arg, num_matches, matches) regexp *prog; int attempt; int retval = FAIL; + int i; + static char *(mtable[]) = {"*", "g*", "[*", "]*", + "/*", "/\\*", "/\\(\\)", + "?", ":?", "?<CR>"}; + static char *(rtable[]) = {"star", "gstar", "[star", "]star", + "/star", "/\\\\star", "/\\\\(\\\\)", + "?", ":?", "?<CR>"}; reg_magic = p_magic; d = IObuff; /* assume IObuff is long enough! */ /* - * Replace "|" with "bar", """ with "quote" and "*" with "star" to - * match the name of the tags for these commands. - * Replace "*" with ".*" and "?" with "." to match command line - * completion. - * Insert a backslash before '~', '$' and '.' to avoid their - * special meaning. - * Replace "^x" by "CTRL-X". Don't do this for "^_" to make - * ":help i_^_CTRL-D" work. - * If tag starts with ', toss everything after a second '. Fixes - * CTRL-] on 'option'. (would include the trailing '.'). + * Recognize a few exceptions to the rule. Some strings that contain '*' + * with "star". Otherwise '*' is recognized as a wildcard. */ - if (STRCMP(arg, "*") == 0 || STRCMP(arg, "[*") == 0 || - STRCMP(arg, "]*") == 0) + for (i = sizeof(mtable) / sizeof(char *); --i >= 0; ) { - if (*arg != '*') - *d++ = *arg; - STRCPY(d, "star"); - d += 4; + if (STRCMP(arg, mtable[i]) == 0) + { + STRCPY(d, rtable[i]); + break; + } } - else + + if (i < 0) /* no match in table, replace single characters */ { for (s = arg; *s; ++s) { + /* + * Replace "|" with "bar" and """ with "quote" to match the name of + * the tags for these commands. + * Replace "*" with ".*" and "?" with "." to match command line + * completion. + * Insert a backslash before '~', '$' and '.' to avoid their + * special meaning. + */ if (d - IObuff > IOSIZE - 10) /* getting too long!? */ break; switch (*s) @@ -242,18 +251,18 @@ find_help_tags(arg, num_matches, matches) continue; case '*': *d++ = '.'; break; - /* "?", ":?" and "?<CR>" are real tags */ - case '?': if (arg[1] == NUL || - STRCMP(arg, ":?") == 0 || - STRCMP(arg, "?<CR>") == 0) - break; - *d++ = '.'; + case '?': *d++ = '.'; continue; case '$': case '.': case '~': *d++ = '\\'; break; } + + /* + * Replace "^x" by "CTRL-X". Don't do this for "^_" to make + * ":help i_^_CTRL-D" work. + */ if (*s < ' ' || (*s == '^' && s[1] && s[1] != '_')) /* ^x */ { STRCPY(d, "CTRL-"); @@ -267,12 +276,26 @@ find_help_tags(arg, num_matches, matches) } else if (*s == '^') /* "^" or "CTRL-^" or "^_" */ *d++ = '\\'; + + /* + * Insert a backslash before a backslash after a slash, for search + * pattern tags: "/\|" --> "/\\|". + */ + else if (s[0] == '\\' && s[1] != '\\' && + *arg == '/' && s == arg + 1) + *d++ = '\\'; + *d++ = *s; + + /* + * If tag starts with ', toss everything after a second '. Fixes + * CTRL-] on 'option'. (would include the trailing '.'). + */ if (*s == '\'' && s > arg && *arg == '\'') break; } + *d = NUL; } - *d = NUL; reg_ic = FALSE; prog = vim_regcomp(IObuff); @@ -284,7 +307,7 @@ find_help_tags(arg, num_matches, matches) { *matches = (char_u **)""; *num_matches = 0; - retval = find_tags(NULL, prog, num_matches, matches, TRUE); + retval = find_tags(NULL, prog, num_matches, matches, TRUE, FALSE); if (retval == FAIL || *num_matches) break; } |