Merge pull request #7116 from lonerover/vim-8.0.0081

vim-patch:8.0.0081
This commit is contained in:
James McCoy 2017-08-04 10:32:47 -04:00 committed by GitHub
commit 36a91c790e
4 changed files with 95 additions and 219 deletions

View File

@ -628,13 +628,13 @@ return {
command='cscope', command='cscope',
flags=bit.bor(EXTRA, NOTRLCOM, XFILE), flags=bit.bor(EXTRA, NOTRLCOM, XFILE),
addr_type=ADDR_LINES, addr_type=ADDR_LINES,
func='do_cscope', func='ex_cscope',
}, },
{ {
command='cstag', command='cstag',
flags=bit.bor(BANG, TRLBAR, WORD1), flags=bit.bor(BANG, TRLBAR, WORD1),
addr_type=ADDR_LINES, addr_type=ADDR_LINES,
func='do_cstag', func='ex_cstag',
}, },
{ {
command='cunmap', command='cunmap',
@ -1324,7 +1324,7 @@ return {
command='lcscope', command='lcscope',
flags=bit.bor(EXTRA, NOTRLCOM, XFILE), flags=bit.bor(EXTRA, NOTRLCOM, XFILE),
addr_type=ADDR_LINES, addr_type=ADDR_LINES,
func='do_cscope', func='ex_cscope',
}, },
{ {
command='ldo', command='ldo',
@ -2334,7 +2334,7 @@ return {
command='scscope', command='scscope',
flags=bit.bor(EXTRA, NOTRLCOM), flags=bit.bor(EXTRA, NOTRLCOM),
addr_type=ADDR_LINES, addr_type=ADDR_LINES,
func='do_scscope', func='ex_scscope',
}, },
{ {
command='set', command='set',

View File

@ -8321,7 +8321,7 @@ static void ex_tag_cmd(exarg_T *eap, char_u *name)
break; break;
default: /* ":tag" */ default: /* ":tag" */
if (p_cst && *eap->arg != NUL) { if (p_cst && *eap->arg != NUL) {
do_cstag(eap); ex_cstag(eap);
return; return;
} }
cmd = DT_TAG; cmd = DT_TAG;

View File

@ -172,14 +172,10 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx)
} }
/* /// Find the command, print help if invalid, and then call the corresponding
* PRIVATE: do_cscope_general /// command function.
* static void
* Find the command, print help if invalid, and then call the corresponding do_cscope_general(
* command function.
*/
static void
do_cscope_general (
exarg_T *eap, exarg_T *eap,
int make_split /* whether to split window */ int make_split /* whether to split window */
) )
@ -208,29 +204,20 @@ do_cscope_general (
postponed_split_tab = 0; postponed_split_tab = 0;
} }
/* /// Implementation of ":cscope" and ":lcscope"
* PUBLIC: do_cscope void ex_cscope(exarg_T *eap)
*/
void do_cscope(exarg_T *eap)
{ {
do_cscope_general(eap, FALSE); do_cscope_general(eap, FALSE);
} }
/* /// Implementation of ":scscope". Same as ex_cscope(), but splits window, too.
* PUBLIC: do_scscope void ex_scscope(exarg_T *eap)
*
* same as do_cscope, but splits window, too.
*/
void do_scscope(exarg_T *eap)
{ {
do_cscope_general(eap, TRUE); do_cscope_general(eap, TRUE);
} }
/* /// Implementation of ":cstag"
* PUBLIC: do_cstag void ex_cstag(exarg_T *eap)
*
*/
void do_cstag(exarg_T *eap)
{ {
int ret = FALSE; int ret = FALSE;
@ -285,18 +272,13 @@ void do_cstag(exarg_T *eap)
(void)EMSG(_("E257: cstag: tag not found")); (void)EMSG(_("E257: cstag: tag not found"));
g_do_tagpreview = 0; g_do_tagpreview = 0;
} }
}
} /* do_cscope */
/* /// This simulates a vim_fgets(), but for cscope, returns the next line
* PUBLIC: cs_find /// from the cscope output. should only be called from find_tags()
* ///
* this simulates a vim_fgets(), but for cscope, returns the next line /// @return TRUE if eof, FALSE otherwise
* from the cscope output. should only be called from find_tags()
*
* returns TRUE if eof, FALSE otherwise
*/
int cs_fgets(char_u *buf, int size) int cs_fgets(char_u *buf, int size)
{ {
char *p; char *p;
@ -309,21 +291,13 @@ int cs_fgets(char_u *buf, int size)
} /* cs_fgets */ } /* cs_fgets */
/* /// Called only from do_tag(), when popping the tag stack.
* PUBLIC: cs_free_tags
*
* called only from do_tag(), when popping the tag stack
*/
void cs_free_tags(void) void cs_free_tags(void)
{ {
cs_manage_matches(NULL, NULL, 0, Free); cs_manage_matches(NULL, NULL, 0, Free);
} }
/* /// Called from do_tag().
* PUBLIC: cs_print_tags
*
* called from do_tag()
*/
void cs_print_tags(void) void cs_print_tags(void)
{ {
cs_manage_matches(NULL, NULL, 0, Print); cs_manage_matches(NULL, NULL, 0, Print);
@ -404,14 +378,8 @@ int cs_connection(int num, char_u *dbpath, char_u *ppath)
* PRIVATE functions * PRIVATE functions
****************************************************************************/ ****************************************************************************/
/* /// Add cscope database or a directory name (to look for cscope.out)
* PRIVATE: cs_add /// to the cscope connection list.
*
* add cscope database or a directory name (to look for cscope.out)
* to the cscope connection list
*
* MAXPATHL 256
*/
static int cs_add(exarg_T *eap) static int cs_add(exarg_T *eap)
{ {
char *fname, *ppath, *flags = NULL; char *fname, *ppath, *flags = NULL;
@ -437,17 +405,13 @@ static void cs_stat_emsg(char *fname)
} }
/* /// The common routine to add a new cscope connection. Called by
* PRIVATE: cs_add_common /// cs_add() and cs_reset(). I really don't like to do this, but this
* /// routine uses a number of goto statements.
* the common routine to add a new cscope connection. called by static int
* cs_add() and cs_reset(). i really don't like to do this, but this cs_add_common(
* routine uses a number of goto statements. char *arg1, // filename - may contain environment variables
*/ char *arg2, // prepend path - may contain environment variables
static int
cs_add_common (
char *arg1, /* filename - may contain environment variables */
char *arg2, /* prepend path - may contain environment variables */
char *flags char *flags
) )
{ {
@ -561,11 +525,7 @@ static int cs_check_for_tags(void)
return p_tags[0] != NUL && curbuf->b_p_tags != NULL; return p_tags[0] != NUL && curbuf->b_p_tags != NULL;
} /* cs_check_for_tags */ } /* cs_check_for_tags */
/* /// Count the number of cscope connections.
* PRIVATE: cs_cnt_connections
*
* count the number of cscope connections
*/
static size_t cs_cnt_connections(void) static size_t cs_cnt_connections(void)
{ {
size_t cnt = 0; size_t cnt = 0;
@ -585,11 +545,7 @@ static void cs_reading_emsg(
} }
#define CSREAD_BUFSIZE 2048 #define CSREAD_BUFSIZE 2048
/* /// Count the number of matches for a given cscope connection.
* PRIVATE: cs_cnt_matches
*
* count the number of matches for a given cscope connection.
*/
static int cs_cnt_matches(size_t idx) static int cs_cnt_matches(size_t idx)
{ {
char *stok; char *stok;
@ -639,11 +595,7 @@ static int cs_cnt_matches(size_t idx)
} /* cs_cnt_matches */ } /* cs_cnt_matches */
/* /// Creates the actual cscope command query from what the user entered.
* PRIVATE: cs_create_cmd
*
* Creates the actual cscope command query from what the user entered.
*/
static char *cs_create_cmd(char *csoption, char *pattern) static char *cs_create_cmd(char *csoption, char *pattern)
{ {
char *cmd; char *cmd;
@ -699,12 +651,8 @@ static char *cs_create_cmd(char *csoption, char *pattern)
} /* cs_create_cmd */ } /* cs_create_cmd */
/* /// This piece of code was taken/adapted from nvi. do we need to add
* PRIVATE: cs_create_connection /// the BSD license notice?
*
* This piece of code was taken/adapted from nvi. do we need to add
* the BSD license notice?
*/
static int cs_create_connection(size_t i) static int cs_create_connection(size_t i)
{ {
#ifdef UNIX #ifdef UNIX
@ -893,14 +841,10 @@ err_closing:
} /* cs_create_connection */ } /* cs_create_connection */
/* /// Query cscope using command line interface. Parse the output and use tselect
* PRIVATE: cs_find /// to allow choices. Like Nvi, creates a pipe to send to/from query/cscope.
* ///
* query cscope using command line interface. parse the output and use tselect /// @return TRUE if we jump to a tag or abort, FALSE if not.
* to allow choices. like Nvi, creates a pipe to send to/from query/cscope.
*
* returns TRUE if we jump to a tag or abort, FALSE if not.
*/
static int cs_find(exarg_T *eap) static int cs_find(exarg_T *eap)
{ {
char *opt, *pat; char *opt, *pat;
@ -934,11 +878,7 @@ static int cs_find(exarg_T *eap)
} /* cs_find */ } /* cs_find */
/* /// Common code for cscope find, shared by cs_find() and ex_cstag().
* PRIVATE: cs_find_common
*
* common code for cscope find, shared by cs_find() and do_cstag()
*/
static int cs_find_common(char *opt, char *pat, int forceit, int verbose, static int cs_find_common(char *opt, char *pat, int forceit, int verbose,
int use_ll, char_u *cmdline) int use_ll, char_u *cmdline)
{ {
@ -1111,11 +1051,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose,
} /* cs_find_common */ } /* cs_find_common */
/* /// Print help.
* PRIVATE: cs_help
*
* print help
*/
static int cs_help(exarg_T *eap) static int cs_help(exarg_T *eap)
{ {
cscmd_T *cmdp = cs_cmds; cscmd_T *cmdp = cs_cmds;
@ -1163,11 +1099,7 @@ static void clear_csinfo(size_t i)
csinfo[i].to_fp = NULL; csinfo[i].to_fp = NULL;
} }
/* /// Insert a new cscope database filename into the filelist.
* PRIVATE: cs_insert_filelist
*
* insert a new cscope database filename into the filelist
*/
static int cs_insert_filelist(char *fname, char *ppath, char *flags, static int cs_insert_filelist(char *fname, char *ppath, char *flags,
FileInfo *file_info) FileInfo *file_info)
{ {
@ -1227,11 +1159,7 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags,
} /* cs_insert_filelist */ } /* cs_insert_filelist */
/* /// Find cscope command in command table.
* PRIVATE: cs_lookup_cmd
*
* find cscope command in command table
*/
static cscmd_T * cs_lookup_cmd(exarg_T *eap) static cscmd_T * cs_lookup_cmd(exarg_T *eap)
{ {
cscmd_T *cmdp; cscmd_T *cmdp;
@ -1256,11 +1184,7 @@ static cscmd_T * cs_lookup_cmd(exarg_T *eap)
} /* cs_lookup_cmd */ } /* cs_lookup_cmd */
/* /// Nuke em.
* PRIVATE: cs_kill
*
* nuke em
*/
static int cs_kill(exarg_T *eap) static int cs_kill(exarg_T *eap)
{ {
char *stok; char *stok;
@ -1317,11 +1241,7 @@ static int cs_kill(exarg_T *eap)
} /* cs_kill */ } /* cs_kill */
/* /// Actually kills a specific cscope connection.
* PRIVATE: cs_kill_execute
*
* Actually kills a specific cscope connection.
*/
static void cs_kill_execute( static void cs_kill_execute(
size_t i, /* cscope table index */ size_t i, /* cscope table index */
char *cname /* cscope database name */ char *cname /* cscope database name */
@ -1336,26 +1256,22 @@ static void cs_kill_execute(
} }
/* /// Convert the cscope output into a ctags style entry (as might be found
* PRIVATE: cs_make_vim_style_matches /// in a ctags tags file). there's one catch though: cscope doesn't tell you
* /// the type of the tag you are looking for. for example, in Darren Hiebert's
* convert the cscope output into a ctags style entry (as might be found /// ctags (the one that comes with vim), #define's use a line number to find the
* in a ctags tags file). there's one catch though: cscope doesn't tell you /// tag in a file while function definitions use a regexp search pattern.
* the type of the tag you are looking for. for example, in Darren Hiebert's ///
* ctags (the one that comes with vim), #define's use a line number to find the /// I'm going to always use the line number because cscope does something
* tag in a file while function definitions use a regexp search pattern. /// quirky (and probably other things i don't know about):
* ///
* i'm going to always use the line number because cscope does something /// if you have "# define" in your source file, which is
* quirky (and probably other things i don't know about): /// perfectly legal, cscope thinks you have "#define". this
* /// will result in a failed regexp search. :(
* if you have "# define" in your source file, which is ///
* perfectly legal, cscope thinks you have "#define". this /// Besides, even if this particular case didn't happen, the search pattern
* will result in a failed regexp search. :( /// would still have to be modified to escape all the special regular expression
* /// characters to comply with ctags formatting.
* besides, even if this particular case didn't happen, the search pattern
* would still have to be modified to escape all the special regular expression
* characters to comply with ctags formatting.
*/
static char *cs_make_vim_style_matches(char *fname, char *slno, char *search, static char *cs_make_vim_style_matches(char *fname, char *slno, char *search,
char *tagstr) char *tagstr)
{ {
@ -1389,24 +1305,20 @@ static char *cs_make_vim_style_matches(char *fname, char *slno, char *search,
} /* cs_make_vim_style_matches */ } /* cs_make_vim_style_matches */
/* /// This is kind of hokey, but i don't see an easy way round this.
* PRIVATE: cs_manage_matches ///
* /// Store: keep a ptr to the (malloc'd) memory of matches originally
* this is kind of hokey, but i don't see an easy way round this.. /// generated from cs_find(). the matches are originally lines directly
* /// from cscope output, but transformed to look like something out of a
* Store: keep a ptr to the (malloc'd) memory of matches originally /// ctags. see cs_make_vim_style_matches for more details.
* generated from cs_find(). the matches are originally lines directly ///
* from cscope output, but transformed to look like something out of a /// Get: used only from cs_fgets(), this simulates a vim_fgets() to return
* ctags. see cs_make_vim_style_matches for more details. /// the next line from the cscope output. it basically keeps track of which
* /// lines have been "used" and returns the next one.
* Get: used only from cs_fgets(), this simulates a vim_fgets() to return ///
* the next line from the cscope output. it basically keeps track of which /// Free: frees up everything and resets
* lines have been "used" and returns the next one. ///
* /// Print: prints the tags
* Free: frees up everything and resets
*
* Print: prints the tags
*/
static char *cs_manage_matches(char **matches, char **contexts, static char *cs_manage_matches(char **matches, char **contexts,
size_t totmatches, mcmd_e cmd) size_t totmatches, mcmd_e cmd)
{ {
@ -1461,11 +1373,7 @@ static char *cs_manage_matches(char **matches, char **contexts,
} /* cs_manage_matches */ } /* cs_manage_matches */
/* /// Parse cscope output.
* PRIVATE: cs_parse_results
*
* parse cscope output
*/
static char *cs_parse_results(size_t cnumber, char *buf, int bufsize, static char *cs_parse_results(size_t cnumber, char *buf, int bufsize,
char **context, char **linenumber, char **search) char **context, char **linenumber, char **search)
{ {
@ -1515,11 +1423,7 @@ static char *cs_parse_results(size_t cnumber, char *buf, int bufsize,
return name; return name;
} }
/* /// Write cscope find results to file.
* PRIVATE: cs_file_results
*
* write cscope find results to file
*/
static void cs_file_results(FILE *f, int *nummatches_a) static void cs_file_results(FILE *f, int *nummatches_a)
{ {
char *search, *slno; char *search, *slno;
@ -1560,13 +1464,9 @@ static void cs_file_results(FILE *f, int *nummatches_a)
xfree(buf); xfree(buf);
} }
/* /// Get parsed cscope output and calls cs_make_vim_style_matches to convert
* PRIVATE: cs_fill_results /// into ctags format.
* /// When there are no matches sets "*matches_p" to NULL.
* get parsed cscope output and calls cs_make_vim_style_matches to convert
* into ctags format
* When there are no matches sets "*matches_p" to NULL.
*/
static void cs_fill_results(char *tagstr, size_t totmatches, int *nummatches_a, static void cs_fill_results(char *tagstr, size_t totmatches, int *nummatches_a,
char ***matches_p, char ***cntxts_p, char ***matches_p, char ***cntxts_p,
size_t *matched) size_t *matched)
@ -1758,11 +1658,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts,
xfree(buf); xfree(buf);
} }
/* /// Read a cscope prompt (basically, skip over the ">> ").
* PRIVATE: cs_read_prompt
*
* read a cscope prompt (basically, skip over the ">> ")
*/
static int cs_read_prompt(size_t i) static int cs_read_prompt(size_t i)
{ {
int ch; int ch;
@ -1847,12 +1743,8 @@ static void sig_handler(int s) {
#endif #endif
/* /// Does the actual free'ing for the cs ptr with an optional flag of whether
* PRIVATE: cs_release_csp /// or not to free the filename. Called by cs_kill and cs_reset.
*
* Does the actual free'ing for the cs ptr with an optional flag of whether
* or not to free the filename. Called by cs_kill and cs_reset.
*/
static void cs_release_csp(size_t i, int freefnpp) static void cs_release_csp(size_t i, int freefnpp)
{ {
// Trying to exit normally (not sure whether it is fit to Unix cscope) // Trying to exit normally (not sure whether it is fit to Unix cscope)
@ -1964,11 +1856,7 @@ static void cs_release_csp(size_t i, int freefnpp)
} /* cs_release_csp */ } /* cs_release_csp */
/* /// Calls cs_kill on all cscope connections then reinits.
* PRIVATE: cs_reset
*
* calls cs_kill on all cscope connections then reinits
*/
static int cs_reset(exarg_T *eap) static int cs_reset(exarg_T *eap)
{ {
char **dblist = NULL, **pplist = NULL, **fllist = NULL; char **dblist = NULL, **pplist = NULL, **fllist = NULL;
@ -2018,17 +1906,13 @@ static int cs_reset(exarg_T *eap)
} /* cs_reset */ } /* cs_reset */
/* /// Construct the full pathname to a file found in the cscope database.
* PRIVATE: cs_resolve_file /// (Prepends ppath, if there is one and if it's not already prepended,
* /// otherwise just uses the name found.)
* Construct the full pathname to a file found in the cscope database. ///
* (Prepends ppath, if there is one and if it's not already prepended, /// We need to prepend the prefix because on some cscope's (e.g., the one that
* otherwise just uses the name found.) /// ships with Solaris 2.6), the output never has the prefix prepended.
* /// Contrast this with my development system (Digital Unix), which does.
* We need to prepend the prefix because on some cscope's (e.g., the one that
* ships with Solaris 2.6), the output never has the prefix prepended.
* Contrast this with my development system (Digital Unix), which does.
*/
static char *cs_resolve_file(size_t i, char *name) static char *cs_resolve_file(size_t i, char *name)
{ {
char *fullname; char *fullname;
@ -2074,11 +1958,7 @@ static char *cs_resolve_file(size_t i, char *name)
} }
/* /// Show all cscope connections.
* PRIVATE: cs_show
*
* show all cscope connections
*/
static int cs_show(exarg_T *eap) static int cs_show(exarg_T *eap)
{ {
if (cs_cnt_connections() == 0) if (cs_cnt_connections() == 0)
@ -2106,11 +1986,7 @@ static int cs_show(exarg_T *eap)
} /* cs_show */ } /* cs_show */
/* /// Only called when VIM exits to quit any cscope sessions.
* PUBLIC: cs_end
*
* Only called when VIM exits to quit any cscope sessions.
*/
void cs_end(void) void cs_end(void)
{ {
for (size_t i = 0; i < csinfo_size; i++) for (size_t i = 0; i < csinfo_size; i++)

View File

@ -648,7 +648,7 @@ static const int included_patches[] = {
84, 84,
83, 83,
// 82 NA // 82 NA
// 81, 81,
// 80 NA // 80 NA
79, 79,
78, 78,