Skip to content

Commit f82b853

Browse files
committed
1 Update Snowball sources
2 Makefile fixes
1 parent 3b0453b commit f82b853

File tree

14 files changed

+2269
-2337
lines changed

14 files changed

+2269
-2337
lines changed

contrib/tsearch2/dict_snowball.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ snb_en_init(PG_FUNCTION_ARGS)
4949
PG_FREE_IF_COPY(in, 0);
5050
}
5151

52-
d->z = english_create_env();
52+
d->z = english_ISO_8859_1_create_env();
5353
if (!d->z)
5454
{
5555
freestoplist(&(d->stoplist));
5656
ereport(ERROR,
5757
(errcode(ERRCODE_OUT_OF_MEMORY),
5858
errmsg("out of memory")));
5959
}
60-
d->stem = english_stem;
60+
d->stem = english_ISO_8859_1_stem;
6161

6262
PG_RETURN_POINTER(d);
6363
}
@@ -83,15 +83,15 @@ snb_ru_init(PG_FUNCTION_ARGS)
8383
PG_FREE_IF_COPY(in, 0);
8484
}
8585

86-
d->z = russian_create_env();
86+
d->z = russian_KOI8_R_create_env();
8787
if (!d->z)
8888
{
8989
freestoplist(&(d->stoplist));
9090
ereport(ERROR,
9191
(errcode(ERRCODE_OUT_OF_MEMORY),
9292
errmsg("out of memory")));
9393
}
94-
d->stem = russian_stem;
94+
d->stem = russian_KOI8_R_stem;
9595

9696
PG_RETURN_POINTER(d);
9797
}

contrib/tsearch2/gendict/README.gendict

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Example 1:
5050

5151
2. Create template files for Portuguese
5252

53-
./config.sh -n pt -s -p portuguese -v -C'Snowball stemmer for Portuguese'
53+
./config.sh -n pt -s -p portuguese_ISO_8859_1 -v -C'Snowball stemmer for Portuguese'
5454

5555
Note, that argument for -p option should be *the same* as name of stemming
5656
function in stem.c (without _stem)
@@ -81,9 +81,10 @@ Example 1:
8181
Here is what I have in pg_ts_dict table
8282

8383
psql -d testdict -c "select * from pg_ts_dict where dict_name='pt';"
84-
dict_name | dict_init | dict_initoption | dict_lexize | dict_comment
85-
-----------+-----------+-----------------+-------------+---------------------------------
86-
pt | 7177806 | | 7159330 | Snowball stemmer for Portuguese
84+
dict_name | dict_init | dict_initoption | dict_lexize | dict_comment
85+
-----------+--------------------+-----------------+---------------------------------------+---------------------------------
86+
pt | dinit_pt(internal) | | snb_lexize(internal,internal,integer) | Snowball stemmer for Portuguese
87+
8788
(1 row)
8889

8990

@@ -127,4 +128,4 @@ Example 2:
127128
you may edit them to create actual dictionary.
128129

129130
Please, check Tsearch2 home page (http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/)
130-
for additional information about "Gendict tutorial" and dictionaries.
131+
for additional information about "Gendict tutorial" and dictionaries.

