commit a87aa68ed0e79389ba2e0b94a727f69303c62b71
parent 23c214ed4abe6135837b58a6ef74705d352e5f1a
Author: bfredl <bjorn.linse@gmail.com>
Date: Sun, 18 May 2025 11:36:12 +0200
Merge pull request #34071 from bfredl/tagutf
refactor(helptags): remove useless homegrown encoding check
Diffstat:
1 file changed, 0 insertions(+), 38 deletions(-)
diff --git a/src/nvim/help.c b/src/nvim/help.c
@@ -839,8 +839,6 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
int filecount;
char **files;
char *s;
- TriState utf8 = kNone;
- bool mix = false; // detected mixed encodings
// Find all *.txt files.
size_t dirlen = xstrlcpy(NameBuff, dir, sizeof(NameBuff));
@@ -905,36 +903,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
const char *const fname = files[fi] + dirlen + 1;
bool in_example = false;
- bool firstline = true;
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) {
- if (firstline) {
- // Detect utf-8 file by a non-ASCII char in the first line.
- TriState this_utf8 = kNone;
- for (s = IObuff; *s != NUL; s++) {
- if ((uint8_t)(*s) >= 0x80) {
- this_utf8 = kTrue;
- const int l = utf_ptr2len(s);
- if (l == 1) {
- // Illegal UTF-8 byte sequence.
- this_utf8 = kFalse;
- break;
- }
- s += l - 1;
- }
- }
- if (this_utf8 == kNone) { // only ASCII characters found
- this_utf8 = kFalse;
- }
- if (utf8 == kNone) { // first file
- utf8 = this_utf8;
- } else if (utf8 != this_utf8) {
- semsg(_("E670: Mix of help file encodings within a language: %s"),
- files[fi]);
- mix = !got_int;
- got_int = true;
- }
- firstline = false;
- }
if (in_example) {
// skip over example; a non-white in the first column ends it
if (vim_strchr(" \t\n\r", (uint8_t)IObuff[0])) {
@@ -1008,10 +977,6 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
}
}
- if (utf8 == kTrue) {
- fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n");
- }
-
// Write the tags into the file.
for (int i = 0; i < ga.ga_len; i++) {
s = ((char **)ga.ga_data)[i];
@@ -1031,9 +996,6 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
}
}
}
- if (mix) {
- got_int = false; // continue with other languages
- }
GA_DEEP_CLEAR_PTR(&ga);
fclose(fd_tags); // there is no check for an error...