Discard too long lines in dictionary file: add warning and test

This commit is contained in:
Bartek Fabiszewski 2017-10-24 22:36:10 +02:00
parent 94a15dfc4e
commit b7daafd28d
6 changed files with 25 additions and 0 deletions

View File

@ -444,6 +444,10 @@ for (k = 0; k < 2; k++) {
if (!feof(f) && strchr(buf, '\n') == NULL) {
int c;
while ((c = fgetc(f)) != '\n' && c != EOF);
/* issue warning if not a comment */
if (buf[0] != '%') {
fprintf(stderr, "Warning: skipping too long pattern (more than %lu chars)\n", sizeof(buf));
}
continue;
}

View File

@ -11,6 +11,7 @@ alt4.test \
alt5.test \
alt6.test \
alt7.test \
longlines.test \
compound.test \
compound2.test \
compound3.test \
@ -50,6 +51,9 @@ alt6.word \
alt7.hyph \
alt7.pat \
alt7.word \
longlines.hyph \
longlines.pat \
longlines.word \
alt.hyph \
alt.pat \
alt.word \
@ -105,6 +109,7 @@ alt4.test \
alt5.test \
alt6.test \
alt7.test \
longlines.test \
alt.test \
basealt2.test \
basealt.test \

1
tests/longlines.hyph Normal file
View File

@ -0,0 +1 @@
a=bc=d

10
tests/longlines.pat Normal file
View File

@ -0,0 +1,10 @@
ISO8859-1
LEFTHYPHENMIN 1
RIGHTHYPHENMIN 1
% Check whether characters over MAX_CHARS are not treated as new line
% This test is valid as long as MAX_CHARS is 100
%
% Following pattern should result in a=bc=d hyphenation
a1b2c1d
% and should not be overriden by pattern from too long comment (over MAX_CHARS characters)
%|------------------------------ this part is 100 characters long --------------------------------|a8b9c8d

4
tests/longlines.test Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
DIR="`dirname $0`"
NAME="`basename $0 .test`"
$DIR/test.sh $NAME.pat $NAME.word $NAME.hyph

1
tests/longlines.word Normal file
View File

@ -0,0 +1 @@
abcd