contrib/tsearch2/gendict/config.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,16 @@ fi
131131
if [ ${#cfile} -ne 0 ] || [ ${#hfile} -ne 0 ] ; then
132132
[ $verbose = "yes" ] && echo -n 'Copy source and header files... '
133133
if [ ${#cfile} -ne 0 ] ; then
134-
if ! cp $cfile ../../$dir ; then
135-
echo "Cant cp all or one of files: $cfile"
136-
exit 1
134+
if [ $stemmode = "yes" ] ; then
135+
for cfn in $cfile
136+
do
137+
sed s#../runtime/## < $cfn > ../../$dir/$cfn
138+
done
139+
else
140+
if ! cp $cfile ../../$dir ; then
141+
echo "Can't cp all or one of files: $cfile"
142+
exit 1
143+
fi
137144
fi
138145
fi
139146
if [ ${#hfile} -ne 0 ] ; then

contrib/tsearch2/ispell/Makefile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
# $PostgreSQL: pgsql/contrib/tsearch2/ispell/Makefile,v 1.6 2004/06/23 11:06:11 teodor Exp $
1+
# $PostgreSQL: pgsql/contrib/tsearch2/ispell/Makefile,v 1.7 2005/09/15 11:14:18 teodor Exp $
22

3-
subdir = contrib/tsearch2/ispell
3+
PG_CPPFLAGS = -I$(srcdir)/..
4+
SUBOBJS = spell.o regis.o
5+
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS)
6+
7+
ifdef USE_PGXS
8+
PGXS = $(shell pg_config --pgxs)
9+
include $(PGXS)
10+
else
11+
subdir = contrib/tsearch2
412
top_builddir = ../../..
513
include $(top_builddir)/src/Makefile.global
14+
include $(top_srcdir)/contrib/contrib-global.mk
15+
endif
616

7-
8-
PG_CPPFLAGS = -I$(srcdir)/.. $(CPPFLAGS)
917
override CFLAGS += $(CFLAGS_SL)
1018

11-
SUBOBJS = spell.o regis.o
12-
1319
all: SUBSYS.o
1420

1521
SUBSYS.o: $(SUBOBJS)
1622
$(LD) $(LDREL) $(LDOUT) $@ $^
1723

18-
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS)
1924

20-
include $(top_srcdir)/contrib/contrib-global.mk

contrib/tsearch2/snowball/Makefile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
# $PostgreSQL: pgsql/contrib/tsearch2/snowball/Makefile,v 1.5 2003/11/29 19:51:36 pgsql Exp $
1+
# $PostgreSQL: pgsql/contrib/tsearch2/snowball/Makefile,v 1.6 2005/09/15 11:14:18 teodor Exp $
22

3-
subdir = contrib/tsearch2/snowball
3+
4+
PG_CPPFLAGS = -I$(srcdir)/..
5+
SUBOBJS = english_stem.o api.o russian_stem.o utilities.o
6+
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS)
7+
8+
ifdef USE_PGXS
9+
PGXS = $(shell pg_config --pgxs)
10+
include $(PGXS)
11+
else
12+
subdir = contrib/tsearch2
413
top_builddir = ../../..
514
include $(top_builddir)/src/Makefile.global
15+
include $(top_srcdir)/contrib/contrib-global.mk
16+
endif
617

7-
8-
PG_CPPFLAGS = -I$(srcdir)/..
918
override CFLAGS += $(CFLAGS_SL)
1019

11-
SUBOBJS = english_stem.o api.o russian_stem.o utilities.o
12-
1320
all: SUBSYS.o
1421

1522
SUBSYS.o: $(SUBOBJS)
1623
$(LD) $(LDREL) $(LDOUT) $@ $^
1724

18-
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS)
1925

20-
include $(top_srcdir)/contrib/contrib-global.mk

contrib/tsearch2/snowball/api.c

Lines changed: 54 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,69 @@
1-
#include <stdlib.h>
21

2+
#include <stdlib.h> /* for calloc, free */
33
#include "header.h"
44

5-
struct SN_env *
6-
SN_create_env(int S_size, int I_size, int B_size)
5+
extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size)
76
{
8-
struct SN_env *z = (struct SN_env *) calloc(1, sizeof(struct SN_env));
9-
struct SN_env *z2 = z;
7+
struct SN_env * z = (struct SN_env *) calloc(1, sizeof(struct SN_env));
8+
if (z == NULL) return NULL;
9+
z->p = create_s();
10+
if (z->p == NULL) goto error;
11+
if (S_size)
12+
{
13+
int i;
14+
z->S = (symbol * *) calloc(S_size, sizeof(symbol *));
15+
if (z->S == NULL) goto error;
1016

11-
if (!z)
12-
return z;
17+
for (i = 0; i < S_size; i++)
18+
{
19+
z->S[i] = create_s();
20+
if (z->S[i] == NULL) goto error;
21+
}
22+
z->S_size = S_size;
23+
}
1324

14-
z->p = create_s();
15-
if (!z->p)
16-
z = NULL;
25+
if (I_size)
26+
{
27+
z->I = (int *) calloc(I_size, sizeof(int));
28+
if (z->I == NULL) goto error;
29+
z->I_size = I_size;
30+
}
1731

18-
if (z && S_size)
19-
{
20-
if ((z->S = (symbol * *) calloc(S_size, sizeof(symbol *))))
21-
{
22-
int i;
32+
if (B_size)
33+
{
34+
z->B = (symbol *) calloc(B_size, sizeof(symbol));
35+
if (z->B == NULL) goto error;
36+
z->B_size = B_size;
37+
}
2338

24-
for (i = 0; i < S_size; i++)
25-
{
26-
if (!(z->S[i] = create_s()))
27-
{
28-
z = NULL;
29-
break;
30-
}
31-
}
32-
z2->S_size = i;
33-
}
34-
else
35-
z = NULL;
36-
}
37-
38-
if (z && I_size)
39-
{
40-
z->I = (int *) calloc(I_size, sizeof(int));
41-
if (z->I)
42-
z->I_size = I_size;
43-
else
44-
z = NULL;
45-
}
46-
47-
if (z && B_size)
48-
{
49-
z->B = (symbol *) calloc(B_size, sizeof(symbol));
50-
if (z->B)
51-
z->B_size = B_size;
52-
else
53-
z = NULL;
54-
}
55-
56-
if (!z)
57-
SN_close_env(z2);
58-
59-
return z;
39+
return z;
40+
error:
41+
SN_close_env(z);
42+
return NULL;
6043
}
6144

62-
void
63-
SN_close_env(struct SN_env * z)
45+
extern void SN_close_env(struct SN_env * z)
6446
{
65-
if (z->S && z->S_size)
66-
{
67-
{
68-
int i;
69-
70-
for (i = 0; i < z->S_size; i++)
71-
lose_s(z->S[i]);
72-
}
73-
free(z->S);
74-
}
75-
if (z->I_size)
76-
free(z->I);
77-
if (z->B_size)
78-
free(z->B);
79-
if (z->p)
80-
lose_s(z->p);
81-
free(z);
47+
if (z == NULL) return;
48+
if (z->S_size)
49+
{
50+
int i;
51+
for (i = 0; i < z->S_size; i++)
52+
{
53+
lose_s(z->S[i]);
54+
}
55+
free(z->S);
56+
}
57+
if (z->I_size) free(z->I);
58+
if (z->B_size) free(z->B);
59+
if (z->p) lose_s(z->p);
60+
free(z);
8261
}
8362

84-
void
85-
SN_set_current(struct SN_env * z, int size, const symbol * s)
63+
extern int SN_set_current(struct SN_env * z, int size, const symbol * s)
8664
{
87-
replace_s(z, 0, z->l, size, s);
88-
z->c = 0;
65+
int err = replace_s(z, 0, z->l, size, s, NULL);
66+
z->c = 0;
67+
return err;
8968
}
69+

contrib/tsearch2/snowball/api.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,17 @@ typedef unsigned char symbol;
1111
1212
*/
1313

14-
struct SN_env
15-
{
16-
symbol *p;
17-
int c;
18-
int a;
19-
int l;
20-
int lb;
21-
int bra;
22-
int ket;
23-
int S_size;
24-
int I_size;
25-
int B_size;
26-
symbol **S;
27-
int *I;
28-
symbol *B;
14+
struct SN_env {
15+
symbol * p;
16+
int c; int a; int l; int lb; int bra; int ket;
17+
int S_size; int I_size; int B_size;
18+
symbol * * S;
19+
int * I;
20+
symbol * B;
2921
};
3022

31-
extern struct SN_env *SN_create_env(int S_size, int I_size, int B_size);
23+
extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size);
3224
extern void SN_close_env(struct SN_env * z);
3325

34-
extern void SN_set_current(struct SN_env * z, int size, const symbol * s);
26+
extern int SN_set_current(struct SN_env * z, int size, const symbol * s);
27+

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