Mercurial > vim
annotate src/if_cscope.c @ 32051:e8c60d35fce3 v9.0.1357
patch 9.0.1357: using null_object results in an internal error
Commit: https://github.com/vim/vim/commit/c4e1b86cb0d88fa5ec1141d3c600e026dcc1bc21
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 26 18:58:23 2023 +0000
patch 9.0.1357: using null_object results in an internal error
Problem: Using null_object results in an internal error. (Ernie Rael)
Solution: Add instructions for pushing an object and class. (closes https://github.com/vim/vim/issues/12044)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Feb 2023 20:00:03 +0100 |
parents | 50555279168b |
children | bb5458706799 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9418
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * CSCOPE support for Vim added by Andy Kahn <kahn@zk3.dec.com> | |
148 | 4 * Ported to Win32 by Sergey Khorev <sergey.khorev@gmail.com> |
7 | 5 * |
6 * The basic idea/structure of cscope for Vim was borrowed from Nvi. There | |
7 * might be a few lines of code that look similar to what Nvi has. | |
8 * | |
9 * See README.txt for an overview of the Vim source code. | |
10 */ | |
11 | |
12 #include "vim.h" | |
13 | |
14 #if defined(FEAT_CSCOPE) || defined(PROTO) | |
15 | |
16 #include <sys/types.h> | |
17 #include <sys/stat.h> | |
18 #if defined(UNIX) | |
19 # include <sys/wait.h> | |
20 #endif | |
27104
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
21 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
22 #if defined (MSWIN) |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
23 # ifndef WIN32_LEAN_AND_MEAN |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
24 # define WIN32_LEAN_AND_MEAN |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
25 # endif |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
26 # include <windows.h> |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
27 #endif |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
28 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
29 #define CSCOPE_SUCCESS 0 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
30 #define CSCOPE_FAILURE -1 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
31 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
32 #define CSCOPE_DBFILE "cscope.out" |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
33 #define CSCOPE_PROMPT ">> " |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
34 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
35 /* |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
36 * See ":help cscope-find" for the possible queries. |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
37 */ |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
38 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
39 typedef struct { |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
40 char * name; |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
41 int (*func)(exarg_T *eap); |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
42 char * help; |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
43 char * usage; |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
44 int cansplit; // if supports splitting window |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
45 } cscmd_T; |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
46 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
47 typedef struct csi { |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
48 char * fname; // cscope db name |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
49 char * ppath; // path to prepend (the -P option) |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
50 char * flags; // additional cscope flags/options (e.g, -p2) |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
51 #if defined(UNIX) |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
52 pid_t pid; // PID of the connected cscope process. |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
53 dev_t st_dev; // ID of dev containing cscope db |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
54 ino_t st_ino; // inode number of cscope db |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
55 #else |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
56 # if defined(MSWIN) |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
57 DWORD pid; // PID of the connected cscope process. |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
58 HANDLE hProc; // cscope process handle |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
59 DWORD nVolume; // Volume serial number, instead of st_dev |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
60 DWORD nIndexHigh; // st_ino has no meaning in the Windows |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
61 DWORD nIndexLow; |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
62 # endif |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
63 #endif |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
64 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
65 FILE * fr_fp; // from cscope: FILE. |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
66 FILE * to_fp; // to cscope: FILE. |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
67 } csinfo_T; |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
68 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
69 typedef enum { Add, Find, Help, Kill, Reset, Show } csid_e; |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
70 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
71 typedef enum { |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
72 Store, |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
73 Get, |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
74 Free, |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
75 Print |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
76 } mcmd_e; |
7 | 77 |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
78 static int cs_add(exarg_T *eap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
79 static int cs_add_common(char *, char *, char *); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
80 static int cs_check_for_connections(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
81 static int cs_check_for_tags(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
82 static int cs_cnt_connections(void); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
83 static int cs_create_connection(int i); |
636 | 84 #ifdef FEAT_QUICKFIX |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
85 static void cs_file_results(FILE *, int *); |
636 | 86 #endif |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
87 static void cs_fill_results(char *, int , int *, char ***, |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
88 char ***, int *); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
89 static int cs_find(exarg_T *eap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
90 static int cs_find_common(char *opt, char *pat, int, int, int, char_u *cmdline); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
91 static int cs_help(exarg_T *eap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
92 static int cs_insert_filelist(char *, char *, char *, |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9340
diff
changeset
|
93 stat_T *); |
7803
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
94 static int cs_kill(exarg_T *eap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
95 static void cs_kill_execute(int, char *); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
96 static cscmd_T * cs_lookup_cmd(exarg_T *eap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
97 static char * cs_make_vim_style_matches(char *, char *, |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
98 char *, char *); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
99 static char * cs_manage_matches(char **, char **, int, mcmd_e); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
100 static void cs_print_tags_priv(char **, char **, int); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
101 static int cs_read_prompt(int); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
102 static void cs_release_csp(int, int freefnpp); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
103 static int cs_reset(exarg_T *eap); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
104 static char * cs_resolve_file(int, char *); |
37c929c4a073
commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
105 static int cs_show(exarg_T *eap); |
7 | 106 |
107 | |
1931 | 108 static csinfo_T * csinfo = NULL; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
109 static int csinfo_size = 0; // number of items allocated in |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
110 // csinfo[] |
1931 | 111 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
112 static int eap_arg_len; // length of eap->arg, set in |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
113 // cs_lookup_cmd() |
7 | 114 static cscmd_T cs_cmds[] = |
115 { | |
116 { "add", cs_add, | |
117 N_("Add a new database"), "add file|dir [pre-path] [flags]", 0 }, | |
118 { "find", cs_find, | |
9418
6d213bd46cc3
commit https://github.com/vim/vim/commit/80632db65e8f5f775dadbbc10c5ba6c173ebb24f
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
119 N_("Query for a pattern"), "find a|c|d|e|f|g|i|s|t name", 1 }, |
7 | 120 { "help", cs_help, |
121 N_("Show this message"), "help", 0 }, | |
122 { "kill", cs_kill, | |
123 N_("Kill a connection"), "kill #", 0 }, | |
124 { "reset", cs_reset, | |
125 N_("Reinit all connections"), "reset", 0 }, | |
126 { "show", cs_show, | |
127 N_("Show connections"), "show", 0 }, | |
1880 | 128 { NULL, NULL, NULL, NULL, 0 } |
7 | 129 }; |
130 | |
131 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
132 cs_usage_msg(csid_e x) |
7 | 133 { |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
134 (void)semsg(_(e_usage_cscope_str), cs_cmds[(int)x].usage); |
7 | 135 } |
136 | |
1845 | 137 static enum |
138 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
139 EXP_CSCOPE_SUBCMD, // expand ":cscope" sub-commands |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
140 EXP_SCSCOPE_SUBCMD, // expand ":scscope" sub-commands |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
141 EXP_CSCOPE_FIND, // expand ":cscope find" arguments |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
142 EXP_CSCOPE_KILL // expand ":cscope kill" arguments |
1845 | 143 } expand_what; |
144 | |
145 /* | |
146 * Function given to ExpandGeneric() to obtain the cscope command | |
147 * expansion. | |
148 */ | |
149 char_u * | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
150 get_cscope_name(expand_T *xp UNUSED, int idx) |
1845 | 151 { |
1858 | 152 int current_idx; |
153 int i; | |
154 | |
1845 | 155 switch (expand_what) |
156 { | |
157 case EXP_CSCOPE_SUBCMD: | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
158 // Complete with sub-commands of ":cscope": |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
159 // add, find, help, kill, reset, show |
1845 | 160 return (char_u *)cs_cmds[idx].name; |
1858 | 161 case EXP_SCSCOPE_SUBCMD: |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
162 // Complete with sub-commands of ":scscope": same sub-commands as |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
163 // ":cscope" but skip commands which don't support split windows |
1858 | 164 for (i = 0, current_idx = 0; cs_cmds[i].name != NULL; i++) |
165 if (cs_cmds[i].cansplit) | |
166 if (current_idx++ == idx) | |
167 break; | |
168 return (char_u *)cs_cmds[i].name; | |
1845 | 169 case EXP_CSCOPE_FIND: |
170 { | |
171 const char *query_type[] = | |
172 { | |
9418
6d213bd46cc3
commit https://github.com/vim/vim/commit/80632db65e8f5f775dadbbc10c5ba6c173ebb24f
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
173 "a", "c", "d", "e", "f", "g", "i", "s", "t", NULL |
1845 | 174 }; |
175 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
176 // Complete with query type of ":cscope find {query_type}". |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
177 // {query_type} can be letters (c, d, ... a) or numbers (0, 1, |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
178 // ..., 9) but only complete with letters, since numbers are |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
179 // redundant. |
1845 | 180 return (char_u *)query_type[idx]; |
181 } | |
182 case EXP_CSCOPE_KILL: | |
183 { | |
1931 | 184 static char connection[5]; |
1845 | 185 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
186 // ":cscope kill" accepts connection numbers or partial names of |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
187 // the pathname of the cscope database as argument. Only complete |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
188 // with connection numbers. -1 can also be used to kill all |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
189 // connections. |
1931 | 190 for (i = 0, current_idx = 0; i < csinfo_size; i++) |
1845 | 191 { |
192 if (csinfo[i].fname == NULL) | |
193 continue; | |
194 if (current_idx++ == idx) | |
195 { | |
1931 | 196 vim_snprintf(connection, sizeof(connection), "%d", i); |
197 return (char_u *)connection; | |
1845 | 198 } |
199 } | |
200 return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL; | |
201 } | |
202 default: | |
203 return NULL; | |
204 } | |
205 } | |
206 | |
207 /* | |
208 * Handle command line completion for :cscope command. | |
209 */ | |
210 void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
211 set_context_in_cscope_cmd( |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
212 expand_T *xp, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
213 char_u *arg, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
214 cmdidx_T cmdidx) |
1845 | 215 { |
216 char_u *p; | |
217 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
218 // Default: expand subcommands |
1845 | 219 xp->xp_context = EXPAND_CSCOPE; |
220 xp->xp_pattern = arg; | |
1858 | 221 expand_what = (cmdidx == CMD_scscope) |
222 ? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD; | |
1845 | 223 |
31702
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
224 if (*arg == NUL) |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
225 return; |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
226 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
227 // (part of) subcommand already typed |
31702
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
228 p = skiptowhite(arg); |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
229 if (*p == NUL) |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
230 return; |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
231 |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
232 // past first word |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
233 xp->xp_pattern = skipwhite(p); |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
234 if (*skiptowhite(xp->xp_pattern) != NUL) |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
235 xp->xp_context = EXPAND_NOTHING; |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
236 else if (STRNICMP(arg, "add", p - arg) == 0) |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
237 xp->xp_context = EXPAND_FILES; |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
238 else if (STRNICMP(arg, "kill", p - arg) == 0) |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
239 expand_what = EXP_CSCOPE_KILL; |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
240 else if (STRNICMP(arg, "find", p - arg) == 0) |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
241 expand_what = EXP_CSCOPE_FIND; |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
242 else |
27c9212d10aa
patch 9.0.1183: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
30817
diff
changeset
|
243 xp->xp_context = EXPAND_NOTHING; |
1845 | 244 } |
245 | |
7 | 246 /* |
1845 | 247 * Find the command, print help if invalid, and then call the corresponding |
248 * command function. | |
7 | 249 */ |
250 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
251 do_cscope_general( |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
252 exarg_T *eap, |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
253 int make_split UNUSED) // whether to split window |
7 | 254 { |
255 cscmd_T *cmdp; | |
256 | |
257 if ((cmdp = cs_lookup_cmd(eap)) == NULL) | |
258 { | |
259 cs_help(eap); | |
260 return; | |
261 } | |
262 | |
263 if (make_split) | |
264 { | |
265 if (!cmdp->cansplit) | |
266 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
267 (void)msg_puts(_("This cscope command does not support splitting the window.\n")); |
7 | 268 return; |
269 } | |
270 postponed_split = -1; | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
271 postponed_split_flags = cmdmod.cmod_split; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21927
diff
changeset
|
272 postponed_split_tab = cmdmod.cmod_tab; |
7 | 273 } |
274 | |
275 cmdp->func(eap); | |
276 | |
277 postponed_split_flags = 0; | |
1090 | 278 postponed_split_tab = 0; |
7 | 279 } |
280 | |
281 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
282 * Implementation of ":cscope" and ":lcscope" |
7 | 283 */ |
284 void | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
285 ex_cscope(exarg_T *eap) |
7 | 286 { |
287 do_cscope_general(eap, FALSE); | |
288 } | |
289 | |
290 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
291 * Implementation of ":scscope". Same as ex_cscope(), but splits window, too. |
7 | 292 */ |
293 void | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
294 ex_scscope(exarg_T *eap) |
7 | 295 { |
296 do_cscope_general(eap, TRUE); | |
297 } | |
298 | |
299 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
300 * Implementation of ":cstag" |
7 | 301 */ |
302 void | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
303 ex_cstag(exarg_T *eap) |
7 | 304 { |
305 int ret = FALSE; | |
306 | |
1621 | 307 if (*eap->arg == NUL) |
7 | 308 { |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
309 (void)emsg(_(e_usage_cstag_ident)); |
7 | 310 return; |
311 } | |
312 | |
313 switch (p_csto) | |
314 { | |
315 case 0 : | |
316 if (cs_check_for_connections()) | |
317 { | |
665 | 318 ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, FALSE, |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
319 FALSE, *eap->cmdlinep); |
7 | 320 if (ret == FALSE) |
321 { | |
322 cs_free_tags(); | |
323 if (msg_col) | |
324 msg_putchar('\n'); | |
325 | |
326 if (cs_check_for_tags()) | |
327 ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE); | |
328 } | |
329 } | |
330 else if (cs_check_for_tags()) | |
331 { | |
332 ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE); | |
333 } | |
334 break; | |
335 case 1 : | |
336 if (cs_check_for_tags()) | |
337 { | |
338 ret = do_tag(eap->arg, DT_JUMP, 0, eap->forceit, FALSE); | |
339 if (ret == FALSE) | |
340 { | |
341 if (msg_col) | |
342 msg_putchar('\n'); | |
343 | |
344 if (cs_check_for_connections()) | |
345 { | |
346 ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
347 FALSE, FALSE, *eap->cmdlinep); |
7 | 348 if (ret == FALSE) |
349 cs_free_tags(); | |
350 } | |
351 } | |
352 } | |
353 else if (cs_check_for_connections()) | |
354 { | |
665 | 355 ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, FALSE, |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
356 FALSE, *eap->cmdlinep); |
7 | 357 if (ret == FALSE) |
358 cs_free_tags(); | |
359 } | |
360 break; | |
361 default : | |
362 break; | |
363 } | |
364 | |
365 if (!ret) | |
366 { | |
26893
79c76ca2c53c
patch 8.2.3975: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
367 (void)emsg(_(e_cstag_tag_not_founc)); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
368 #if defined(FEAT_QUICKFIX) |
7 | 369 g_do_tagpreview = 0; |
370 #endif | |
371 } | |
372 | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
373 } |
7 | 374 |
375 | |
376 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
377 * This simulates a vim_fgets(), but for cscope, returns the next line |
7 | 378 * from the cscope output. should only be called from find_tags() |
379 * | |
380 * returns TRUE if eof, FALSE otherwise | |
381 */ | |
382 int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
383 cs_fgets(char_u *buf, int size) |
7 | 384 { |
385 char *p; | |
386 | |
387 if ((p = cs_manage_matches(NULL, NULL, -1, Get)) == NULL) | |
388 return TRUE; | |
1372 | 389 vim_strncpy(buf, (char_u *)p, size - 1); |
7 | 390 |
391 return FALSE; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
392 } |
7 | 393 |
394 | |
395 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
396 * Called only from do_tag(), when popping the tag stack. |
7 | 397 */ |
398 void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
399 cs_free_tags(void) |
7 | 400 { |
401 cs_manage_matches(NULL, NULL, -1, Free); | |
402 } | |
403 | |
404 | |
405 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
406 * Called from do_tag(). |
7 | 407 */ |
408 void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
409 cs_print_tags(void) |
7 | 410 { |
411 cs_manage_matches(NULL, NULL, -1, Print); | |
412 } | |
413 | |
414 | |
415 /* | |
416 * "cscope_connection([{num} , {dbpath} [, {prepend}]])" function | |
417 * | |
418 * Checks for the existence of a |cscope| connection. If no | |
419 * parameters are specified, then the function returns: | |
420 * | |
421 * 0, if cscope was not available (not compiled in), or if there | |
422 * are no cscope connections; or | |
423 * 1, if there is at least one cscope connection. | |
424 * | |
425 * If parameters are specified, then the value of {num} | |
426 * determines how existence of a cscope connection is checked: | |
427 * | |
428 * {num} Description of existence check | |
429 * ----- ------------------------------ | |
430 * 0 Same as no parameters (e.g., "cscope_connection()"). | |
431 * 1 Ignore {prepend}, and use partial string matches for | |
432 * {dbpath}. | |
433 * 2 Ignore {prepend}, and use exact string matches for | |
434 * {dbpath}. | |
435 * 3 Use {prepend}, use partial string matches for both | |
436 * {dbpath} and {prepend}. | |
437 * 4 Use {prepend}, use exact string matches for both | |
438 * {dbpath} and {prepend}. | |
439 * | |
440 * Note: All string comparisons are case sensitive! | |
441 */ | |
442 #if defined(FEAT_EVAL) || defined(PROTO) | |
17986
5c8906f653f5
patch 8.1.1989: the evalfunc.c file is still too big
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
443 static int |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
444 cs_connection(int num, char_u *dbpath, char_u *ppath) |
7 | 445 { |
446 int i; | |
447 | |
448 if (num < 0 || num > 4 || (num > 0 && !dbpath)) | |
449 return FALSE; | |
450 | |
1931 | 451 for (i = 0; i < csinfo_size; i++) |
7 | 452 { |
453 if (!csinfo[i].fname) | |
454 continue; | |
455 | |
456 if (num == 0) | |
457 return TRUE; | |
458 | |
459 switch (num) | |
460 { | |
461 case 1: | |
462 if (strstr(csinfo[i].fname, (char *)dbpath)) | |
463 return TRUE; | |
464 break; | |
465 case 2: | |
466 if (strcmp(csinfo[i].fname, (char *)dbpath) == 0) | |
467 return TRUE; | |
468 break; | |
469 case 3: | |
470 if (strstr(csinfo[i].fname, (char *)dbpath) | |
471 && ((!ppath && !csinfo[i].ppath) | |
472 || (ppath | |
473 && csinfo[i].ppath | |
474 && strstr(csinfo[i].ppath, (char *)ppath)))) | |
475 return TRUE; | |
476 break; | |
477 case 4: | |
478 if ((strcmp(csinfo[i].fname, (char *)dbpath) == 0) | |
479 && ((!ppath && !csinfo[i].ppath) | |
480 || (ppath | |
481 && csinfo[i].ppath | |
482 && (strcmp(csinfo[i].ppath, (char *)ppath) == 0)))) | |
483 return TRUE; | |
484 break; | |
485 } | |
486 } | |
487 | |
488 return FALSE; | |
17986
5c8906f653f5
patch 8.1.1989: the evalfunc.c file is still too big
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
489 } |
5c8906f653f5
patch 8.1.1989: the evalfunc.c file is still too big
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
490 |
7 | 491 #endif |
492 | |
493 | |
494 /* | |
495 * PRIVATE functions | |
496 ****************************************************************************/ | |
497 | |
498 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
499 * Add cscope database or a directory name (to look for cscope.out) |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
500 * to the cscope connection list. |
7 | 501 */ |
502 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
503 cs_add(exarg_T *eap UNUSED) |
7 | 504 { |
505 char *fname, *ppath, *flags = NULL; | |
506 | |
507 if ((fname = strtok((char *)NULL, (const char *)" ")) == NULL) | |
508 { | |
509 cs_usage_msg(Add); | |
510 return CSCOPE_FAILURE; | |
511 } | |
512 if ((ppath = strtok((char *)NULL, (const char *)" ")) != NULL) | |
513 flags = strtok((char *)NULL, (const char *)" "); | |
514 | |
515 return cs_add_common(fname, ppath, flags); | |
516 } | |
517 | |
518 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
519 cs_stat_emsg(char *fname) |
7 | 520 { |
26055
109e9272cd5c
patch 8.2.3561: cscope has a complicated way of giving an error message
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
521 int err = errno; |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
522 (void)semsg(_(e_stat_str_error_nr), fname, err); |
7 | 523 } |
524 | |
525 | |
526 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
527 * The common routine to add a new cscope connection. Called by |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
528 * cs_add() and cs_reset(). I really don't like to do this, but this |
7 | 529 * routine uses a number of goto statements. |
530 */ | |
531 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
532 cs_add_common( |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
533 char *arg1, // filename - may contain environment variables |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
534 char *arg2, // prepend path - may contain environment variables |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
535 char *flags) |
7 | 536 { |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9340
diff
changeset
|
537 stat_T statbuf; |
12 | 538 int ret; |
539 char *fname = NULL; | |
540 char *fname2 = NULL; | |
541 char *ppath = NULL; | |
542 int i; | |
4867
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
543 int len; |
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
544 int usedlen = 0; |
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
545 char_u *fbuf = NULL; |
7 | 546 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
547 // get the filename (arg1), expand it, and try to stat it |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
548 if ((fname = alloc(MAXPATHL + 1)) == NULL) |
7 | 549 goto add_err; |
550 | |
551 expand_env((char_u *)arg1, (char_u *)fname, MAXPATHL); | |
4867
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
552 len = (int)STRLEN(fname); |
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
553 fbuf = (char_u *)fname; |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
554 (void)modify_fname((char_u *)":p", FALSE, &usedlen, |
4867
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
555 (char_u **)&fname, &fbuf, &len); |
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
556 if (fname == NULL) |
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
557 goto add_err; |
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
558 fname = (char *)vim_strnsave((char_u *)fname, len); |
04b8912a9c85
updated for version 7.3.1180
Bram Moolenaar <bram@vim.org>
parents:
4581
diff
changeset
|
559 vim_free(fbuf); |
17966
46f95606b9ec
patch 8.1.1979: code for handling file names is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
560 |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9340
diff
changeset
|
561 ret = mch_stat(fname, &statbuf); |
7 | 562 if (ret < 0) |
563 { | |
564 staterr: | |
565 if (p_csverbose) | |
566 cs_stat_emsg(fname); | |
567 goto add_err; | |
568 } | |
569 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
570 // get the prepend path (arg2), expand it, and try to stat it |
7 | 571 if (arg2 != NULL) |
572 { | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9340
diff
changeset
|
573 stat_T statbuf2; |
7 | 574 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
575 if ((ppath = alloc(MAXPATHL + 1)) == NULL) |
7 | 576 goto add_err; |
577 | |
578 expand_env((char_u *)arg2, (char_u *)ppath, MAXPATHL); | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9340
diff
changeset
|
579 ret = mch_stat(ppath, &statbuf2); |
7 | 580 if (ret < 0) |
581 goto staterr; | |
582 } | |
583 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
584 // if filename is a directory, append the cscope database name to it |
14509
80f715651c4c
patch 8.1.0268: file type checking has too many #ifdef
Christian Brabandt <cb@256bit.org>
parents:
14393
diff
changeset
|
585 if (S_ISDIR(statbuf.st_mode)) |
7 | 586 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
587 fname2 = alloc(strlen(CSCOPE_DBFILE) + strlen(fname) + 2); |
7 | 588 if (fname2 == NULL) |
589 goto add_err; | |
590 | |
591 while (fname[strlen(fname)-1] == '/' | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
592 #ifdef MSWIN |
7 | 593 || fname[strlen(fname)-1] == '\\' |
594 #endif | |
595 ) | |
596 { | |
597 fname[strlen(fname)-1] = '\0'; | |
2278
0b3be97064e5
Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents:
2151
diff
changeset
|
598 if (fname[0] == '\0') |
7 | 599 break; |
600 } | |
601 if (fname[0] == '\0') | |
602 (void)sprintf(fname2, "/%s", CSCOPE_DBFILE); | |
603 else | |
604 (void)sprintf(fname2, "%s/%s", fname, CSCOPE_DBFILE); | |
605 | |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9340
diff
changeset
|
606 ret = mch_stat(fname2, &statbuf); |
7 | 607 if (ret < 0) |
608 { | |
609 if (p_csverbose) | |
610 cs_stat_emsg(fname2); | |
611 goto add_err; | |
612 } | |
613 | |
614 i = cs_insert_filelist(fname2, ppath, flags, &statbuf); | |
615 } | |
616 else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) | |
617 { | |
618 i = cs_insert_filelist(fname, ppath, flags, &statbuf); | |
619 } | |
620 else | |
621 { | |
622 if (p_csverbose) | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
623 (void)semsg(_(e_str_is_not_directory_or_valid_cscope_database), |
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
624 fname); |
7 | 625 goto add_err; |
626 } | |
627 | |
628 if (i != -1) | |
629 { | |
630 if (cs_create_connection(i) == CSCOPE_FAILURE | |
631 || cs_read_prompt(i) == CSCOPE_FAILURE) | |
632 { | |
633 cs_release_csp(i, TRUE); | |
634 goto add_err; | |
635 } | |
636 | |
637 if (p_csverbose) | |
638 { | |
639 msg_clr_eos(); | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
640 (void)smsg_attr(HL_ATTR(HLF_R), |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
641 _("Added cscope database %s"), |
7 | 642 csinfo[i].fname); |
643 } | |
644 } | |
645 | |
646 vim_free(fname); | |
647 vim_free(fname2); | |
648 vim_free(ppath); | |
649 return CSCOPE_SUCCESS; | |
650 | |
651 add_err: | |
652 vim_free(fname2); | |
653 vim_free(fname); | |
654 vim_free(ppath); | |
655 return CSCOPE_FAILURE; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
656 } |
7 | 657 |
658 | |
659 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
660 cs_check_for_connections(void) |
7 | 661 { |
662 return (cs_cnt_connections() > 0); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
663 } |
7 | 664 |
665 | |
666 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
667 cs_check_for_tags(void) |
7 | 668 { |
301 | 669 return (p_tags[0] != NUL && curbuf->b_p_tags != NULL); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
670 } |
7 | 671 |
672 | |
673 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
674 * Count the number of cscope connections. |
7 | 675 */ |
676 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
677 cs_cnt_connections(void) |
7 | 678 { |
27451
c1da76214cca
patch 8.2.4254: using short instead of int
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
679 int i; |
c1da76214cca
patch 8.2.4254: using short instead of int
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
680 int cnt = 0; |
7 | 681 |
1931 | 682 for (i = 0; i < csinfo_size; i++) |
7 | 683 if (csinfo[i].fname != NULL) |
684 cnt++; | |
685 return cnt; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
686 } |
7 | 687 |
688 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
689 cs_reading_emsg( |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
690 int idx) // connection index |
7 | 691 { |
26897
d02d40f0261c
patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26893
diff
changeset
|
692 semsg(_(e_error_reading_cscope_connection_nr), idx); |
7 | 693 } |
694 | |
695 #define CSREAD_BUFSIZE 2048 | |
696 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
697 * Count the number of matches for a given cscope connection. |
7 | 698 */ |
699 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
700 cs_cnt_matches(int idx) |
7 | 701 { |
702 char *stok; | |
703 char *buf; | |
13130
161b5fe12b11
patch 8.0.1439: if cscope fails a search Vim may hang
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
704 int nlines = 0; |
7 | 705 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
706 buf = alloc(CSREAD_BUFSIZE); |
7 | 707 if (buf == NULL) |
708 return 0; | |
709 for (;;) | |
710 { | |
711 if (!fgets(buf, CSREAD_BUFSIZE, csinfo[idx].fr_fp)) | |
712 { | |
713 if (feof(csinfo[idx].fr_fp)) | |
714 errno = EIO; | |
715 | |
716 cs_reading_emsg(idx); | |
717 | |
718 vim_free(buf); | |
719 return -1; | |
720 } | |
721 | |
722 /* | |
723 * If the database is out of date, or there's some other problem, | |
724 * cscope will output error messages before the number-of-lines output. | |
725 * Display/discard any output that doesn't match what we want. | |
1058 | 726 * Accept "\S*cscope: X lines", also matches "mlcscope". |
13130
161b5fe12b11
patch 8.0.1439: if cscope fails a search Vim may hang
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
727 * Bail out for the "Unable to search" error. |
7 | 728 */ |
13136
bc735a129ea9
patch 8.0.1442: using pointer before it is set
Christian Brabandt <cb@256bit.org>
parents:
13130
diff
changeset
|
729 if (strstr((const char *)buf, "Unable to search database") != NULL) |
13130
161b5fe12b11
patch 8.0.1439: if cscope fails a search Vim may hang
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
730 break; |
7 | 731 if ((stok = strtok(buf, (const char *)" ")) == NULL) |
732 continue; | |
1058 | 733 if (strstr((const char *)stok, "cscope:") == NULL) |
7 | 734 continue; |
735 | |
736 if ((stok = strtok(NULL, (const char *)" ")) == NULL) | |
737 continue; | |
738 nlines = atoi(stok); | |
739 if (nlines < 0) | |
740 { | |
741 nlines = 0; | |
742 break; | |
743 } | |
744 | |
745 if ((stok = strtok(NULL, (const char *)" ")) == NULL) | |
746 continue; | |
747 if (strncmp((const char *)stok, "lines", 5)) | |
748 continue; | |
749 | |
750 break; | |
751 } | |
752 | |
753 vim_free(buf); | |
754 return nlines; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
755 } |
7 | 756 |
757 | |
758 /* | |
759 * Creates the actual cscope command query from what the user entered. | |
760 */ | |
761 static char * | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
762 cs_create_cmd(char *csoption, char *pattern) |
7 | 763 { |
764 char *cmd; | |
765 short search; | |
1847 | 766 char *pat; |
7 | 767 |
768 switch (csoption[0]) | |
769 { | |
770 case '0' : case 's' : | |
771 search = 0; | |
772 break; | |
773 case '1' : case 'g' : | |
774 search = 1; | |
775 break; | |
776 case '2' : case 'd' : | |
777 search = 2; | |
778 break; | |
779 case '3' : case 'c' : | |
780 search = 3; | |
781 break; | |
782 case '4' : case 't' : | |
783 search = 4; | |
784 break; | |
785 case '6' : case 'e' : | |
786 search = 6; | |
787 break; | |
788 case '7' : case 'f' : | |
789 search = 7; | |
790 break; | |
791 case '8' : case 'i' : | |
792 search = 8; | |
793 break; | |
9340
387cd517939f
commit https://github.com/vim/vim/commit/b12e7ef956e0b0344778b7ef93d41f4b4ed2a670
Christian Brabandt <cb@256bit.org>
parents:
8234
diff
changeset
|
794 case '9' : case 'a' : |
387cd517939f
commit https://github.com/vim/vim/commit/b12e7ef956e0b0344778b7ef93d41f4b4ed2a670
Christian Brabandt <cb@256bit.org>
parents:
8234
diff
changeset
|
795 search = 9; |
387cd517939f
commit https://github.com/vim/vim/commit/b12e7ef956e0b0344778b7ef93d41f4b4ed2a670
Christian Brabandt <cb@256bit.org>
parents:
8234
diff
changeset
|
796 break; |
7 | 797 default : |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
798 (void)emsg(_(e_unknown_cscope_search_type)); |
7 | 799 cs_usage_msg(Find); |
800 return NULL; | |
801 } | |
802 | |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
803 // Skip white space before the pattern, except for text and pattern search, |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
804 // they may want to use the leading white space. |
1847 | 805 pat = pattern; |
806 if (search != 4 && search != 6) | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11063
diff
changeset
|
807 while VIM_ISWHITE(*pat) |
1847 | 808 ++pat; |
809 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
810 if ((cmd = alloc(strlen(pat) + 2)) == NULL) |
7 | 811 return NULL; |
812 | |
1847 | 813 (void)sprintf(cmd, "%d%s", search, pat); |
7 | 814 |
815 return cmd; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
816 } |
7 | 817 |
818 | |
819 /* | |
820 * This piece of code was taken/adapted from nvi. do we need to add | |
821 * the BSD license notice? | |
822 */ | |
823 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
824 cs_create_connection(int i) |
7 | 825 { |
1385 | 826 #ifdef UNIX |
827 int to_cs[2], from_cs[2]; | |
828 #endif | |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
829 int cmdlen; |
1385 | 830 int len; |
831 char *prog, *cmd, *ppath = NULL; | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
832 #ifdef MSWIN |
1385 | 833 int fd; |
834 SECURITY_ATTRIBUTES sa; | |
835 PROCESS_INFORMATION pi; | |
836 STARTUPINFO si; | |
837 BOOL pipe_stdin = FALSE, pipe_stdout = FALSE; | |
838 HANDLE stdin_rd, stdout_rd; | |
839 HANDLE stdout_wr, stdin_wr; | |
840 BOOL created; | |
7 | 841 #endif |
842 | |
1385 | 843 #if defined(UNIX) |
7 | 844 /* |
845 * Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from | |
846 * from_cs[0] and writes to to_cs[1]. | |
847 */ | |
848 to_cs[0] = to_cs[1] = from_cs[0] = from_cs[1] = -1; | |
849 if (pipe(to_cs) < 0 || pipe(from_cs) < 0) | |
850 { | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
851 (void)emsg(_(e_could_not_create_cscope_pipes)); |
7 | 852 err_closing: |
853 if (to_cs[0] != -1) | |
854 (void)close(to_cs[0]); | |
855 if (to_cs[1] != -1) | |
856 (void)close(to_cs[1]); | |
857 if (from_cs[0] != -1) | |
858 (void)close(from_cs[0]); | |
859 if (from_cs[1] != -1) | |
860 (void)close(from_cs[1]); | |
861 return CSCOPE_FAILURE; | |
862 } | |
863 | |
27104
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
864 if ((csinfo[i].pid = fork()) == -1) |
7 | 865 { |
26948
51ddf6740ac6
patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
866 (void)emsg(_(e_could_not_fork_for_cscope)); |
7 | 867 goto err_closing; |
27104
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
868 } |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
869 else if (csinfo[i].pid == 0) // child: run cscope. |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
870 { |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
871 char **argv = NULL; |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
872 int argc = 0; |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
873 |
7 | 874 if (dup2(to_cs[0], STDIN_FILENO) == -1) |
875 PERROR("cs_create_connection 1"); | |
876 if (dup2(from_cs[1], STDOUT_FILENO) == -1) | |
877 PERROR("cs_create_connection 2"); | |
878 if (dup2(from_cs[1], STDERR_FILENO) == -1) | |
879 PERROR("cs_create_connection 3"); | |
880 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
881 // close unused |
7 | 882 (void)close(to_cs[1]); |
883 (void)close(from_cs[0]); | |
884 #else | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
885 // MSWIN |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
886 // Create pipes to communicate with cscope |
1385 | 887 sa.nLength = sizeof(SECURITY_ATTRIBUTES); |
888 sa.bInheritHandle = TRUE; | |
889 sa.lpSecurityDescriptor = NULL; | |
890 | |
891 if (!(pipe_stdin = CreatePipe(&stdin_rd, &stdin_wr, &sa, 0)) | |
892 || !(pipe_stdout = CreatePipe(&stdout_rd, &stdout_wr, &sa, 0))) | |
893 { | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
894 (void)emsg(_(e_could_not_create_cscope_pipes)); |
1385 | 895 err_closing: |
896 if (pipe_stdin) | |
897 { | |
898 CloseHandle(stdin_rd); | |
899 CloseHandle(stdin_wr); | |
900 } | |
901 if (pipe_stdout) | |
902 { | |
903 CloseHandle(stdout_rd); | |
904 CloseHandle(stdout_wr); | |
905 } | |
906 return CSCOPE_FAILURE; | |
907 } | |
7 | 908 #endif |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
909 // expand the cscope exec for env var's |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
910 if ((prog = alloc(MAXPATHL + 1)) == NULL) |
7 | 911 { |
912 #ifdef UNIX | |
27104
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
913 exit(EXIT_FAILURE); |
7 | 914 #else |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
915 // MSWIN |
7 | 916 goto err_closing; |
917 #endif | |
918 } | |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27342
diff
changeset
|
919 expand_env(p_csprg, (char_u *)prog, MAXPATHL); |
7 | 920 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
921 // alloc space to hold the cscope command |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
922 cmdlen = (int)(strlen(prog) + strlen(csinfo[i].fname) + 32); |
7 | 923 if (csinfo[i].ppath) |
924 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
925 // expand the prepend path for env var's |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
926 if ((ppath = alloc(MAXPATHL + 1)) == NULL) |
7 | 927 { |
928 vim_free(prog); | |
929 #ifdef UNIX | |
27104
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
930 exit(EXIT_FAILURE); |
7 | 931 #else |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
932 // MSWIN |
7 | 933 goto err_closing; |
934 #endif | |
935 } | |
936 expand_env((char_u *)csinfo[i].ppath, (char_u *)ppath, MAXPATHL); | |
937 | |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
938 cmdlen += (int)strlen(ppath); |
7 | 939 } |
940 | |
941 if (csinfo[i].flags) | |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
942 cmdlen += (int)strlen(csinfo[i].flags); |
7 | 943 |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
944 if ((cmd = alloc(cmdlen)) == NULL) |
7 | 945 { |
946 vim_free(prog); | |
947 vim_free(ppath); | |
948 #ifdef UNIX | |
27104
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
949 exit(EXIT_FAILURE); |
7 | 950 #else |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
951 // MSWIN |
7 | 952 goto err_closing; |
953 #endif | |
954 } | |
955 | |
27104
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
956 // run the cscope command |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
957 #ifdef UNIX |
30817
e95794dadf52
patch 9.0.0743: starting cscope on Unix does not quote the arguments right
Bram Moolenaar <Bram@vim.org>
parents:
30600
diff
changeset
|
958 vim_snprintf(cmd, cmdlen, "/bin/sh -c \"exec %s -dl -f %s", |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
959 prog, csinfo[i].fname); |
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
960 #else |
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
961 vim_snprintf(cmd, cmdlen, "%s -dl -f %s", prog, csinfo[i].fname); |
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
962 #endif |
7 | 963 if (csinfo[i].ppath != NULL) |
964 { | |
30600
33a3f63785db
patch 9.0.0635: build error and compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
30497
diff
changeset
|
965 len = (int)STRLEN(cmd); |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
966 vim_snprintf(cmd + len, cmdlen - len, " -P%s", csinfo[i].ppath); |
7 | 967 } |
968 if (csinfo[i].flags != NULL) | |
969 { | |
30600
33a3f63785db
patch 9.0.0635: build error and compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
30497
diff
changeset
|
970 len = (int)STRLEN(cmd); |
30497
1b9abc263eb3
patch 9.0.0584: cscope test with wrong executable name fails
Bram Moolenaar <Bram@vim.org>
parents:
29960
diff
changeset
|
971 vim_snprintf(cmd + len, cmdlen - len, " %s", csinfo[i].flags); |
7 | 972 } |
973 # ifdef UNIX | |
30817
e95794dadf52
patch 9.0.0743: starting cscope on Unix does not quote the arguments right
Bram Moolenaar <Bram@vim.org>
parents:
30600
diff
changeset
|
974 // terminate the -c command argument |
e95794dadf52
patch 9.0.0743: starting cscope on Unix does not quote the arguments right
Bram Moolenaar <Bram@vim.org>
parents:
30600
diff
changeset
|
975 STRCAT(cmd, "\""); |
e95794dadf52
patch 9.0.0743: starting cscope on Unix does not quote the arguments right
Bram Moolenaar <Bram@vim.org>
parents:
30600
diff
changeset
|
976 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
977 // on Win32 we still need prog |
7 | 978 vim_free(prog); |
979 # endif | |
980 vim_free(ppath); | |
981 | |
982 #if defined(UNIX) | |
5066
d2f9f67924e7
updated for version 7.3.1276
Bram Moolenaar <bram@vim.org>
parents:
4867
diff
changeset
|
983 # if defined(HAVE_SETSID) || defined(HAVE_SETPGID) |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
984 // Change our process group to avoid cscope receiving SIGWINCH. |
5066
d2f9f67924e7
updated for version 7.3.1276
Bram Moolenaar <bram@vim.org>
parents:
4867
diff
changeset
|
985 # if defined(HAVE_SETSID) |
d2f9f67924e7
updated for version 7.3.1276
Bram Moolenaar <bram@vim.org>
parents:
4867
diff
changeset
|
986 (void)setsid(); |
d2f9f67924e7
updated for version 7.3.1276
Bram Moolenaar <bram@vim.org>
parents:
4867
diff
changeset
|
987 # else |
d2f9f67924e7
updated for version 7.3.1276
Bram Moolenaar <bram@vim.org>
parents:
4867
diff
changeset
|
988 if (setpgid(0, 0) == -1) |
d2f9f67924e7
updated for version 7.3.1276
Bram Moolenaar <bram@vim.org>
parents:
4867
diff
changeset
|
989 PERROR(_("cs_create_connection setpgid failed")); |
d2f9f67924e7
updated for version 7.3.1276
Bram Moolenaar <bram@vim.org>
parents:
4867
diff
changeset
|
990 # endif |
d2f9f67924e7
updated for version 7.3.1276
Bram Moolenaar <bram@vim.org>
parents:
4867
diff
changeset
|
991 # endif |
27104
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
992 if (build_argv_from_string((char_u *)cmd, &argv, &argc) == FAIL) |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
993 exit(EXIT_FAILURE); |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
994 |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
995 if (execvp(argv[0], argv) == -1) |
7 | 996 PERROR(_("cs_create_connection exec failed")); |
997 | |
998 exit(127); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
999 // NOTREACHED |
27104
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
1000 } |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
1001 else // parent. |
92e0b1f2b72f
patch 8.2.4081: CodeQL reports problem in if_cscope causing it to fail
Bram Moolenaar <Bram@vim.org>
parents:
26948
diff
changeset
|
1002 { |
7 | 1003 /* |
1004 * Save the file descriptors for later duplication, and | |
1005 * reopen as streams. | |
1006 */ | |
1007 if ((csinfo[i].to_fp = fdopen(to_cs[1], "w")) == NULL) | |
1008 PERROR(_("cs_create_connection: fdopen for to_fp failed")); | |
1009 if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL) | |
1010 PERROR(_("cs_create_connection: fdopen for fr_fp failed")); | |
1011 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1012 // close unused |
7 | 1013 (void)close(to_cs[0]); |
1014 (void)close(from_cs[1]); | |
1015 } | |
1016 #else | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1017 // MSWIN |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1018 // Create a new process to run cscope and use pipes to talk with it |
1385 | 1019 GetStartupInfo(&si); |
1020 si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1021 si.wShowWindow = SW_HIDE; // Hide child application window |
1385 | 1022 si.hStdOutput = stdout_wr; |
1023 si.hStdError = stdout_wr; | |
1024 si.hStdInput = stdin_rd; | |
1025 created = CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, | |
1026 NULL, NULL, &si, &pi); | |
1027 vim_free(prog); | |
1028 vim_free(cmd); | |
1029 | |
1030 if (!created) | |
1031 { | |
1032 PERROR(_("cs_create_connection exec failed")); | |
26948
51ddf6740ac6
patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
1033 (void)emsg(_(e_could_not_spawn_cscope_process)); |
1385 | 1034 goto err_closing; |
1035 } | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1036 // else |
1385 | 1037 csinfo[i].pid = pi.dwProcessId; |
1038 csinfo[i].hProc = pi.hProcess; | |
1039 CloseHandle(pi.hThread); | |
1040 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1041 // TODO - tidy up after failure to create files on pipe handles. |
27342
41a940219183
patch 8.2.4199: MS-Windows: Support for MSVC 2003 is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27104
diff
changeset
|
1042 if (((fd = _open_osfhandle((intptr_t)stdin_wr, |
1393 | 1043 _O_TEXT|_O_APPEND)) < 0) |
1385 | 1044 || ((csinfo[i].to_fp = _fdopen(fd, "w")) == NULL)) |
1045 PERROR(_("cs_create_connection: fdopen for to_fp failed")); | |
27342
41a940219183
patch 8.2.4199: MS-Windows: Support for MSVC 2003 is not useful
Bram Moolenaar <Bram@vim.org>
parents:
27104
diff
changeset
|
1046 if (((fd = _open_osfhandle((intptr_t)stdout_rd, |
1393 | 1047 _O_TEXT|_O_RDONLY)) < 0) |
1385 | 1048 || ((csinfo[i].fr_fp = _fdopen(fd, "r")) == NULL)) |
1049 PERROR(_("cs_create_connection: fdopen for fr_fp failed")); | |
1050 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1051 // Close handles for file descriptors inherited by the cscope process |
1385 | 1052 CloseHandle(stdin_rd); |
1053 CloseHandle(stdout_wr); | |
1054 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1055 #endif // !UNIX |
1385 | 1056 |
7 | 1057 return CSCOPE_SUCCESS; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1058 } |
7 | 1059 |
1060 | |
1061 /* | |
7009 | 1062 * Query cscope using command line interface. Parse the output and use tselect |
1063 * to allow choices. Like Nvi, creates a pipe to send to/from query/cscope. | |
7 | 1064 * |
1065 * returns TRUE if we jump to a tag or abort, FALSE if not. | |
1066 */ | |
1067 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1068 cs_find(exarg_T *eap) |
7 | 1069 { |
1070 char *opt, *pat; | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1071 int i; |
7 | 1072 |
1073 if (cs_check_for_connections() == FALSE) | |
1074 { | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
1075 (void)emsg(_(e_no_cscope_connections)); |
7 | 1076 return FALSE; |
1077 } | |
1078 | |
1079 if ((opt = strtok((char *)NULL, (const char *)" ")) == NULL) | |
1080 { | |
1081 cs_usage_msg(Find); | |
1082 return FALSE; | |
1083 } | |
1084 | |
1085 pat = opt + strlen(opt) + 1; | |
1372 | 1086 if (pat >= (char *)eap->arg + eap_arg_len) |
7 | 1087 { |
1088 cs_usage_msg(Find); | |
1089 return FALSE; | |
1090 } | |
1091 | |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1092 /* |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1093 * Let's replace the NULs written by strtok() with spaces - we need the |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1094 * spaces to correctly display the quickfix/location list window's title. |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1095 */ |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1096 for (i = 0; i < eap_arg_len; ++i) |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1097 if (NUL == eap->arg[i]) |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1098 eap->arg[i] = ' '; |
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1099 |
665 | 1100 return cs_find_common(opt, pat, eap->forceit, TRUE, |
2411
68e394361ca3
Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
1101 eap->cmdidx == CMD_lcscope, *eap->cmdlinep); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1102 } |
7 | 1103 |
1104 | |
1105 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1106 * Common code for cscope find, shared by cs_find() and ex_cstag(). |
7 | 1107 */ |
1108 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1109 cs_find_common( |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1110 char *opt, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1111 char *pat, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1112 int forceit, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1113 int verbose, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1114 int use_ll UNUSED, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1115 char_u *cmdline UNUSED) |
7 | 1116 { |
1117 int i; | |
1118 char *cmd; | |
1931 | 1119 int *nummatches; |
1120 int totmatches; | |
7 | 1121 #ifdef FEAT_QUICKFIX |
1122 char cmdletter; | |
1123 char *qfpos; | |
2151
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1124 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1125 // get cmd letter |
2151
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1126 switch (opt[0]) |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1127 { |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1128 case '0' : |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1129 cmdletter = 's'; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1130 break; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1131 case '1' : |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1132 cmdletter = 'g'; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1133 break; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1134 case '2' : |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1135 cmdletter = 'd'; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1136 break; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1137 case '3' : |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1138 cmdletter = 'c'; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1139 break; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1140 case '4' : |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1141 cmdletter = 't'; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1142 break; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1143 case '6' : |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1144 cmdletter = 'e'; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1145 break; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1146 case '7' : |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1147 cmdletter = 'f'; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1148 break; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1149 case '8' : |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1150 cmdletter = 'i'; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1151 break; |
9340
387cd517939f
commit https://github.com/vim/vim/commit/b12e7ef956e0b0344778b7ef93d41f4b4ed2a670
Christian Brabandt <cb@256bit.org>
parents:
8234
diff
changeset
|
1152 case '9' : |
387cd517939f
commit https://github.com/vim/vim/commit/b12e7ef956e0b0344778b7ef93d41f4b4ed2a670
Christian Brabandt <cb@256bit.org>
parents:
8234
diff
changeset
|
1153 cmdletter = 'a'; |
387cd517939f
commit https://github.com/vim/vim/commit/b12e7ef956e0b0344778b7ef93d41f4b4ed2a670
Christian Brabandt <cb@256bit.org>
parents:
8234
diff
changeset
|
1154 break; |
2151
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1155 default : |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1156 cmdletter = opt[0]; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1157 } |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1158 |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1159 qfpos = (char *)vim_strchr(p_csqf, cmdletter); |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1160 if (qfpos != NULL) |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1161 { |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1162 qfpos++; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1163 // next symbol must be + or - |
2151
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1164 if (strchr(CSQF_FLAGS, *qfpos) == NULL) |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1165 { |
26915
3631d2deb36c
patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26897
diff
changeset
|
1166 (void)semsg(_(e_invalid_cscopequickfix_flag_chr_for_chr), |
3631d2deb36c
patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26897
diff
changeset
|
1167 *qfpos, *(qfpos - 1)); |
2151
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1168 return FALSE; |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1169 } |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1170 |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
1171 if (*qfpos != '0' |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
1172 && apply_autocmds(EVENT_QUICKFIXCMDPRE, (char_u *)"cscope", |
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
1173 curbuf->b_fname, TRUE, curbuf)) |
2151
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1174 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1175 # ifdef FEAT_EVAL |
10346
d52d97bf675e
commit https://github.com/vim/vim/commit/21662be2211675824df1771c7f169948ede40c41
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
1176 if (aborting()) |
2151
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1177 return FALSE; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1178 # endif |
2151
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1179 } |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1180 } |
7 | 1181 #endif |
1182 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1183 // create the actual command to send to cscope |
7 | 1184 cmd = cs_create_cmd(opt, pat); |
1185 if (cmd == NULL) | |
1186 return FALSE; | |
1187 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1188 nummatches = ALLOC_MULT(int, csinfo_size); |
1931 | 1189 if (nummatches == NULL) |
7009 | 1190 { |
1191 vim_free(cmd); | |
1931 | 1192 return FALSE; |
7009 | 1193 } |
1931 | 1194 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1195 // Send query to all open connections, then count the total number |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1196 // of matches so we can alloc all in one swell foop. |
1931 | 1197 for (i = 0; i < csinfo_size; i++) |
7 | 1198 nummatches[i] = 0; |
1199 totmatches = 0; | |
1931 | 1200 for (i = 0; i < csinfo_size; i++) |
7 | 1201 { |
1040 | 1202 if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL) |
7 | 1203 continue; |
1204 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1205 // send cmd to cscope |
7 | 1206 (void)fprintf(csinfo[i].to_fp, "%s\n", cmd); |
1207 (void)fflush(csinfo[i].to_fp); | |
1208 | |
1209 nummatches[i] = cs_cnt_matches(i); | |
1210 | |
1211 if (nummatches[i] > -1) | |
1212 totmatches += nummatches[i]; | |
1213 | |
1214 if (nummatches[i] == 0) | |
1215 (void)cs_read_prompt(i); | |
1216 } | |
1217 vim_free(cmd); | |
1218 | |
1219 if (totmatches == 0) | |
1220 { | |
26055
109e9272cd5c
patch 8.2.3561: cscope has a complicated way of giving an error message
Bram Moolenaar <Bram@vim.org>
parents:
25852
diff
changeset
|
1221 if (verbose) |
26893
79c76ca2c53c
patch 8.2.3975: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
1222 (void)semsg(_(e_no_matches_found_for_cscope_query_str_of_str), |
79c76ca2c53c
patch 8.2.3975: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
1223 opt, pat); |
1931 | 1224 vim_free(nummatches); |
7 | 1225 return FALSE; |
1226 } | |
1227 | |
1228 #ifdef FEAT_QUICKFIX | |
36 | 1229 if (qfpos != NULL && *qfpos != '0' && totmatches > 0) |
7 | 1230 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1231 // fill error list |
1027 | 1232 FILE *f; |
6721 | 1233 char_u *tmp = vim_tempname('c', TRUE); |
665 | 1234 qf_info_T *qi = NULL; |
1235 win_T *wp = NULL; | |
7 | 1236 |
531 | 1237 f = mch_fopen((char *)tmp, "w"); |
1027 | 1238 if (f == NULL) |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26055
diff
changeset
|
1239 semsg(_(e_cant_open_file_str), tmp); |
1027 | 1240 else |
7 | 1241 { |
1027 | 1242 cs_file_results(f, nummatches); |
1243 fclose(f); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1244 if (use_ll) // Use location list |
1027 | 1245 wp = curwin; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1246 // '-' starts a new error list |
1027 | 1247 if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m", |
11063
e71d3bdf3bc3
patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents:
10605
diff
changeset
|
1248 *qfpos == '-', cmdline, NULL) > 0) |
1027 | 1249 { |
1250 if (postponed_split != 0) | |
1251 { | |
7009 | 1252 (void)win_split(postponed_split > 0 ? postponed_split : 0, |
7 | 1253 postponed_split_flags); |
2583 | 1254 RESET_BINDING(curwin); |
1027 | 1255 postponed_split = 0; |
1256 } | |
2151
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1257 |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1258 apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)"cscope", |
ae22c450546c
updated for version 7.2.433
Bram Moolenaar <bram@zimbu.org>
parents:
2087
diff
changeset
|
1259 curbuf->b_fname, TRUE, curbuf); |
1027 | 1260 if (use_ll) |
1261 /* | |
1262 * In the location list window, use the displayed location | |
1263 * list. Otherwise, use the location list for the window. | |
1264 */ | |
1265 qi = (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL) | |
1266 ? wp->w_llist_ref : wp->w_llist; | |
1267 qf_jump(qi, 0, 0, forceit); | |
1268 } | |
7 | 1269 } |
1270 mch_remove(tmp); | |
1271 vim_free(tmp); | |
1931 | 1272 vim_free(nummatches); |
7 | 1273 return TRUE; |
1274 } | |
1275 else | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1276 #endif // FEAT_QUICKFIX |
7 | 1277 { |
944 | 1278 char **matches = NULL, **contexts = NULL; |
1279 int matched = 0; | |
1280 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1281 // read output |
25852
336e2d9924e6
patch 8.2.3460: some type casts are not needed
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1282 cs_fill_results(pat, totmatches, nummatches, &matches, |
7 | 1283 &contexts, &matched); |
1931 | 1284 vim_free(nummatches); |
7 | 1285 if (matches == NULL) |
1286 return FALSE; | |
1287 | |
293 | 1288 (void)cs_manage_matches(matches, contexts, matched, Store); |
7 | 1289 |
1290 return do_tag((char_u *)pat, DT_CSCOPE, 0, forceit, verbose); | |
1291 } | |
1292 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1293 } |
7 | 1294 |
1295 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1296 * Print help. |
7 | 1297 */ |
1298 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1299 cs_help(exarg_T *eap UNUSED) |
7 | 1300 { |
1301 cscmd_T *cmdp = cs_cmds; | |
1302 | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
1303 (void)msg_puts(_("cscope commands:\n")); |
7 | 1304 while (cmdp->name != NULL) |
1305 { | |
1793 | 1306 char *help = _(cmdp->help); |
1307 int space_cnt = 30 - vim_strsize((char_u *)help); | |
1308 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1309 // Use %*s rather than %30s to ensure proper alignment in utf-8 |
1793 | 1310 if (space_cnt < 0) |
1311 space_cnt = 0; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1312 (void)smsg(_("%-5s: %s%*s (Usage: %s)"), |
1793 | 1313 cmdp->name, |
1314 help, space_cnt, " ", | |
1315 cmdp->usage); | |
7 | 1316 if (strcmp(cmdp->name, "find") == 0) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
1317 msg_puts(_("\n" |
9418
6d213bd46cc3
commit https://github.com/vim/vim/commit/80632db65e8f5f775dadbbc10c5ba6c173ebb24f
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
1318 " a: Find assignments to this symbol\n" |
1706 | 1319 " c: Find functions calling this function\n" |
1320 " d: Find functions called by this function\n" | |
1321 " e: Find this egrep pattern\n" | |
1322 " f: Find this file\n" | |
1323 " g: Find this definition\n" | |
1324 " i: Find files #including this file\n" | |
1325 " s: Find this C symbol\n" | |
9418
6d213bd46cc3
commit https://github.com/vim/vim/commit/80632db65e8f5f775dadbbc10c5ba6c173ebb24f
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
1326 " t: Find this text string\n")); |
1706 | 1327 |
7 | 1328 cmdp++; |
1329 } | |
1330 | |
1331 wait_return(TRUE); | |
1332 return 0; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1333 } |
7 | 1334 |
1335 | |
1336 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1337 clear_csinfo(int i) |
7 | 1338 { |
1339 csinfo[i].fname = NULL; | |
1340 csinfo[i].ppath = NULL; | |
1341 csinfo[i].flags = NULL; | |
1342 #if defined(UNIX) | |
1343 csinfo[i].st_dev = (dev_t)0; | |
1344 csinfo[i].st_ino = (ino_t)0; | |
1345 #else | |
1346 csinfo[i].nVolume = 0; | |
1347 csinfo[i].nIndexHigh = 0; | |
1348 csinfo[i].nIndexLow = 0; | |
1349 #endif | |
1621 | 1350 csinfo[i].pid = 0; |
7 | 1351 csinfo[i].fr_fp = NULL; |
1352 csinfo[i].to_fp = NULL; | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1353 #if defined(MSWIN) |
301 | 1354 csinfo[i].hProc = NULL; |
1355 #endif | |
7 | 1356 } |
1357 | |
1358 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1359 * Insert a new cscope database filename into the filelist. |
7 | 1360 */ |
1361 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1362 cs_insert_filelist( |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1363 char *fname, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1364 char *ppath, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1365 char *flags, |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
9340
diff
changeset
|
1366 stat_T *sb UNUSED) |
7 | 1367 { |
27451
c1da76214cca
patch 8.2.4254: using short instead of int
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1368 int i; |
c1da76214cca
patch 8.2.4254: using short instead of int
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1369 int j; |
7 | 1370 #ifndef UNIX |
1371 BY_HANDLE_FILE_INFORMATION bhfi; | |
1372 | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1373 switch (win32_fileinfo((char_u *)fname, &bhfi)) |
7 | 1374 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1375 case FILEINFO_ENC_FAIL: // enc_to_utf16() failed |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1376 case FILEINFO_READ_FAIL: // CreateFile() failed |
7 | 1377 if (p_csverbose) |
1378 { | |
26948
51ddf6740ac6
patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
1379 char *cant_msg = _(e_cannot_open_cscope_database_str); |
7 | 1380 char *winmsg = GetWin32Error(); |
1381 | |
1382 if (winmsg != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1383 (void)semsg(cant_msg, winmsg); |
7 | 1384 else |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1385 // subst filename if can't get error text |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1386 (void)semsg(cant_msg, fname); |
7 | 1387 } |
1388 return -1; | |
2793 | 1389 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1390 case FILEINFO_INFO_FAIL: // GetFileInformationByHandle() failed |
7 | 1391 if (p_csverbose) |
26948
51ddf6740ac6
patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
1392 (void)emsg(_(e_cannot_get_cscope_database_information)); |
7 | 1393 return -1; |
1394 } | |
1395 #endif | |
1396 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1397 i = -1; // can be set to the index of an empty item in csinfo |
1931 | 1398 for (j = 0; j < csinfo_size; j++) |
7 | 1399 { |
1400 if (csinfo[j].fname != NULL | |
1401 #if defined(UNIX) | |
1402 && csinfo[j].st_dev == sb->st_dev && csinfo[j].st_ino == sb->st_ino | |
1403 #else | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1404 // compare pathnames first |
8080
b6cb94ad97a4
commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents:
7823
diff
changeset
|
1405 && ((fullpathcmp((char_u *)csinfo[j].fname, |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1406 (char_u *)fname, FALSE, TRUE) & FPC_SAME) |
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
1407 // test index file attributes too |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
1408 || (csinfo[j].nVolume == bhfi.dwVolumeSerialNumber |
7 | 1409 && csinfo[j].nIndexHigh == bhfi.nFileIndexHigh |
1410 && csinfo[j].nIndexLow == bhfi.nFileIndexLow)) | |
1411 #endif | |
1412 ) | |
1413 { | |
1414 if (p_csverbose) | |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
1415 (void)emsg(_(e_duplicate_cscope_database_not_added)); |
7 | 1416 return -1; |
1417 } | |
1418 | |
1419 if (csinfo[j].fname == NULL && i == -1) | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1420 i = j; // remember first empty entry |
7 | 1421 } |
1422 | |
1423 if (i == -1) | |
1424 { | |
1931 | 1425 i = csinfo_size; |
1426 if (csinfo_size == 0) | |
1427 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1428 // First time allocation: allocate only 1 connection. It should |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1429 // be enough for most users. If more is needed, csinfo will be |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1430 // reallocated. |
1931 | 1431 csinfo_size = 1; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1432 csinfo = ALLOC_CLEAR_ONE(csinfo_T); |
1931 | 1433 } |
1434 else | |
1435 { | |
6596 | 1436 csinfo_T *t_csinfo = csinfo; |
1437 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1438 // Reallocate space for more connections. |
1931 | 1439 csinfo_size *= 2; |
1440 csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size); | |
6596 | 1441 if (csinfo == NULL) |
1442 { | |
1443 vim_free(t_csinfo); | |
1444 csinfo_size = 0; | |
1445 } | |
1931 | 1446 } |
1447 if (csinfo == NULL) | |
1448 return -1; | |
1449 for (j = csinfo_size/2; j < csinfo_size; j++) | |
1450 clear_csinfo(j); | |
7 | 1451 } |
1452 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1453 if ((csinfo[i].fname = alloc(strlen(fname)+1)) == NULL) |
7 | 1454 return -1; |
1455 | |
1456 (void)strcpy(csinfo[i].fname, (const char *)fname); | |
1457 | |
1458 if (ppath != NULL) | |
1459 { | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1460 if ((csinfo[i].ppath = alloc(strlen(ppath) + 1)) == NULL) |
7 | 1461 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13136
diff
changeset
|
1462 VIM_CLEAR(csinfo[i].fname); |
7 | 1463 return -1; |
1464 } | |
1465 (void)strcpy(csinfo[i].ppath, (const char *)ppath); | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31702
diff
changeset
|
1466 } |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31702
diff
changeset
|
1467 else |
7 | 1468 csinfo[i].ppath = NULL; |
1469 | |
1470 if (flags != NULL) | |
1471 { | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1472 if ((csinfo[i].flags = alloc(strlen(flags) + 1)) == NULL) |
7 | 1473 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13136
diff
changeset
|
1474 VIM_CLEAR(csinfo[i].fname); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13136
diff
changeset
|
1475 VIM_CLEAR(csinfo[i].ppath); |
7 | 1476 return -1; |
1477 } | |
1478 (void)strcpy(csinfo[i].flags, (const char *)flags); | |
31804
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31702
diff
changeset
|
1479 } |
50555279168b
patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents:
31702
diff
changeset
|
1480 else |
7 | 1481 csinfo[i].flags = NULL; |
1482 | |
1483 #if defined(UNIX) | |
1484 csinfo[i].st_dev = sb->st_dev; | |
1485 csinfo[i].st_ino = sb->st_ino; | |
1486 | |
1487 #else | |
1488 csinfo[i].nVolume = bhfi.dwVolumeSerialNumber; | |
1489 csinfo[i].nIndexLow = bhfi.nFileIndexLow; | |
1490 csinfo[i].nIndexHigh = bhfi.nFileIndexHigh; | |
1491 #endif | |
1492 return i; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1493 } |
7 | 1494 |
1495 | |
1496 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1497 * Find cscope command in command table. |
7 | 1498 */ |
1499 static cscmd_T * | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1500 cs_lookup_cmd(exarg_T *eap) |
7 | 1501 { |
1502 cscmd_T *cmdp; | |
1503 char *stok; | |
1504 size_t len; | |
1505 | |
1506 if (eap->arg == NULL) | |
1507 return NULL; | |
1508 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1509 // Store length of eap->arg before it gets modified by strtok(). |
1570 | 1510 eap_arg_len = (int)STRLEN(eap->arg); |
1372 | 1511 |
7 | 1512 if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL) |
1513 return NULL; | |
1514 | |
1515 len = strlen(stok); | |
1516 for (cmdp = cs_cmds; cmdp->name != NULL; ++cmdp) | |
1517 { | |
1518 if (strncmp((const char *)(stok), cmdp->name, len) == 0) | |
1519 return (cmdp); | |
1520 } | |
1521 return NULL; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1522 } |
7 | 1523 |
1524 | |
1525 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1526 * Nuke em. |
7 | 1527 */ |
1528 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1529 cs_kill(exarg_T *eap UNUSED) |
7 | 1530 { |
1531 char *stok; | |
27451
c1da76214cca
patch 8.2.4254: using short instead of int
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
1532 int i; |
7 | 1533 |
1534 if ((stok = strtok((char *)NULL, (const char *)" ")) == NULL) | |
1535 { | |
1536 cs_usage_msg(Kill); | |
1537 return CSCOPE_FAILURE; | |
1538 } | |
1539 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1540 // only single digit positive and negative integers are allowed |
7 | 1541 if ((strlen(stok) < 2 && VIM_ISDIGIT((int)(stok[0]))) |
1542 || (strlen(stok) < 3 && stok[0] == '-' | |
1543 && VIM_ISDIGIT((int)(stok[1])))) | |
1544 i = atoi(stok); | |
1545 else | |
1546 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1547 // It must be part of a name. We will try to find a match |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1548 // within all the names in the csinfo data structure |
1931 | 1549 for (i = 0; i < csinfo_size; i++) |
7 | 1550 { |
1551 if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok)) | |
1552 break; | |
1553 } | |
1554 } | |
1555 | |
1931 | 1556 if ((i != -1) && (i >= csinfo_size || i < -1 || csinfo[i].fname == NULL)) |
7 | 1557 { |
1558 if (p_csverbose) | |
26897
d02d40f0261c
patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26893
diff
changeset
|
1559 (void)semsg(_(e_cscope_connection_str_not_founc), stok); |
7 | 1560 } |
1561 else | |
1562 { | |
1563 if (i == -1) | |
1564 { | |
1931 | 1565 for (i = 0; i < csinfo_size; i++) |
7 | 1566 { |
1567 if (csinfo[i].fname) | |
1568 cs_kill_execute(i, csinfo[i].fname); | |
1569 } | |
1570 } | |
1571 else | |
1572 cs_kill_execute(i, stok); | |
1573 } | |
1574 | |
1575 return 0; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1576 } |
7 | 1577 |
1578 | |
1579 /* | |
1580 * Actually kills a specific cscope connection. | |
1581 */ | |
1582 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1583 cs_kill_execute( |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1584 int i, // cscope table index |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1585 char *cname) // cscope database name |
7 | 1586 { |
1587 if (p_csverbose) | |
1588 { | |
1589 msg_clr_eos(); | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
1590 (void)smsg_attr(HL_ATTR(HLF_R) | MSG_HIST, |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
1591 _("cscope connection %s closed"), cname); |
7 | 1592 } |
1593 cs_release_csp(i, TRUE); | |
1594 } | |
1595 | |
1596 | |
1597 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1598 * Convert the cscope output into a ctags style entry (as might be found |
7 | 1599 * in a ctags tags file). there's one catch though: cscope doesn't tell you |
1600 * the type of the tag you are looking for. for example, in Darren Hiebert's | |
1601 * ctags (the one that comes with vim), #define's use a line number to find the | |
1602 * tag in a file while function definitions use a regexp search pattern. | |
1603 * | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1604 * I'm going to always use the line number because cscope does something |
7 | 1605 * quirky (and probably other things i don't know about): |
1606 * | |
1607 * if you have "# define" in your source file, which is | |
1608 * perfectly legal, cscope thinks you have "#define". this | |
1609 * will result in a failed regexp search. :( | |
1610 * | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1611 * Besides, even if this particular case didn't happen, the search pattern |
7 | 1612 * would still have to be modified to escape all the special regular expression |
1613 * characters to comply with ctags formatting. | |
1614 */ | |
1615 static char * | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1616 cs_make_vim_style_matches( |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1617 char *fname, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1618 char *slno, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1619 char *search, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1620 char *tagstr) |
7 | 1621 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1622 // vim style is ctags: |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1623 // |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1624 // <tagstr>\t<filename>\t<linenum_or_search>"\t<extra> |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1625 // |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1626 // but as mentioned above, we'll always use the line number and |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1627 // put the search pattern (if one exists) as "extra" |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1628 // |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1629 // buf is used as part of vim's method of handling tags, and |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1630 // (i think) vim frees it when you pop your tags and get replaced |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1631 // by new ones on the tag stack. |
7 | 1632 char *buf; |
1633 int amt; | |
1634 | |
1635 if (search != NULL) | |
1636 { | |
835 | 1637 amt = (int)(strlen(fname) + strlen(slno) + strlen(tagstr) + strlen(search)+6); |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1638 if ((buf = alloc(amt)) == NULL) |
7 | 1639 return NULL; |
1640 | |
1641 (void)sprintf(buf, "%s\t%s\t%s;\"\t%s", tagstr, fname, slno, search); | |
1642 } | |
1643 else | |
1644 { | |
835 | 1645 amt = (int)(strlen(fname) + strlen(slno) + strlen(tagstr) + 5); |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1646 if ((buf = alloc(amt)) == NULL) |
7 | 1647 return NULL; |
1648 | |
1649 (void)sprintf(buf, "%s\t%s\t%s;\"", tagstr, fname, slno); | |
1650 } | |
1651 | |
1652 return buf; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1653 } |
7 | 1654 |
1655 | |
1656 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1657 * This is kind of hokey, but i don't see an easy way round this. |
7 | 1658 * |
1659 * Store: keep a ptr to the (malloc'd) memory of matches originally | |
1660 * generated from cs_find(). the matches are originally lines directly | |
1661 * from cscope output, but transformed to look like something out of a | |
1662 * ctags. see cs_make_vim_style_matches for more details. | |
1663 * | |
1664 * Get: used only from cs_fgets(), this simulates a vim_fgets() to return | |
1665 * the next line from the cscope output. it basically keeps track of which | |
1666 * lines have been "used" and returns the next one. | |
1667 * | |
1668 * Free: frees up everything and resets | |
1669 * | |
1670 * Print: prints the tags | |
1671 */ | |
1672 static char * | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1673 cs_manage_matches( |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1674 char **matches, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1675 char **contexts, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1676 int totmatches, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1677 mcmd_e cmd) |
7 | 1678 { |
1679 static char **mp = NULL; | |
1680 static char **cp = NULL; | |
1681 static int cnt = -1; | |
1682 static int next = -1; | |
1683 char *p = NULL; | |
1684 | |
1685 switch (cmd) | |
1686 { | |
1687 case Store: | |
1688 assert(matches != NULL); | |
1689 assert(totmatches > 0); | |
1690 if (mp != NULL || cp != NULL) | |
1691 (void)cs_manage_matches(NULL, NULL, -1, Free); | |
1692 mp = matches; | |
1693 cp = contexts; | |
1694 cnt = totmatches; | |
1695 next = 0; | |
1696 break; | |
1697 case Get: | |
1698 if (next >= cnt) | |
1699 return NULL; | |
1700 | |
1701 p = mp[next]; | |
1702 next++; | |
1703 break; | |
1704 case Free: | |
1705 if (mp != NULL) | |
1706 { | |
1707 if (cnt > 0) | |
1708 while (cnt--) | |
1709 { | |
1710 vim_free(mp[cnt]); | |
1711 if (cp != NULL) | |
1712 vim_free(cp[cnt]); | |
1713 } | |
1714 vim_free(mp); | |
1715 vim_free(cp); | |
1716 } | |
1717 mp = NULL; | |
1718 cp = NULL; | |
1719 cnt = 0; | |
1720 next = 0; | |
1721 break; | |
1722 case Print: | |
1723 cs_print_tags_priv(mp, cp, cnt); | |
1724 break; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1725 default: // should not reach here |
26917
d91aea2a612c
patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26915
diff
changeset
|
1726 iemsg(_(e_fatal_error_in_cs_manage_matches)); |
7 | 1727 return NULL; |
1728 } | |
1729 | |
1730 return p; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1731 } |
7 | 1732 |
1733 | |
1734 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1735 * Parse cscope output. |
7 | 1736 */ |
1737 static char * | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1738 cs_parse_results( |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1739 int cnumber, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1740 char *buf, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1741 int bufsize, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1742 char **context, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1743 char **linenumber, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1744 char **search) |
7 | 1745 { |
1746 int ch; | |
1747 char *p; | |
1748 char *name; | |
1749 | |
1750 if (fgets(buf, bufsize, csinfo[cnumber].fr_fp) == NULL) | |
1751 { | |
1752 if (feof(csinfo[cnumber].fr_fp)) | |
1753 errno = EIO; | |
1754 | |
1755 cs_reading_emsg(cnumber); | |
1756 | |
1757 return NULL; | |
1758 } | |
1759 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1760 // If the line's too long for the buffer, discard it. |
7 | 1761 if ((p = strchr(buf, '\n')) == NULL) |
1762 { | |
1763 while ((ch = getc(csinfo[cnumber].fr_fp)) != EOF && ch != '\n') | |
1764 ; | |
1765 return NULL; | |
1766 } | |
1767 *p = '\0'; | |
1768 | |
1769 /* | |
1770 * cscope output is in the following format: | |
1771 * | |
1772 * <filename> <context> <line number> <pattern> | |
1773 */ | |
25852
336e2d9924e6
patch 8.2.3460: some type casts are not needed
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1774 if ((name = strtok(buf, (const char *)" ")) == NULL) |
7 | 1775 return NULL; |
1776 if ((*context = strtok(NULL, (const char *)" ")) == NULL) | |
1777 return NULL; | |
1778 if ((*linenumber = strtok(NULL, (const char *)" ")) == NULL) | |
1779 return NULL; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1780 *search = *linenumber + strlen(*linenumber) + 1; // +1 to skip \0 |
7 | 1781 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1782 // --- nvi --- |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1783 // If the file is older than the cscope database, that is, |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1784 // the database was built since the file was last modified, |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1785 // or there wasn't a search string, use the line number. |
7 | 1786 if (strcmp(*search, "<unknown>") == 0) |
1787 *search = NULL; | |
1788 | |
1789 name = cs_resolve_file(cnumber, name); | |
1790 return name; | |
1791 } | |
1792 | |
636 | 1793 #ifdef FEAT_QUICKFIX |
7 | 1794 /* |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1795 * Write cscope find results to file. |
7 | 1796 */ |
1797 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1798 cs_file_results(FILE *f, int *nummatches_a) |
7 | 1799 { |
1800 int i, j; | |
1801 char *buf; | |
1802 char *search, *slno; | |
1803 char *fullname; | |
1804 char *cntx; | |
1805 char *context; | |
1806 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1807 buf = alloc(CSREAD_BUFSIZE); |
7 | 1808 if (buf == NULL) |
1809 return; | |
1810 | |
1931 | 1811 for (i = 0; i < csinfo_size; i++) |
7 | 1812 { |
1813 if (nummatches_a[i] < 1) | |
1814 continue; | |
1815 | |
1816 for (j = 0; j < nummatches_a[i]; j++) | |
1817 { | |
293 | 1818 if ((fullname = cs_parse_results(i, buf, CSREAD_BUFSIZE, &cntx, |
1819 &slno, &search)) == NULL) | |
7 | 1820 continue; |
1821 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1822 context = alloc(strlen(cntx)+5); |
1027 | 1823 if (context == NULL) |
23831
7c257af6ccf5
patch 8.2.2457: Coverity warns for memory leak
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1824 { |
7c257af6ccf5
patch 8.2.2457: Coverity warns for memory leak
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1825 vim_free(fullname); |
7 | 1826 continue; |
23831
7c257af6ccf5
patch 8.2.2457: Coverity warns for memory leak
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
1827 } |
7 | 1828 |
1829 if (strcmp(cntx, "<global>")==0) | |
1830 strcpy(context, "<<global>>"); | |
1831 else | |
1832 sprintf(context, "<<%s>>", cntx); | |
1833 | |
1027 | 1834 if (search == NULL) |
7 | 1835 fprintf(f, "%s\t%s\t%s\n", fullname, slno, context); |
1836 else | |
1837 fprintf(f, "%s\t%s\t%s %s\n", fullname, slno, context, search); | |
1838 | |
1839 vim_free(context); | |
1840 vim_free(fullname); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1841 } // for all matches |
7 | 1842 |
1843 (void)cs_read_prompt(i); | |
1844 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1845 } // for all cscope connections |
7 | 1846 vim_free(buf); |
1847 } | |
636 | 1848 #endif |
7 | 1849 |
1850 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1851 * Get parsed cscope output and calls cs_make_vim_style_matches to convert |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1852 * into ctags format. |
297 | 1853 * When there are no matches sets "*matches_p" to NULL. |
7 | 1854 */ |
1855 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1856 cs_fill_results( |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1857 char *tagstr, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1858 int totmatches, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1859 int *nummatches_a, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1860 char ***matches_p, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1861 char ***cntxts_p, |
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1862 int *matched) |
7 | 1863 { |
1864 int i, j; | |
1865 char *buf; | |
1866 char *search, *slno; | |
1867 int totsofar = 0; | |
1868 char **matches = NULL; | |
1869 char **cntxts = NULL; | |
1870 char *fullname; | |
1871 char *cntx; | |
1872 | |
1873 assert(totmatches > 0); | |
1874 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1875 buf = alloc(CSREAD_BUFSIZE); |
7 | 1876 if (buf == NULL) |
1877 return; | |
1878 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1879 if ((matches = ALLOC_MULT(char *, totmatches)) == NULL) |
7 | 1880 goto parse_out; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1881 if ((cntxts = ALLOC_MULT(char *, totmatches)) == NULL) |
7 | 1882 goto parse_out; |
1883 | |
1931 | 1884 for (i = 0; i < csinfo_size; i++) |
7 | 1885 { |
1886 if (nummatches_a[i] < 1) | |
1887 continue; | |
1888 | |
1889 for (j = 0; j < nummatches_a[i]; j++) | |
1890 { | |
1891 if ((fullname = cs_parse_results(i, buf, CSREAD_BUFSIZE, &cntx, | |
1892 &slno, &search)) == NULL) | |
1893 continue; | |
1894 | |
1895 matches[totsofar] = cs_make_vim_style_matches(fullname, slno, | |
1896 search, tagstr); | |
1897 | |
1898 vim_free(fullname); | |
1899 | |
1900 if (strcmp(cntx, "<global>") == 0) | |
1901 cntxts[totsofar] = NULL; | |
1902 else | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1903 // note: if vim_strsave returns NULL, then the context |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1904 // will be "<global>", which is misleading. |
7 | 1905 cntxts[totsofar] = (char *)vim_strsave((char_u *)cntx); |
1906 | |
1907 if (matches[totsofar] != NULL) | |
1908 totsofar++; | |
1909 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1910 } // for all matches |
7 | 1911 |
1912 (void)cs_read_prompt(i); | |
1913 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1914 } // for all cscope connections |
7 | 1915 |
1916 parse_out: | |
297 | 1917 if (totsofar == 0) |
1918 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1919 // No matches, free the arrays and return NULL in "*matches_p". |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13136
diff
changeset
|
1920 VIM_CLEAR(matches); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13136
diff
changeset
|
1921 VIM_CLEAR(cntxts); |
297 | 1922 } |
7 | 1923 *matched = totsofar; |
1924 *matches_p = matches; | |
1925 *cntxts_p = cntxts; | |
297 | 1926 |
7 | 1927 vim_free(buf); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1928 } |
7 | 1929 |
1930 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1931 /* |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1932 * get the requested path components |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1933 */ |
7 | 1934 static char * |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1935 cs_pathcomponents(char *path) |
7 | 1936 { |
1937 int i; | |
1938 char *s; | |
1939 | |
1940 if (p_cspc == 0) | |
1941 return path; | |
1942 | |
1943 s = path + strlen(path) - 1; | |
1944 for (i = 0; i < p_cspc; ++i) | |
1945 while (s > path && *--s != '/' | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1946 #ifdef MSWIN |
7 | 1947 && *--s != '\\' |
1948 #endif | |
1949 ) | |
1950 ; | |
1951 if ((s > path && *s == '/') | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
1952 #ifdef MSWIN |
7 | 1953 || (s > path && *s == '\\') |
1954 #endif | |
1955 ) | |
1956 ++s; | |
1957 return s; | |
1958 } | |
1959 | |
1960 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
1961 * Called from cs_manage_matches(). |
7 | 1962 */ |
1963 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
1964 cs_print_tags_priv(char **matches, char **cntxts, int num_matches) |
7 | 1965 { |
1966 char *buf = NULL; | |
6596 | 1967 char *t_buf; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
1968 int bufsize = 0; // Track available bufsize |
7 | 1969 int newsize = 0; |
1970 char *ptag; | |
1971 char *fname, *lno, *extra, *tbuf; | |
1972 int i, idx, num; | |
1973 char *globalcntx = "GLOBAL"; | |
1974 char *cntxformat = " <<%s>>"; | |
1975 char *context; | |
1976 char *cstag_msg = _("Cscope tag: %s"); | |
1977 char *csfmt_str = "%4d %6s "; | |
1978 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
1979 assert(num_matches > 0); |
7 | 1980 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1981 if ((tbuf = alloc(strlen(matches[0]) + 1)) == NULL) |
7 | 1982 return; |
1983 | |
1984 strcpy(tbuf, matches[0]); | |
1985 ptag = strtok(tbuf, "\t"); | |
7009 | 1986 if (ptag == NULL) |
8234
dc72f4a463e4
commit https://github.com/vim/vim/commit/42dd7aee41ffcc5afdbf9bb83d70e7123261cada
Christian Brabandt <cb@256bit.org>
parents:
8226
diff
changeset
|
1987 { |
dc72f4a463e4
commit https://github.com/vim/vim/commit/42dd7aee41ffcc5afdbf9bb83d70e7123261cada
Christian Brabandt <cb@256bit.org>
parents:
8226
diff
changeset
|
1988 vim_free(tbuf); |
7009 | 1989 return; |
8234
dc72f4a463e4
commit https://github.com/vim/vim/commit/42dd7aee41ffcc5afdbf9bb83d70e7123261cada
Christian Brabandt <cb@256bit.org>
parents:
8226
diff
changeset
|
1990 } |
7 | 1991 |
835 | 1992 newsize = (int)(strlen(cstag_msg) + strlen(ptag)); |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
1993 buf = alloc(newsize); |
7 | 1994 if (buf != NULL) |
1995 { | |
1996 bufsize = newsize; | |
1997 (void)sprintf(buf, cstag_msg, ptag); | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
1998 msg_puts_attr(buf, HL_ATTR(HLF_T)); |
7 | 1999 } |
2000 | |
2001 vim_free(tbuf); | |
2002 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2003 msg_puts_attr(_("\n # line"), HL_ATTR(HLF_T)); // strlen is 7 |
7 | 2004 msg_advance(msg_col + 2); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2005 msg_puts_attr(_("filename / context / line\n"), HL_ATTR(HLF_T)); |
7 | 2006 |
2007 num = 1; | |
2008 for (i = 0; i < num_matches; i++) | |
2009 { | |
2010 idx = i; | |
2011 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2012 // if we really wanted to, we could avoid this malloc and strcpy |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2013 // by parsing matches[i] on the fly and placing stuff into buf |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2014 // directly, but that's too much of a hassle |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
2015 if ((tbuf = alloc(strlen(matches[idx]) + 1)) == NULL) |
7 | 2016 continue; |
2017 (void)strcpy(tbuf, matches[idx]); | |
2018 | |
8226
cb0edf7bd0a4
commit https://github.com/vim/vim/commit/e16e5a9d8d6d3159107541a259c6823ade18fd08
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2019 if (strtok(tbuf, (const char *)"\t") == NULL |
cb0edf7bd0a4
commit https://github.com/vim/vim/commit/e16e5a9d8d6d3159107541a259c6823ade18fd08
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2020 || (fname = strtok(NULL, (const char *)"\t")) == NULL |
cb0edf7bd0a4
commit https://github.com/vim/vim/commit/e16e5a9d8d6d3159107541a259c6823ade18fd08
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2021 || (lno = strtok(NULL, (const char *)"\t")) == NULL) |
cb0edf7bd0a4
commit https://github.com/vim/vim/commit/e16e5a9d8d6d3159107541a259c6823ade18fd08
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2022 { |
cb0edf7bd0a4
commit https://github.com/vim/vim/commit/e16e5a9d8d6d3159107541a259c6823ade18fd08
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2023 vim_free(tbuf); |
7 | 2024 continue; |
8226
cb0edf7bd0a4
commit https://github.com/vim/vim/commit/e16e5a9d8d6d3159107541a259c6823ade18fd08
Christian Brabandt <cb@256bit.org>
parents:
8080
diff
changeset
|
2025 } |
1078 | 2026 extra = strtok(NULL, (const char *)"\t"); |
7 | 2027 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2028 lno[strlen(lno)-2] = '\0'; // ignore ;" at the end |
7 | 2029 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2030 // hopefully 'num' (num of matches) will be less than 10^16 |
835 | 2031 newsize = (int)(strlen(csfmt_str) + 16 + strlen(lno)); |
7 | 2032 if (bufsize < newsize) |
2033 { | |
6596 | 2034 t_buf = buf; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
2035 buf = vim_realloc(buf, newsize); |
7 | 2036 if (buf == NULL) |
6596 | 2037 { |
7 | 2038 bufsize = 0; |
6596 | 2039 vim_free(t_buf); |
2040 } | |
7 | 2041 else |
2042 bufsize = newsize; | |
2043 } | |
2044 if (buf != NULL) | |
2045 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2046 // csfmt_str = "%4d %6s "; |
7 | 2047 (void)sprintf(buf, csfmt_str, num, lno); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2048 msg_puts_attr(buf, HL_ATTR(HLF_CM)); |
7 | 2049 } |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2050 msg_outtrans_long_attr((char_u *)cs_pathcomponents(fname), |
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2051 HL_ATTR(HLF_CM)); |
7 | 2052 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2053 // compute the required space for the context |
7 | 2054 if (cntxts[idx] != NULL) |
2055 context = cntxts[idx]; | |
2056 else | |
2057 context = globalcntx; | |
835 | 2058 newsize = (int)(strlen(context) + strlen(cntxformat)); |
7 | 2059 |
2060 if (bufsize < newsize) | |
2061 { | |
6596 | 2062 t_buf = buf; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
2063 buf = vim_realloc(buf, newsize); |
7 | 2064 if (buf == NULL) |
6596 | 2065 { |
7 | 2066 bufsize = 0; |
6596 | 2067 vim_free(t_buf); |
2068 } | |
7 | 2069 else |
2070 bufsize = newsize; | |
2071 } | |
2072 if (buf != NULL) | |
2073 { | |
2074 (void)sprintf(buf, cntxformat, context); | |
2075 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2076 // print the context only if it fits on the same line |
7 | 2077 if (msg_col + (int)strlen(buf) >= (int)Columns) |
2078 msg_putchar('\n'); | |
2079 msg_advance(12); | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2080 msg_outtrans_long_attr((char_u *)buf, 0); |
7 | 2081 msg_putchar('\n'); |
2082 } | |
2083 if (extra != NULL) | |
2084 { | |
2085 msg_advance(13); | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2086 msg_outtrans_long_attr((char_u *)extra, 0); |
7 | 2087 } |
2088 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2089 vim_free(tbuf); // only after printing extra due to strtok use |
7 | 2090 |
2091 if (msg_col) | |
2092 msg_putchar('\n'); | |
2093 | |
2094 ui_breakcheck(); | |
2095 if (got_int) | |
2096 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2097 got_int = FALSE; // don't print any more matches |
7 | 2098 break; |
2099 } | |
2100 | |
2101 num++; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2102 } // for all matches |
7 | 2103 |
2104 vim_free(buf); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2105 } |
7 | 2106 |
2107 | |
2108 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
2109 * Read a cscope prompt (basically, skip over the ">> "). |
7 | 2110 */ |
2111 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2112 cs_read_prompt(int i) |
7 | 2113 { |
2114 int ch; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2115 char *buf = NULL; // buffer for possible error message from cscope |
7 | 2116 int bufpos = 0; |
2117 char *cs_emsg; | |
2118 int maxlen; | |
2119 static char *eprompt = "Press the RETURN key to continue:"; | |
835 | 2120 int epromptlen = (int)strlen(eprompt); |
7 | 2121 int n; |
2122 | |
26948
51ddf6740ac6
patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26917
diff
changeset
|
2123 cs_emsg = _(e_cscope_error_str); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2124 // compute maximum allowed len for Cscope error message |
7 | 2125 maxlen = (int)(IOSIZE - strlen(cs_emsg)); |
2126 | |
2127 for (;;) | |
2128 { | |
2129 while ((ch = getc(csinfo[i].fr_fp)) != EOF && ch != CSCOPE_PROMPT[0]) | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2130 // if there is room and char is printable |
7 | 2131 if (bufpos < maxlen - 1 && vim_isprintc(ch)) |
2132 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2133 if (buf == NULL) // lazy buffer allocation |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
2134 buf = alloc(maxlen); |
7 | 2135 if (buf != NULL) |
2136 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2137 // append character to the message |
7 | 2138 buf[bufpos++] = ch; |
2139 buf[bufpos] = NUL; | |
2140 if (bufpos >= epromptlen | |
2141 && strcmp(&buf[bufpos - epromptlen], eprompt) == 0) | |
2142 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2143 // remove eprompt from buf |
7 | 2144 buf[bufpos - epromptlen] = NUL; |
2145 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2146 // print message to user |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
2147 (void)semsg(cs_emsg, buf); |
7 | 2148 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2149 // send RETURN to cscope |
7 | 2150 (void)putc('\n', csinfo[i].to_fp); |
2151 (void)fflush(csinfo[i].to_fp); | |
2152 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2153 // clear buf |
7 | 2154 bufpos = 0; |
2155 buf[bufpos] = NUL; | |
2156 } | |
2157 } | |
2158 } | |
2159 | |
2160 for (n = 0; n < (int)strlen(CSCOPE_PROMPT); ++n) | |
2161 { | |
2162 if (n > 0) | |
2163 ch = getc(csinfo[i].fr_fp); | |
2164 if (ch == EOF) | |
2165 { | |
2166 if (buf != NULL && buf[0] != NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
2167 (void)semsg(cs_emsg, buf); |
7 | 2168 else if (p_csverbose) |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2169 cs_reading_emsg(i); // don't have additional information |
7 | 2170 cs_release_csp(i, TRUE); |
2171 vim_free(buf); | |
2172 return CSCOPE_FAILURE; | |
2173 } | |
2174 | |
2175 if (ch != CSCOPE_PROMPT[n]) | |
2176 { | |
2177 ch = EOF; | |
2178 break; | |
2179 } | |
2180 } | |
2181 | |
2182 if (ch == EOF) | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2183 continue; // didn't find the prompt |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2184 break; // did find the prompt |
7 | 2185 } |
2186 | |
2187 vim_free(buf); | |
2188 return CSCOPE_SUCCESS; | |
2189 } | |
2190 | |
1566 | 2191 #if defined(UNIX) && defined(SIGALRM) |
2192 /* | |
2193 * Used to catch and ignore SIGALRM below. | |
2194 */ | |
29079
9781c150eddd
patch 8.2.5061: C89 requires signal handlers to return void
Bram Moolenaar <Bram@vim.org>
parents:
27657
diff
changeset
|
2195 static void |
1566 | 2196 sig_handler SIGDEFARG(sigarg) |
2197 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2198 // do nothing |
1566 | 2199 } |
2200 #endif | |
7 | 2201 |
2202 /* | |
1385 | 2203 * Does the actual free'ing for the cs ptr with an optional flag of whether |
2204 * or not to free the filename. Called by cs_kill and cs_reset. | |
7 | 2205 */ |
2206 static void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2207 cs_release_csp(int i, int freefnpp) |
7 | 2208 { |
2209 /* | |
2210 * Trying to exit normally (not sure whether it is fit to UNIX cscope | |
2211 */ | |
2212 if (csinfo[i].to_fp != NULL) | |
2213 { | |
2214 (void)fputs("q\n", csinfo[i].to_fp); | |
2215 (void)fflush(csinfo[i].to_fp); | |
2216 } | |
1566 | 2217 #if defined(UNIX) |
2218 { | |
1575 | 2219 int waitpid_errno; |
1566 | 2220 int pstat; |
2221 pid_t pid; | |
2222 | |
2223 # if defined(HAVE_SIGACTION) | |
2224 struct sigaction sa, old; | |
2225 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2226 // Use sigaction() to limit the waiting time to two seconds. |
1568 | 2227 sigemptyset(&sa.sa_mask); |
1566 | 2228 sa.sa_handler = sig_handler; |
2087
3112fcc89238
updated for version 7.2.371
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
2229 # ifdef SA_NODEFER |
1566 | 2230 sa.sa_flags = SA_NODEFER; |
2087
3112fcc89238
updated for version 7.2.371
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
2231 # else |
3112fcc89238
updated for version 7.2.371
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
2232 sa.sa_flags = 0; |
3112fcc89238
updated for version 7.2.371
Bram Moolenaar <bram@zimbu.org>
parents:
2047
diff
changeset
|
2233 # endif |
1566 | 2234 sigaction(SIGALRM, &sa, &old); |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2235 alarm(2); // 2 sec timeout |
1566 | 2236 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2237 // Block until cscope exits or until timer expires |
1566 | 2238 pid = waitpid(csinfo[i].pid, &pstat, 0); |
1575 | 2239 waitpid_errno = errno; |
1566 | 2240 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2241 // cancel pending alarm if still there and restore signal |
1566 | 2242 alarm(0); |
2243 sigaction(SIGALRM, &old, NULL); | |
2244 # else | |
2245 int waited; | |
2246 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2247 // Can't use sigaction(), loop for two seconds. First yield the CPU |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2248 // to give cscope a chance to exit quickly. |
1566 | 2249 sleep(0); |
2250 for (waited = 0; waited < 40; ++waited) | |
2251 { | |
2252 pid = waitpid(csinfo[i].pid, &pstat, WNOHANG); | |
1575 | 2253 waitpid_errno = errno; |
1566 | 2254 if (pid != 0) |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2255 break; // break unless the process is still running |
21927
88070e222e82
patch 8.2.1513: cannot interrupt shell used for filename expansion
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2256 mch_delay(50L, 0); // sleep 50 ms |
1566 | 2257 } |
2258 # endif | |
2259 /* | |
2260 * If the cscope process is still running: kill it. | |
2261 * Safety check: If the PID would be zero here, the entire X session | |
2262 * would be killed. -1 and 1 are dangerous as well. | |
2263 */ | |
2264 if (pid < 0 && csinfo[i].pid > 1) | |
2265 { | |
1575 | 2266 # ifdef ECHILD |
2267 int alive = TRUE; | |
2268 | |
2269 if (waitpid_errno == ECHILD) | |
2270 { | |
2271 /* | |
2272 * When using 'vim -g', vim is forked and cscope process is | |
2273 * no longer a child process but a sibling. So waitpid() | |
2274 * fails with errno being ECHILD (No child processes). | |
2275 * Don't send SIGKILL to cscope immediately but wait | |
2276 * (polling) for it to exit normally as result of sending | |
2277 * the "q" command, hence giving it a chance to clean up | |
2278 * its temporary files. | |
2279 */ | |
2280 int waited; | |
2281 | |
2282 sleep(0); | |
2283 for (waited = 0; waited < 40; ++waited) | |
2284 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2285 // Check whether cscope process is still alive |
1575 | 2286 if (kill(csinfo[i].pid, 0) != 0) |
2287 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2288 alive = FALSE; // cscope process no longer exists |
1575 | 2289 break; |
2290 } | |
21927
88070e222e82
patch 8.2.1513: cannot interrupt shell used for filename expansion
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2291 mch_delay(50L, 0); // sleep 50 ms |
1575 | 2292 } |
2293 } | |
2294 if (alive) | |
2295 # endif | |
2296 { | |
2297 kill(csinfo[i].pid, SIGKILL); | |
2298 (void)waitpid(csinfo[i].pid, &pstat, 0); | |
2299 } | |
1566 | 2300 } |
2301 } | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2302 #else // !UNIX |
1385 | 2303 if (csinfo[i].hProc != NULL) |
2304 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2305 // Give cscope a chance to exit normally |
1385 | 2306 if (WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT) |
2307 TerminateProcess(csinfo[i].hProc, 0); | |
2308 CloseHandle(csinfo[i].hProc); | |
2309 } | |
7 | 2310 #endif |
2311 | |
2312 if (csinfo[i].fr_fp != NULL) | |
2313 (void)fclose(csinfo[i].fr_fp); | |
2314 if (csinfo[i].to_fp != NULL) | |
2315 (void)fclose(csinfo[i].to_fp); | |
2316 | |
2317 if (freefnpp) | |
2318 { | |
2319 vim_free(csinfo[i].fname); | |
2320 vim_free(csinfo[i].ppath); | |
2321 vim_free(csinfo[i].flags); | |
2322 } | |
2323 | |
2324 clear_csinfo(i); | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2325 } |
7 | 2326 |
2327 | |
2328 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
2329 * Calls cs_kill on all cscope connections then reinits. |
7 | 2330 */ |
2331 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2332 cs_reset(exarg_T *eap UNUSED) |
7 | 2333 { |
2334 char **dblist = NULL, **pplist = NULL, **fllist = NULL; | |
2335 int i; | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2336 char buf[20]; // for sprintf " (#%d)" |
7 | 2337 |
1931 | 2338 if (csinfo_size == 0) |
2339 return CSCOPE_SUCCESS; | |
2340 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2341 // malloc our db and ppath list |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
2342 dblist = ALLOC_MULT(char *, csinfo_size); |
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
2343 pplist = ALLOC_MULT(char *, csinfo_size); |
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
2344 fllist = ALLOC_MULT(char *, csinfo_size); |
7 | 2345 if (dblist == NULL || pplist == NULL || fllist == NULL) |
2346 { | |
2347 vim_free(dblist); | |
2348 vim_free(pplist); | |
2349 vim_free(fllist); | |
2350 return CSCOPE_FAILURE; | |
2351 } | |
2352 | |
1931 | 2353 for (i = 0; i < csinfo_size; i++) |
7 | 2354 { |
2355 dblist[i] = csinfo[i].fname; | |
2356 pplist[i] = csinfo[i].ppath; | |
2357 fllist[i] = csinfo[i].flags; | |
2358 if (csinfo[i].fname != NULL) | |
2359 cs_release_csp(i, FALSE); | |
2360 } | |
2361 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2362 // rebuild the cscope connection list |
1931 | 2363 for (i = 0; i < csinfo_size; i++) |
7 | 2364 { |
2365 if (dblist[i] != NULL) | |
2366 { | |
2367 cs_add_common(dblist[i], pplist[i], fllist[i]); | |
2368 if (p_csverbose) | |
2369 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2370 // don't use smsg_attr() because we want to display the |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2371 // connection number in the same line as |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2372 // "Added cscope database..." |
7 | 2373 sprintf(buf, " (#%d)", i); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2374 msg_puts_attr(buf, HL_ATTR(HLF_R)); |
7 | 2375 } |
2376 } | |
2377 vim_free(dblist[i]); | |
2378 vim_free(pplist[i]); | |
2379 vim_free(fllist[i]); | |
2380 } | |
2381 vim_free(dblist); | |
2382 vim_free(pplist); | |
2383 vim_free(fllist); | |
2384 | |
2385 if (p_csverbose) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2386 msg_attr(_("All cscope databases reset"), HL_ATTR(HLF_R) | MSG_HIST); |
7 | 2387 return CSCOPE_SUCCESS; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2388 } |
7 | 2389 |
2390 | |
2391 /* | |
4581
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2392 * Construct the full pathname to a file found in the cscope database. |
7 | 2393 * (Prepends ppath, if there is one and if it's not already prepended, |
2394 * otherwise just uses the name found.) | |
2395 * | |
4581
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2396 * We need to prepend the prefix because on some cscope's (e.g., the one that |
7 | 2397 * ships with Solaris 2.6), the output never has the prefix prepended. |
4581
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2398 * Contrast this with my development system (Digital Unix), which does. |
7 | 2399 */ |
2400 static char * | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2401 cs_resolve_file(int i, char *name) |
7 | 2402 { |
2873 | 2403 char *fullname; |
2404 int len; | |
2405 char_u *csdir = NULL; | |
7 | 2406 |
2407 /* | |
2873 | 2408 * Ppath is freed when we destroy the cscope connection. |
2409 * Fullname is freed after cs_make_vim_style_matches, after it's been | |
2410 * copied into the tag buffer used by Vim. | |
7 | 2411 */ |
835 | 2412 len = (int)(strlen(name) + 2); |
7 | 2413 if (csinfo[i].ppath != NULL) |
835 | 2414 len += (int)strlen(csinfo[i].ppath); |
2873 | 2415 else if (p_csre && csinfo[i].fname != NULL) |
2416 { | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2417 // If 'cscoperelative' is set and ppath is not set, use cscope.out |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2418 // path in path resolution. |
2873 | 2419 csdir = alloc(MAXPATHL); |
2420 if (csdir != NULL) | |
2421 { | |
2422 vim_strncpy(csdir, (char_u *)csinfo[i].fname, | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13136
diff
changeset
|
2423 gettail((char_u *)csinfo[i].fname) |
4581
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2424 - (char_u *)csinfo[i].fname); |
2873 | 2425 len += (int)STRLEN(csdir); |
2426 } | |
2427 } | |
7 | 2428 |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2429 // Note/example: this won't work if the cscope output already starts |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2430 // "../.." and the prefix path is also "../..". if something like this |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2431 // happens, you are screwed up and need to fix how you're using cscope. |
2873 | 2432 if (csinfo[i].ppath != NULL |
2433 && (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0) | |
2434 && (name[0] != '/') | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
2435 #ifdef MSWIN |
2873 | 2436 && name[0] != '\\' && name[1] != ':' |
7 | 2437 #endif |
2873 | 2438 ) |
4581
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2439 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
2440 if ((fullname = alloc(len)) != NULL) |
4581
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2441 (void)sprintf(fullname, "%s/%s", csinfo[i].ppath, name); |
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2442 } |
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2443 else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL) |
2873 | 2444 { |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2445 // Check for csdir to be non empty to avoid empty path concatenated to |
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2446 // cscope output. |
2875 | 2447 fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE); |
2873 | 2448 } |
7 | 2449 else |
4581
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2450 { |
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2451 fullname = (char *)vim_strsave((char_u *)name); |
6a73ac422c67
updated for version 7.3.1038
Bram Moolenaar <bram@vim.org>
parents:
4352
diff
changeset
|
2452 } |
7 | 2453 |
2873 | 2454 vim_free(csdir); |
7 | 2455 return fullname; |
2873 | 2456 } |
7 | 2457 |
2458 | |
2459 /* | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
2460 * Show all cscope connections. |
7 | 2461 */ |
2462 static int | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2463 cs_show(exarg_T *eap UNUSED) |
7 | 2464 { |
27451
c1da76214cca
patch 8.2.4254: using short instead of int
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2465 int i; |
c1da76214cca
patch 8.2.4254: using short instead of int
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
2466 |
7 | 2467 if (cs_cnt_connections() == 0) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2468 msg_puts(_("no cscope connections\n")); |
7 | 2469 else |
2470 { | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
2471 msg_puts_attr( |
7 | 2472 _(" # pid database name prepend path\n"), |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
2473 HL_ATTR(HLF_T)); |
1931 | 2474 for (i = 0; i < csinfo_size; i++) |
7 | 2475 { |
2476 if (csinfo[i].fname == NULL) | |
2477 continue; | |
2478 | |
2479 if (csinfo[i].ppath != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
2480 (void)smsg("%2d %-5ld %-34s %-32s", |
7 | 2481 i, (long)csinfo[i].pid, csinfo[i].fname, csinfo[i].ppath); |
2482 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
2483 (void)smsg("%2d %-5ld %-34s <none>", |
7 | 2484 i, (long)csinfo[i].pid, csinfo[i].fname); |
2485 } | |
2486 } | |
2487 | |
29960
4fcf816aa806
patch 9.0.0318: clearing screen causes flicker
Bram Moolenaar <Bram@vim.org>
parents:
29079
diff
changeset
|
2488 wait_return(FALSE); |
7 | 2489 return CSCOPE_SUCCESS; |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2490 } |
7 | 2491 |
1385 | 2492 |
2493 /* | |
2494 * Only called when VIM exits to quit any cscope sessions. | |
2495 */ | |
2496 void | |
7823
bcef391c101c
commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents:
7803
diff
changeset
|
2497 cs_end(void) |
1385 | 2498 { |
2499 int i; | |
2500 | |
1931 | 2501 for (i = 0; i < csinfo_size; i++) |
1385 | 2502 cs_release_csp(i, TRUE); |
1931 | 2503 vim_free(csinfo); |
2504 csinfo_size = 0; | |
1385 | 2505 } |
2506 | |
18798
f0f9692d4487
patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
17990
diff
changeset
|
2507 #endif // FEAT_CSCOPE |
7 | 2508 |
17990
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2509 #if defined(FEAT_EVAL) || defined(PROTO) |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2510 |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2511 /* |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2512 * "cscope_connection([{num} , {dbpath} [, {prepend}]])" function |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2513 * |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2514 * Checks the existence of a cscope connection. |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2515 */ |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2516 void |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2517 f_cscope_connection(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2518 { |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2519 # ifdef FEAT_CSCOPE |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2520 int num = 0; |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2521 char_u *dbpath = NULL; |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2522 char_u *prepend = NULL; |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2523 char_u buf[NUMBUFLEN]; |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2524 |
25348
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25342
diff
changeset
|
2525 if (in_vim9script() |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25342
diff
changeset
|
2526 && (check_for_opt_number_arg(argvars, 0) == FAIL |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25342
diff
changeset
|
2527 || (argvars[0].v_type != VAR_UNKNOWN |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25342
diff
changeset
|
2528 && (check_for_opt_string_arg(argvars, 1) == FAIL |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25342
diff
changeset
|
2529 || (argvars[1].v_type != VAR_UNKNOWN |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25342
diff
changeset
|
2530 && check_for_opt_string_arg(argvars, 2) == FAIL))))) |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25342
diff
changeset
|
2531 return; |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25342
diff
changeset
|
2532 |
17990
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2533 if (argvars[0].v_type != VAR_UNKNOWN |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2534 && argvars[1].v_type != VAR_UNKNOWN) |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2535 { |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2536 num = (int)tv_get_number(&argvars[0]); |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2537 dbpath = tv_get_string(&argvars[1]); |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2538 if (argvars[2].v_type != VAR_UNKNOWN) |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2539 prepend = tv_get_string_buf(&argvars[2], buf); |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2540 } |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2541 |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2542 rettv->vval.v_number = cs_connection(num, dbpath, prepend); |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2543 # endif |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2544 } |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2545 |
8976c3a3803a
patch 8.1.1991: still cannot build with eval but without cscope
Bram Moolenaar <Bram@vim.org>
parents:
17986
diff
changeset
|
2546 #endif // FEAT_EVAL |