Skip to content

Commit 01f2172

Browse files
committed
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.
1 parent 12fca1f commit 01f2172

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

contrib/tsearch2/ispell/spell.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ NIAddAffix(IspellDict * Conf, int flag, char flagflags, const char *mask, const
306306
#define PAE_INREPL 5
307307

308308
static bool
309-
parse_affentry( char *str, char *mask, char *find, char *repl ) {
309+
parse_affentry( char *str, char *mask, char *find, char *repl, int line ) {
310310
int state = PAE_WAIT_MASK;
311311
char *pmask=mask, *pfind=find, *prepl=repl;
312312

@@ -332,12 +332,12 @@ parse_affentry( char *str, char *mask, char *find, char *repl ) {
332332
} else if ( state == PAE_WAIT_FIND ) {
333333
if ( t_iseq(str,'-') ) {
334334
state = PAE_INFIND;
335-
} else if (t_isalpha(str)) {
335+
} else if (t_isalpha(str) || t_iseq(str,'\'') /* english 's */) {
336336
COPYCHAR(prepl,str);
337337
prepl += pg_mblen(str);
338338
state = PAE_INREPL;
339339
} else if (!t_isspace(str))
340-
ts_error(ERROR, "Affix parse error");
340+
ts_error(ERROR, "Affix parse error at %d line", line);
341341
} else if ( state == PAE_INFIND ) {
342342
if ( t_iseq(str,',') ) {
343343
*pfind='\0';
@@ -346,7 +346,7 @@ parse_affentry( char *str, char *mask, char *find, char *repl ) {
346346
COPYCHAR(pfind,str);
347347
pfind += pg_mblen(str);
348348
} else if (!t_isspace(str))
349-
ts_error(ERROR, "Affix parse error");
349+
ts_error(ERROR, "Affix parse error at %d line", line);
350350
} else if ( state == PAE_WAIT_REPL ) {
351351
if ( t_iseq(str,'-') ) {
352352
break; /* void repl */
@@ -355,7 +355,7 @@ parse_affentry( char *str, char *mask, char *find, char *repl ) {
355355
prepl += pg_mblen(str);
356356
state = PAE_INREPL;
357357
} else if (!t_isspace(str))
358-
ts_error(ERROR, "Affix parse error");
358+
ts_error(ERROR, "Affix parse error at %d line", line);
359359
} else if ( state == PAE_INREPL ) {
360360
if ( t_iseq(str,'#') ) {
361361
*prepl = '\0';
@@ -364,7 +364,7 @@ parse_affentry( char *str, char *mask, char *find, char *repl ) {
364364
COPYCHAR(prepl,str);
365365
prepl += pg_mblen(str);
366366
} else if (!t_isspace(str))
367-
ts_error(ERROR, "Affix parse error");
367+
ts_error(ERROR, "Affix parse error at %d line", line);
368368
} else
369369
ts_error(ERROR, "Unknown state in parse_affentry: %d", state);
370370

@@ -390,13 +390,15 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
390390
int flag = 0;
391391
char flagflags = 0;
392392
FILE *affix;
393+
int line=0;
393394

394395
if (!(affix = fopen(filename, "r")))
395396
return (1);
396397
Conf->compoundcontrol = '\t';
397398

398399
while (fgets(str, sizeof(str), affix))
399400
{
401+
line++;
400402
pg_verifymbstr( str, strlen(str), false);
401403
memcpy(tmpstr, str, 32); /* compoundwords... */
402404
tmpstr[32]='\0';
@@ -463,7 +465,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
463465
continue;
464466

465467
lowerstr(str);
466-
if ( !parse_affentry(str, mask, find, repl) )
468+
if ( !parse_affentry(str, mask, find, repl, line) )
467469
continue;
468470

469471
NIAddAffix(Conf, flag, flagflags, mask, find, repl, suffixes ? FF_SUFFIX : FF_PREFIX);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy