=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/vim/Attic/help.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/vim/Attic/help.c 1996/09/07 21:40:26 1.1 --- src/usr.bin/vim/Attic/help.c 1996/09/21 06:23:04 1.2 *************** *** 1,4 **** ! /* $OpenBSD: help.c,v 1.1 1996/09/07 21:40:26 downsj Exp $ */ /* vi:set ts=4 sw=4: * * VIM - Vi IMproved by Bram Moolenaar --- 1,4 ---- ! /* $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,46 **** return; } ! /* The first file is the best match */ arg = strsave(matches[0]); need_free = TRUE; FreeWild(num_matches, matches); --- 40,46 ---- return; } ! /* The first match is the best match */ arg = strsave(matches[0]); need_free = TRUE; FreeWild(num_matches, matches); *************** *** 98,104 **** * 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); /* save the values of the options we change */ vim_free(help_save_isk); --- 98,105 ---- * open help file (do_ecmd() will set b_help flag, readfile() will * set b_p_ro flag) */ ! (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,235 **** regexp *prog; int attempt; int retval = FAIL; 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 '.'). */ ! if (STRCMP(arg, "*") == 0 || STRCMP(arg, "[*") == 0 || ! STRCMP(arg, "]*") == 0) { ! if (*arg != '*') ! *d++ = *arg; ! STRCPY(d, "star"); ! d += 4; } ! else { for (s = arg; *s; ++s) { if (d - IObuff > IOSIZE - 10) /* getting too long!? */ break; switch (*s) --- 203,244 ---- regexp *prog; int attempt; int retval = FAIL; + int i; + static char *(mtable[]) = {"*", "g*", "[*", "]*", + "/*", "/\\*", "/\\(\\)", + "?", ":?", "?"}; + static char *(rtable[]) = {"star", "gstar", "[star", "]star", + "/star", "/\\\\star", "/\\\\(\\\\)", + "?", ":?", "?"}; reg_magic = p_magic; d = IObuff; /* assume IObuff is long enough! */ /* ! * Recognize a few exceptions to the rule. Some strings that contain '*' ! * with "star". Otherwise '*' is recognized as a wildcard. */ ! for (i = sizeof(mtable) / sizeof(char *); --i >= 0; ) { ! if (STRCMP(arg, mtable[i]) == 0) ! { ! STRCPY(d, rtable[i]); ! break; ! } } ! ! 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,259 **** continue; case '*': *d++ = '.'; break; ! /* "?", ":?" and "?" are real tags */ ! case '?': if (arg[1] == NUL || ! STRCMP(arg, ":?") == 0 || ! STRCMP(arg, "?") == 0) ! break; ! *d++ = '.'; continue; case '$': case '.': case '~': *d++ = '\\'; break; } if (*s < ' ' || (*s == '^' && s[1] && s[1] != '_')) /* ^x */ { STRCPY(d, "CTRL-"); --- 251,268 ---- continue; case '*': *d++ = '.'; break; ! 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,278 **** } else if (*s == '^') /* "^" or "CTRL-^" or "^_" */ *d++ = '\\'; *d++ = *s; if (*s == '\'' && s > arg && *arg == '\'') break; } } - *d = NUL; reg_ic = FALSE; prog = vim_regcomp(IObuff); --- 276,301 ---- } 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; } reg_ic = FALSE; prog = vim_regcomp(IObuff); *************** *** 284,290 **** { *matches = (char_u **)""; *num_matches = 0; ! retval = find_tags(NULL, prog, num_matches, matches, TRUE); if (retval == FAIL || *num_matches) break; } --- 307,313 ---- { *matches = (char_u **)""; *num_matches = 0; ! retval = find_tags(NULL, prog, num_matches, matches, TRUE, FALSE); if (retval == FAIL || *num_matches) break; }