ex_cmds: add const to fix_help_buffer() variables

This commit is contained in:
Jan Edmund Lazo 2018-08-01 21:13:01 -04:00
parent d29c02710e
commit 144e85b7b9

View File

@ -4913,11 +4913,7 @@ void fix_help_buffer(void)
{ {
linenr_T lnum; linenr_T lnum;
char_u *line; char_u *line;
int in_example = FALSE; bool in_example = false;
int len;
char_u *fname;
char_u *p;
char_u *rt;
// Set filetype to "help". // Set filetype to "help".
if (STRCMP(curbuf->b_p_ft, "help") != 0) { if (STRCMP(curbuf->b_p_ft, "help") != 0) {
@ -4927,9 +4923,9 @@ void fix_help_buffer(void)
} }
if (!syntax_present(curwin)) { if (!syntax_present(curwin)) {
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) { for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) {
line = ml_get_buf(curbuf, lnum, FALSE); line = ml_get_buf(curbuf, lnum, false);
len = (int)STRLEN(line); const size_t len = STRLEN(line);
if (in_example && len > 0 && !ascii_iswhite(line[0])) { if (in_example && len > 0 && !ascii_iswhite(line[0])) {
/* End of example: non-white or '<' in first column. */ /* End of example: non-white or '<' in first column. */
if (line[0] == '<') { if (line[0] == '<') {
@ -4937,14 +4933,14 @@ void fix_help_buffer(void)
line = ml_get_buf(curbuf, lnum, TRUE); line = ml_get_buf(curbuf, lnum, TRUE);
line[0] = ' '; line[0] = ' ';
} }
in_example = FALSE; in_example = false;
} }
if (!in_example && len > 0) { if (!in_example && len > 0) {
if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) { if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) {
/* blank-out a '>' in the last column (start of example) */ /* blank-out a '>' in the last column (start of example) */
line = ml_get_buf(curbuf, lnum, TRUE); line = ml_get_buf(curbuf, lnum, TRUE);
line[len - 1] = ' '; line[len - 1] = ' ';
in_example = TRUE; in_example = true;
} else if (line[len - 1] == '~') { } else if (line[len - 1] == '~') {
/* blank-out a '~' at the end of line (header marker) */ /* blank-out a '~' at the end of line (header marker) */
line = ml_get_buf(curbuf, lnum, TRUE); line = ml_get_buf(curbuf, lnum, TRUE);
@ -4958,7 +4954,7 @@ void fix_help_buffer(void)
* In the "help.txt" and "help.abx" file, add the locally added help * In the "help.txt" and "help.abx" file, add the locally added help
* files. This uses the very first line in the help file. * files. This uses the very first line in the help file.
*/ */
fname = path_tail(curbuf->b_fname); char_u *const fname = path_tail(curbuf->b_fname);
if (fnamecmp(fname, "help.txt") == 0 if (fnamecmp(fname, "help.txt") == 0
|| (fnamencmp(fname, "help.", 5) == 0 || (fnamencmp(fname, "help.", 5) == 0
&& ASCII_ISALPHA(fname[5]) && ASCII_ISALPHA(fname[5])
@ -4973,17 +4969,15 @@ void fix_help_buffer(void)
/* Go through all directories in 'runtimepath', skipping /* Go through all directories in 'runtimepath', skipping
* $VIMRUNTIME. */ * $VIMRUNTIME. */
p = p_rtp; char_u *p = p_rtp;
while (*p != NUL) { while (*p != NUL) {
copy_option_part(&p, NameBuff, MAXPATHL, ","); copy_option_part(&p, NameBuff, MAXPATHL, ",");
rt = (char_u *)vim_getenv("VIMRUNTIME"); char_u *const rt = (char_u *)vim_getenv("VIMRUNTIME");
if (rt != NULL if (rt != NULL
&& path_full_compare(rt, NameBuff, false) != kEqualFiles) { && path_full_compare(rt, NameBuff, false) != kEqualFiles) {
int fcount; int fcount;
char_u **fnames; char_u **fnames;
FILE *fd;
char_u *s; char_u *s;
int fi;
vimconv_T vc; vimconv_T vc;
char_u *cp; char_u *cp;
@ -5001,29 +4995,24 @@ void fix_help_buffer(void)
if (gen_expand_wildcards(1, buff_list, &fcount, if (gen_expand_wildcards(1, buff_list, &fcount,
&fnames, EW_FILE|EW_SILENT) == OK &fnames, EW_FILE|EW_SILENT) == OK
&& fcount > 0) { && fcount > 0) {
int i1; // If foo.abx is found use it instead of foo.txt in
int i2; // the same directory.
char_u *f1; for (int i1 = 0; i1 < fcount; i1++) {
char_u *f2; for (int i2 = 0; i2 < fcount; i2++) {
char_u *t1; if (i1 == i2) {
char_u *e1;
char_u *e2;
/* If foo.abx is found use it instead of foo.txt in
* the same directory. */
for (i1 = 0; i1 < fcount; ++i1) {
for (i2 = 0; i2 < fcount; ++i2) {
if (i1 == i2)
continue; continue;
if (fnames[i1] == NULL || fnames[i2] == NULL) }
if (fnames[i1] == NULL || fnames[i2] == NULL) {
continue; continue;
f1 = fnames[i1]; }
f2 = fnames[i2]; const char_u *const f1 = fnames[i1];
t1 = path_tail(f1); const char_u *const f2 = fnames[i2];
if (fnamencmp(f1, f2, t1 - f1) != 0) const char_u *const t1 = path_tail(f1);
if (fnamencmp(f1, f2, t1 - f1) != 0) {
continue; continue;
e1 = vim_strrchr(t1, '.'); }
e2 = vim_strrchr(path_tail(f2), '.'); const char_u *const e1 = vim_strrchr(t1, '.');
const char_u *const e2 = vim_strrchr(path_tail(f2), '.');
if (e1 == NULL || e2 == NULL) { if (e1 == NULL || e2 == NULL) {
continue; continue;
} }
@ -5044,10 +5033,12 @@ void fix_help_buffer(void)
} }
} }
} }
for (fi = 0; fi < fcount; ++fi) { for (int fi = 0; fi < fcount; fi++) {
if (fnames[fi] == NULL) if (fnames[fi] == NULL) {
continue; continue;
fd = mch_fopen((char *)fnames[fi], "r"); }
FILE *const fd = mch_fopen((char *)fnames[fi], "r");
if (fd == NULL) { if (fd == NULL) {
continue; continue;
} }