summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeodor Sigaev2006-02-10 12:56:14 +0000
committerTeodor Sigaev2006-02-10 12:56:14 +0000
commit01f2172ec1f8793fde569eb2bc7156f5ea23d956 (patch)
tree5daefff1680220b074cd2e1c968a28a273b60af0
parent12fca1f6fa2aa49634b7ee1d004fa7a63e4cc65c (diff)
Allow "'" symbol in affixes ("'s" affix in english): it was diallowed during
multibyte support work. Add line number to error output during affix file parsing.
-rw-r--r--contrib/tsearch2/ispell/spell.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/contrib/tsearch2/ispell/spell.c b/contrib/tsearch2/ispell/spell.c
index 49b9e9dfbfa..4ee75e680ae 100644
--- a/contrib/tsearch2/ispell/spell.c
+++ b/contrib/tsearch2/ispell/spell.c
@@ -306,7 +306,7 @@ NIAddAffix(IspellDict * Conf, int flag, char flagflags, const char *mask, const
#define PAE_INREPL 5
static bool
-parse_affentry( char *str, char *mask, char *find, char *repl ) {
+parse_affentry( char *str, char *mask, char *find, char *repl, int line ) {
int state = PAE_WAIT_MASK;
char *pmask=mask, *pfind=find, *prepl=repl;
@@ -332,12 +332,12 @@ parse_affentry( char *str, char *mask, char *find, char *repl ) {
} else if ( state == PAE_WAIT_FIND ) {
if ( t_iseq(str,'-') ) {
state = PAE_INFIND;
- } else if (t_isalpha(str)) {
+ } else if (t_isalpha(str) || t_iseq(str,'\'') /* english 's */) {
COPYCHAR(prepl,str);
prepl += pg_mblen(str);
state = PAE_INREPL;
} else if (!t_isspace(str))
- ts_error(ERROR, "Affix parse error");
+ ts_error(ERROR, "Affix parse error at %d line", line);
} else if ( state == PAE_INFIND ) {
if ( t_iseq(str,',') ) {
*pfind='\0';
@@ -346,7 +346,7 @@ parse_affentry( char *str, char *mask, char *find, char *repl ) {
COPYCHAR(pfind,str);
pfind += pg_mblen(str);
} else if (!t_isspace(str))
- ts_error(ERROR, "Affix parse error");
+ ts_error(ERROR, "Affix parse error at %d line", line);
} else if ( state == PAE_WAIT_REPL ) {
if ( t_iseq(str,'-') ) {
break; /* void repl */
@@ -355,7 +355,7 @@ parse_affentry( char *str, char *mask, char *find, char *repl ) {
prepl += pg_mblen(str);
state = PAE_INREPL;
} else if (!t_isspace(str))
- ts_error(ERROR, "Affix parse error");
+ ts_error(ERROR, "Affix parse error at %d line", line);
} else if ( state == PAE_INREPL ) {
if ( t_iseq(str,'#') ) {
*prepl = '\0';
@@ -364,7 +364,7 @@ parse_affentry( char *str, char *mask, char *find, char *repl ) {
COPYCHAR(prepl,str);
prepl += pg_mblen(str);
} else if (!t_isspace(str))
- ts_error(ERROR, "Affix parse error");
+ ts_error(ERROR, "Affix parse error at %d line", line);
} else
ts_error(ERROR, "Unknown state in parse_affentry: %d", state);
@@ -390,6 +390,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
int flag = 0;
char flagflags = 0;
FILE *affix;
+ int line=0;
if (!(affix = fopen(filename, "r")))
return (1);
@@ -397,6 +398,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
while (fgets(str, sizeof(str), affix))
{
+ line++;
pg_verifymbstr( str, strlen(str), false);
memcpy(tmpstr, str, 32); /* compoundwords... */
tmpstr[32]='\0';
@@ -463,7 +465,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
continue;
lowerstr(str);
- if ( !parse_affentry(str, mask, find, repl) )
+ if ( !parse_affentry(str, mask, find, repl, line) )
continue;
NIAddAffix(Conf, flag, flagflags, mask, find, repl, suffixes ? FF_SUFFIX : FF_PREFIX);