📄 nvi-1.79-gtags.diff
字号:
/* * This file is placed into the public domain by the author, * Shigio YAMAGUCHI */diff -c -r -N ../nvi-1.79.org/common/main.c ./common/main.c*** ../nvi-1.79.org/common/main.c Sat Oct 12 07:28:28 1996--- ./common/main.c Fri Jul 13 13:38:45 2001****************** 64,69 ****--- 64,72 ---- size_t len; u_int flags; int ch, flagchk, lflag, secure, startup, readonly, rval, silent;+ /* #ifdef GTAGS */+ int gtags = 0;+ /* #endif */ char *tag_f, *wsizearg, path[256]; /* Initialize the busy routine, if not defined by the screen. */****************** 113,123 **** /* Set the file snapshot flag. */ F_SET(gp, G_SNAPSHOT); #ifdef DEBUG! while ((ch = getopt(argc, argv, "c:D:eFlRrSsT:t:vw:")) != EOF) #else! while ((ch = getopt(argc, argv, "c:eFlRrSst:vw:")) != EOF) #endif switch (ch) { case 'c': /* Run the command. */ /*--- 116,128 ---- /* Set the file snapshot flag. */ F_SET(gp, G_SNAPSHOT); + /* #ifdef GTAGS */ #ifdef DEBUG! while ((ch = getopt(argc, argv, "c:D:eFGlRrSsT:t:vw:")) != EOF) #else! while ((ch = getopt(argc, argv, "c:eFGlRrSst:vw:")) != EOF) #endif+ /* #endif */ switch (ch) { case 'c': /* Run the command. */ /******************* 154,159 ****--- 159,169 ---- case 'F': /* No snapshot. */ F_CLR(gp, G_SNAPSHOT); break;+ /* #ifdef GTAGS */+ case 'G': /* gtags mode. */+ gtags = 1;+ break;+ /* #endif */ case 'l': /* Set lisp, showmatch options. */ lflag = 1; break;****************** 252,257 ****--- 262,271 ---- } if (readonly) *oargp++ = O_READONLY;+ /* #ifdef GTAGS */+ if (gtags)+ *oargp++ = O_GTAGSMODE;+ /* #endif */ if (secure) *oargp++ = O_SECURE; *oargp = -1; /* Options initialization. */diff -c -r -N ../nvi-1.79.org/common/options.c ./common/options.c*** ../nvi-1.79.org/common/options.c Tue Oct 15 03:56:29 1996--- ./common/options.c Fri Jul 13 13:38:45 2001****************** 80,85 ****--- 80,89 ---- {"filec", NULL, OPT_STR, 0}, /* O_FLASH HPUX */ {"flash", NULL, OPT_1BOOL, 0},+ /* #ifdef GTAGS */+ /* O_GTAGSMODE FreeBSD2.2 */+ {"gtagsmode", NULL, OPT_0BOOL, 0},+ /* #endif */ /* O_HARDTABS 4BSD */ {"hardtabs", NULL, OPT_NUM, 0}, /* O_ICLOWER 4.4BSD */****************** 244,249 ****--- 248,256 ---- {"eb", O_ERRORBELLS}, /* 4BSD */ {"ed", O_EDCOMPATIBLE}, /* 4BSD */ {"ex", O_EXRC}, /* System V (undocumented) */+ /* #ifdef GTAGS */+ {"gt", O_GTAGSMODE}, /* FreeBSD2.2 */+ /* #endif */ {"ht", O_HARDTABS}, /* 4BSD */ {"ic", O_IGNORECASE}, /* 4BSD */ {"li", O_LINES}, /* 4.4BSD */diff -c -r -N ../nvi-1.79.org/docs/USD.doc/vi.man/vi.1 ./docs/USD.doc/vi.man/vi.1*** ../nvi-1.79.org/docs/USD.doc/vi.man/vi.1 Fri Oct 11 10:34:05 1996--- ./docs/USD.doc/vi.man/vi.1 Fri Jul 13 13:38:45 2001****************** 17,23 **** .SH SYNOPSIS .B ex [\c! .B -eFRrSsv\c ] [\c .BI -c " cmd"\c ] [\c--- 17,23 ---- .SH SYNOPSIS .B ex [\c! .B -eFGRrSsv\c ] [\c .BI -c " cmd"\c ] [\c****************** 28,34 **** .br .B vi [\c! .B -eFlRrSv\c ] [\c .BI -c " cmd"\c ] [\c--- 28,34 ---- .br .B vi [\c! .B -eFGlRrSv\c ] [\c .BI -c " cmd"\c ] [\c****************** 39,45 **** .br .B view [\c! .B -eFRrSv\c ] [\c .BI -c " cmd"\c ] [\c--- 39,45 ---- .br .B view [\c! .B -eFGRrSv\c ] [\c .BI -c " cmd"\c ] [\c****************** 121,126 ****--- 121,129 ---- .B \-l Start editing with the lisp and showmatch options set. .TP+ .B \-G+ Start editing in gtags mode, as if the gtagsmode option was set.+ .TP .B \-R Start editing in read-only mode, as if the command name was .IR view ,****************** 429,434 ****--- 432,439 ---- .TP .B "<control-]>" Push a tag reference onto the tag stack.+ In gtagsmode, if at the first column of line,+ locate function references otherwise function definitions. .TP .B "<control-^>" Switch to the most recently edited file.****************** 1109,1114 ****--- 1114,1122 ---- .TP .B "flash [on]" Flash the screen instead of beeping the keyboard on error.+ .TP+ .B "gtagsmode, gt [off]"+ Use GTAGS and GRTAGS instead of tags. .TP .B "hardtabs, ht [8]" Set the spacing between hardware tab settings.diff -c -r -N ../nvi-1.79.org/ex/ex.c ./ex/ex.c*** ../nvi-1.79.org/ex/ex.c Fri Oct 11 07:49:46 1996--- ./ex/ex.c Fri Jul 13 13:38:45 2001****************** 935,941 **** } ecp->flagoff = 0;! for (p = ecp->cmd->syntax; *p != '\0'; ++p) { /* * The force flag is sensitive to leading whitespace, i.e. * "next !" is different from "next!". Handle it before--- 935,946 ---- } ecp->flagoff = 0;! p = ecp->cmd->syntax;! /* #ifdef GTAGS */! if (ecp->cmd == &cmds[C_TAG] && O_ISSET(sp, O_GTAGSMODE))! p = "!wNo";! /* #endif */! for ( ; *p != '\0'; ++p) { /* * The force flag is sensitive to leading whitespace, i.e. * "next !" is different from "next!". Handle it beforediff -c -r -N ../nvi-1.79.org/ex/ex_argv.c ./ex/ex_argv.c*** ../nvi-1.79.org/ex/ex_argv.c Sat Sep 21 09:33:02 1996--- ./ex/ex_argv.c Fri Jul 13 13:38:45 2001****************** 326,331 ****--- 326,334 ---- EX_PRIVATE *exp; char *bp, *t; size_t blen, len, off, tlen;+ /* #ifdef GTAGS */+ char b[30];+ /* #endif */ /* Replace file name characters. */ for (bp = *bpp, blen = *blenp, len = *lenp; cmdlen > 0; --cmdlen, ++cmd)****************** 376,381 ****--- 379,401 ---- p += tlen; F_SET(excp, E_MODIFY); break;+ /* #ifdef GTAGS */+ case '@': /* replace with line number */+ if (O_ISSET(sp, O_GTAGSMODE)) {+ snprintf(b, sizeof(b), "%d", sp->lno);+ t = b;+ tlen = strlen(t);+ len += tlen;+ off = p - bp;+ ADD_SPACE_RET(sp, bp, blen, len);+ p = bp + off;+ memcpy(p, t, tlen);+ p += tlen;+ F_SET(excp, E_MODIFY);+ break;+ }+ goto ins_ch;+ /* #endif */ case '\\': /* * QUOTING NOTE:diff -c -r -N ../nvi-1.79.org/ex/ex_tag.c ./ex/ex_tag.c*** ../nvi-1.79.org/ex/ex_tag.c Mon Sep 16 05:02:43 1996--- ./ex/ex_tag.c Fri Jul 13 13:39:47 2001****************** 18,23 ****--- 18,26 ---- #include <sys/param.h> #include <sys/types.h> /* XXX: param.h may not have included types.h */+ /* #ifdef GTAGS */+ #include <sys/wait.h>+ /* #endif */ #ifdef HAVE_SYS_MMAN_H #include <sys/mman.h>****************** 46,51 ****--- 49,58 ---- static int compare __P((char *, char *, char *)); static void ctag_file __P((SCR *, TAGF *, char *, char **, size_t *)); static int ctag_search __P((SCR *, char *, size_t, char *));+ /* #ifdef GTAGS */+ static int getentry __P((char *, char **, char **, char **));+ static TAGQ *gtag_slist __P((SCR *, char *, char *, int));+ /* #endif */ static int ctag_sfile __P((SCR *, TAGF *, TAGQ *, char *)); static TAGQ *ctag_slist __P((SCR *, char *)); static char *linear_search __P((char *, char *, char *));****************** 110,117 ****--- 117,208 ---- size_t cno; long tl; int force, istmp;+ /* #ifdef GTAGS */+ int Pflag, fflag; + char options[BUFSIZ];+ /* #endif */ exp = EXP(sp);+ /* #ifdef GTAGS */+ /*+ * In gtagsmode, you can use global(1)'s option in tag command.+ * For example:+ * :tag -r strcmp -- locate referenced point of strcmp.+ * :tag -P /vm/ -- list files in 'vm' directory.+ * :tag -g init -- locate occurrence of string 'init'.+ */+ if (O_ISSET(sp, O_GTAGSMODE)) {+ char *last, *file;+ int i;+ + Pflag = fflag = 0;+ options[0] = 0;+ for (i = 0; i < cmdp->argc && *cmdp->argv[i]->bp == '-'; i++) {+ char *p = cmdp->argv[i]->bp;+ if (*++p == '-') { /* long name option */+ msgq(sp, M_ERR, "long name option not available.");+ return (1);+ } else { /* short name option */+ if ( index(p, 'c')+ || index(p, 'n')+ || index(p, 'p')+ || index(p, 'u')+ || index(p, 'v')+ ) {+ msgq(sp, M_ERR, "-c, -n, -p, -u and -v option not available.");+ return (1);+ }+ if (index(p, 'P'))+ Pflag = 1;+ if (index(p, 'f'))+ fflag = 1;+ }+ if (strlen(options) + strlen(cmdp->argv[i]->bp) + 1 < BUFSIZ) {+ strcat(options, cmdp->argv[i]->bp);+ strcat(options, " ");+ }+ }+ if (i < cmdp->argc) { /* tag name exist */+ /*+ * In gtagsmode, only one argument can be accepted.+ */+ last = cmdp->argv[cmdp->argc - 1]->bp;+ /*+ * filename substitution only for -f and -P option.+ */+ if (fflag || Pflag) {+ if (*(last + 1) == NULL && (*last == '%' || *last == '#')) {+ char *file = (*last == '%') ? sp->frp->name : sp->alt_name;+ if (file == NULL) {+ msgq(sp, M_ERR,+ "116|No filename to substitute for %%");+ return (1);+ }+ if (Pflag && rindex(file, '/'))+ last = rindex(file, '/');+ else+ last = file;+ }+ }+ if (exp->tag_last != NULL)+ free(exp->tag_last);+ exp->tag_last = strdup(last);+ /* Taglength may limit the number of characters. */+ if ((tl =+ O_VAL(sp, O_TAGLENGTH)) != 0 && strlen(exp->tag_last) > tl)+ exp->tag_last[tl] = '\0';+ } else { /* no tag name */+ if (exp->tag_last == NULL) {+ if (Pflag)+ exp->tag_last = strdup("");+ else {+ msgq(sp, M_ERR, "158|No previous tag entered");+ return (1);+ }+ }+ }+ } else+ /* #endif */ switch (cmdp->argc) { case 1: if (exp->tag_last != NULL)****************** 138,145 **** } /* Get the tag information. */! if ((tqp = ctag_slist(sp, exp->tag_last)) == NULL)! return (1); /* * Allocate all necessary memory before swapping screens. Initialize--- 229,243 ---- } /* Get the tag information. */! /* #ifdef GTAGS */! if (O_ISSET(sp, O_GTAGSMODE)) {! if ((tqp = gtag_slist(sp, options, exp->tag_last, !fflag)) == NULL)! return (1);! } else {! /* #endif */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -