diff options
author | Reuben Thomas <rrt@sc3d.org> | 2019-09-01 13:22:37 +0100 |
---|---|---|
committer | Reuben Thomas <rrt@sc3d.org> | 2019-09-01 13:22:37 +0100 |
commit | 5a2d2be42bc69f238ad7eeb47508fd9a9f8b941e (patch) | |
tree | e40e7d3f5149a13d5f59f572b9173a3bc9cbf557 /src/pwl.c | |
parent | fcfd4f5d1a166acd55b996634dc19f6192b00979 (diff) | |
download | enchant-5a2d2be42bc69f238ad7eeb47508fd9a9f8b941e.tar.gz |
src/pwl.c: cope with different line endings when reading PWL
(Fixes a problem with the tests on Windows, which for some reason only
manifested recently.)
Diffstat (limited to 'src/pwl.c')
-rw-r--r-- | src/pwl.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -248,10 +248,7 @@ static void enchant_pwl_refresh_from_file(EnchantPWL* pwl) if(line_number == 1 && BOM == g_utf8_get_char(line)) line = g_utf8_next_char(line); - size_t l = strlen(line)-1; - if (line[l]=='\n') - line[l] = '\0'; - else if(!feof(f)) /* ignore lines longer than BUFSIZ. */ + if(line[strlen(line)-1] != '\n' && !feof(f)) /* ignore lines longer than BUFSIZ. */ { g_warning ("Line too long (ignored) in %s at line:%zu\n", pwl->filename, line_number); while (NULL != (fgets (buffer, sizeof (buffer), f))) @@ -261,7 +258,8 @@ static void enchant_pwl_refresh_from_file(EnchantPWL* pwl) } continue; } - + + g_strchomp(line); if( line[0] && line[0] != '#') { if(g_utf8_validate(line, -1, NULL)) |