mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
lint: helptags_one
This commit is contained in:
parent
11ed7377f9
commit
6fc0a9f557
@ -5230,10 +5230,8 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// If using the "++t" argument or generating tags for "$VIMRUNTIME/doc"
|
||||||
* If using the "++t" argument or generating tags for "$VIMRUNTIME/doc"
|
// add the "help-tags" tag.
|
||||||
* add the "help-tags" tag.
|
|
||||||
*/
|
|
||||||
ga_init(&ga, (int)sizeof(char_u *), 100);
|
ga_init(&ga, (int)sizeof(char_u *), 100);
|
||||||
if (add_help_tags
|
if (add_help_tags
|
||||||
|| path_full_compare((char_u *)"$VIMRUNTIME/doc",
|
|| path_full_compare((char_u *)"$VIMRUNTIME/doc",
|
||||||
@ -5243,9 +5241,7 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
|
|||||||
GA_APPEND(char_u *, &ga, s);
|
GA_APPEND(char_u *, &ga, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Go over all the files and extract the tags.
|
||||||
* Go over all the files and extract the tags.
|
|
||||||
*/
|
|
||||||
for (int fi = 0; fi < filecount && !got_int; fi++) {
|
for (int fi = 0; fi < filecount && !got_int; fi++) {
|
||||||
FILE *const fd = os_fopen((char *)files[fi], "r");
|
FILE *const fd = os_fopen((char *)files[fi], "r");
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
@ -5285,21 +5281,19 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
|
|||||||
}
|
}
|
||||||
firstline = false;
|
firstline = false;
|
||||||
}
|
}
|
||||||
p1 = vim_strchr(IObuff, '*'); /* find first '*' */
|
p1 = vim_strchr(IObuff, '*'); // find first '*'
|
||||||
while (p1 != NULL) {
|
while (p1 != NULL) {
|
||||||
p2 = (char_u *)strchr((const char *)p1 + 1, '*'); // Find second '*'.
|
p2 = (char_u *)strchr((const char *)p1 + 1, '*'); // Find second '*'.
|
||||||
if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**".
|
if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**".
|
||||||
for (s = p1 + 1; s < p2; s++) {
|
for (s = p1 + 1; s < p2; s++) {
|
||||||
if (*s == ' ' || *s == '\t' || *s == '|') {
|
if (*s == ' ' || *s == '\t' || *s == '|') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Only accept a *tag* when it consists of valid
|
||||||
* Only accept a *tag* when it consists of valid
|
// characters, there is white space before it and is
|
||||||
* characters, there is white space before it and is
|
// followed by a white character or end-of-line.
|
||||||
* followed by a white character or end-of-line.
|
|
||||||
*/
|
|
||||||
if (s == p2
|
if (s == p2
|
||||||
&& (p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t')
|
&& (p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t')
|
||||||
&& (vim_strchr((char_u *)" \t\n\r", s[1]) != NULL
|
&& (vim_strchr((char_u *)" \t\n\r", s[1]) != NULL
|
||||||
@ -5310,7 +5304,7 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
|
|||||||
GA_APPEND(char_u *, &ga, s);
|
GA_APPEND(char_u *, &ga, s);
|
||||||
sprintf((char *)s, "%s\t%s", p1, fname);
|
sprintf((char *)s, "%s\t%s", p1, fname);
|
||||||
|
|
||||||
/* find next '*' */
|
// find next '*'
|
||||||
p2 = vim_strchr(p2 + 1, '*');
|
p2 = vim_strchr(p2 + 1, '*');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5325,15 +5319,11 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
|
|||||||
FreeWild(filecount, files);
|
FreeWild(filecount, files);
|
||||||
|
|
||||||
if (!got_int && ga.ga_data != NULL) {
|
if (!got_int && ga.ga_data != NULL) {
|
||||||
/*
|
// Sort the tags.
|
||||||
* Sort the tags.
|
|
||||||
*/
|
|
||||||
sort_strings((char_u **)ga.ga_data, ga.ga_len);
|
sort_strings((char_u **)ga.ga_data, ga.ga_len);
|
||||||
|
|
||||||
/*
|
// Check for duplicates.
|
||||||
* Check for duplicates.
|
for (int i = 1; i < ga.ga_len; i++) {
|
||||||
*/
|
|
||||||
for (int i = 1; i < ga.ga_len; ++i) {
|
|
||||||
p1 = ((char_u **)ga.ga_data)[i - 1];
|
p1 = ((char_u **)ga.ga_data)[i - 1];
|
||||||
p2 = ((char_u **)ga.ga_data)[i];
|
p2 = ((char_u **)ga.ga_data)[i];
|
||||||
while (*p1 == *p2) {
|
while (*p1 == *p2) {
|
||||||
@ -5355,31 +5345,31 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
|
|||||||
fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n");
|
fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Write the tags into the file.
|
||||||
* Write the tags into the file.
|
for (int i = 0; i < ga.ga_len; i++) {
|
||||||
*/
|
|
||||||
for (int i = 0; i < ga.ga_len; ++i) {
|
|
||||||
s = ((char_u **)ga.ga_data)[i];
|
s = ((char_u **)ga.ga_data)[i];
|
||||||
if (STRNCMP(s, "help-tags\t", 10) == 0)
|
if (STRNCMP(s, "help-tags\t", 10) == 0) {
|
||||||
/* help-tags entry was added in formatted form */
|
// help-tags entry was added in formatted form
|
||||||
fputs((char *)s, fd_tags);
|
fputs((char *)s, fd_tags);
|
||||||
else {
|
} else {
|
||||||
fprintf(fd_tags, "%s\t/*", s);
|
fprintf(fd_tags, "%s\t/" "*", s);
|
||||||
for (p1 = s; *p1 != '\t'; ++p1) {
|
for (p1 = s; *p1 != '\t'; p1++) {
|
||||||
/* insert backslash before '\\' and '/' */
|
// insert backslash before '\\' and '/'
|
||||||
if (*p1 == '\\' || *p1 == '/')
|
if (*p1 == '\\' || *p1 == '/') {
|
||||||
putc('\\', fd_tags);
|
putc('\\', fd_tags);
|
||||||
|
}
|
||||||
putc(*p1, fd_tags);
|
putc(*p1, fd_tags);
|
||||||
}
|
}
|
||||||
fprintf(fd_tags, "*\n");
|
fprintf(fd_tags, "*\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mix)
|
if (mix) {
|
||||||
got_int = FALSE; /* continue with other languages */
|
got_int = false; // continue with other languages
|
||||||
|
}
|
||||||
|
|
||||||
GA_DEEP_CLEAR_PTR(&ga);
|
GA_DEEP_CLEAR_PTR(&ga);
|
||||||
fclose(fd_tags); /* there is no check for an error... */
|
fclose(fd_tags); // there is no check for an error...
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate tags in one help directory, taking care of translations.
|
/// Generate tags in one help directory, taking care of translations.
|
||||||
|
Loading…
Reference in New Issue
Block a user