Commit f82b853b authored by Teodor Sigaev's avatar Teodor Sigaev

1 Update Snowball sources

2 Makefile fixes
parent 3b0453b2
......@@ -49,7 +49,7 @@ snb_en_init(PG_FUNCTION_ARGS)
PG_FREE_IF_COPY(in, 0);
}
d->z = english_create_env();
d->z = english_ISO_8859_1_create_env();
if (!d->z)
{
freestoplist(&(d->stoplist));
......@@ -57,7 +57,7 @@ snb_en_init(PG_FUNCTION_ARGS)
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
d->stem = english_stem;
d->stem = english_ISO_8859_1_stem;
PG_RETURN_POINTER(d);
}
......@@ -83,7 +83,7 @@ snb_ru_init(PG_FUNCTION_ARGS)
PG_FREE_IF_COPY(in, 0);
}
d->z = russian_create_env();
d->z = russian_KOI8_R_create_env();
if (!d->z)
{
freestoplist(&(d->stoplist));
......@@ -91,7 +91,7 @@ snb_ru_init(PG_FUNCTION_ARGS)
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
d->stem = russian_stem;
d->stem = russian_KOI8_R_stem;
PG_RETURN_POINTER(d);
}
......
......@@ -50,7 +50,7 @@ Example 1:
2. Create template files for Portuguese
./config.sh -n pt -s -p portuguese -v -C'Snowball stemmer for Portuguese'
./config.sh -n pt -s -p portuguese_ISO_8859_1 -v -C'Snowball stemmer for Portuguese'
Note, that argument for -p option should be *the same* as name of stemming
function in stem.c (without _stem)
......@@ -82,8 +82,9 @@ Example 1:
psql -d testdict -c "select * from pg_ts_dict where dict_name='pt';"
dict_name | dict_init | dict_initoption | dict_lexize | dict_comment
-----------+-----------+-----------------+-------------+---------------------------------
pt | 7177806 | | 7159330 | Snowball stemmer for Portuguese
-----------+--------------------+-----------------+---------------------------------------+---------------------------------
pt | dinit_pt(internal) | | snb_lexize(internal,internal,integer) | Snowball stemmer for Portuguese
(1 row)
......
......@@ -131,11 +131,18 @@ fi
if [ ${#cfile} -ne 0 ] || [ ${#hfile} -ne 0 ] ; then
[ $verbose = "yes" ] && echo -n 'Copy source and header files... '
if [ ${#cfile} -ne 0 ] ; then
if [ $stemmode = "yes" ] ; then
for cfn in $cfile
do
sed s#../runtime/## < $cfn > ../../$dir/$cfn
done
else
if ! cp $cfile ../../$dir ; then
echo "Cant cp all or one of files: $cfile"
echo "Can't cp all or one of files: $cfile"
exit 1
fi
fi
fi
if [ ${#hfile} -ne 0 ] ; then
if ! cp $hfile ../../$dir ; then
echo "Cant cp all or one of files: $hfile"
......
# $PostgreSQL: pgsql/contrib/tsearch2/ispell/Makefile,v 1.6 2004/06/23 11:06:11 teodor Exp $
# $PostgreSQL: pgsql/contrib/tsearch2/ispell/Makefile,v 1.7 2005/09/15 11:14:18 teodor Exp $
subdir = contrib/tsearch2/ispell
PG_CPPFLAGS = -I$(srcdir)/..
SUBOBJS = spell.o regis.o
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS)
ifdef USE_PGXS
PGXS = $(shell pg_config --pgxs)
include $(PGXS)
else
subdir = contrib/tsearch2
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
PG_CPPFLAGS = -I$(srcdir)/.. $(CPPFLAGS)
override CFLAGS += $(CFLAGS_SL)
SUBOBJS = spell.o regis.o
all: SUBSYS.o
SUBSYS.o: $(SUBOBJS)
$(LD) $(LDREL) $(LDOUT) $@ $^
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS)
include $(top_srcdir)/contrib/contrib-global.mk
# $PostgreSQL: pgsql/contrib/tsearch2/snowball/Makefile,v 1.5 2003/11/29 19:51:36 pgsql Exp $
# $PostgreSQL: pgsql/contrib/tsearch2/snowball/Makefile,v 1.6 2005/09/15 11:14:18 teodor Exp $
subdir = contrib/tsearch2/snowball
PG_CPPFLAGS = -I$(srcdir)/..
SUBOBJS = english_stem.o api.o russian_stem.o utilities.o
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS)
ifdef USE_PGXS
PGXS = $(shell pg_config --pgxs)
include $(PGXS)
else
subdir = contrib/tsearch2
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
PG_CPPFLAGS = -I$(srcdir)/..
override CFLAGS += $(CFLAGS_SL)
SUBOBJS = english_stem.o api.o russian_stem.o utilities.o
all: SUBSYS.o
SUBSYS.o: $(SUBOBJS)
$(LD) $(LDREL) $(LDOUT) $@ $^
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS)
include $(top_srcdir)/contrib/contrib-global.mk
#include <stdlib.h>
#include <stdlib.h> /* for calloc, free */
#include "header.h"
struct SN_env *
SN_create_env(int S_size, int I_size, int B_size)
extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size)
{
struct SN_env *z = (struct SN_env *) calloc(1, sizeof(struct SN_env));
struct SN_env *z2 = z;
if (!z)
return z;
struct SN_env * z = (struct SN_env *) calloc(1, sizeof(struct SN_env));
if (z == NULL) return NULL;
z->p = create_s();
if (!z->p)
z = NULL;
if (z && S_size)
{
if ((z->S = (symbol * *) calloc(S_size, sizeof(symbol *))))
if (z->p == NULL) goto error;
if (S_size)
{
int i;
z->S = (symbol * *) calloc(S_size, sizeof(symbol *));
if (z->S == NULL) goto error;
for (i = 0; i < S_size; i++)
{
if (!(z->S[i] = create_s()))
{
z = NULL;
break;
}
z->S[i] = create_s();
if (z->S[i] == NULL) goto error;
}
z2->S_size = i;
}
else
z = NULL;
z->S_size = S_size;
}
if (z && I_size)
if (I_size)
{
z->I = (int *) calloc(I_size, sizeof(int));
if (z->I)
if (z->I == NULL) goto error;
z->I_size = I_size;
else
z = NULL;
}
if (z && B_size)
if (B_size)
{
z->B = (symbol *) calloc(B_size, sizeof(symbol));
if (z->B)
if (z->B == NULL) goto error;
z->B_size = B_size;
else
z = NULL;
}
if (!z)
SN_close_env(z2);
return z;
error:
SN_close_env(z);
return NULL;
}
void
SN_close_env(struct SN_env * z)
extern void SN_close_env(struct SN_env * z)
{
if (z->S && z->S_size)
{
if (z == NULL) return;
if (z->S_size)
{
int i;
for (i = 0; i < z->S_size; i++)
{
lose_s(z->S[i]);
}
free(z->S);
}
if (z->I_size)
free(z->I);
if (z->B_size)
free(z->B);
if (z->p)
lose_s(z->p);
if (z->I_size) free(z->I);
if (z->B_size) free(z->B);
if (z->p) lose_s(z->p);
free(z);
}
void
SN_set_current(struct SN_env * z, int size, const symbol * s)
extern int SN_set_current(struct SN_env * z, int size, const symbol * s)
{
replace_s(z, 0, z->l, size, s);
int err = replace_s(z, 0, z->l, size, s, NULL);
z->c = 0;
return err;
}
......@@ -11,24 +11,17 @@ typedef unsigned char symbol;
*/
struct SN_env
{
symbol *p;
int c;
int a;
int l;
int lb;
int bra;
int ket;
int S_size;
int I_size;
int B_size;
symbol **S;
int *I;
symbol *B;
struct SN_env {
symbol * p;
int c; int a; int l; int lb; int bra; int ket;
int S_size; int I_size; int B_size;
symbol * * S;
int * I;
symbol * B;
};
extern struct SN_env *SN_create_env(int S_size, int I_size, int B_size);
extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size);
extern void SN_close_env(struct SN_env * z);
extern void SN_set_current(struct SN_env * z, int size, const symbol * s);
extern int SN_set_current(struct SN_env * z, int size, const symbol * s);
This diff is collapsed.
/* This file was generated automatically by the Snowball to ANSI C compiler */
extern struct SN_env *english_create_env(void);
extern void english_close_env(struct SN_env * z);
#ifdef __cplusplus
extern "C" {
#endif
extern struct SN_env * english_ISO_8859_1_create_env(void);
extern void english_ISO_8859_1_close_env(struct SN_env * z);
extern int english_ISO_8859_1_stem(struct SN_env * z);
#ifdef __cplusplus
}
#endif
extern int english_stem(struct SN_env * z);
#include <limits.h>
#include "api.h"
#define MAXINT INT_MAX
#define MININT INT_MIN
#define HEAD 2*sizeof(int)
#define SIZE(p) ((int *)(p))[-1]
......@@ -7,26 +13,27 @@
#define CAPACITY(p) ((int *)(p))[-2]
struct among
{
int s_size; /* number of chars in string */
symbol *s; /* search string */
int substring_i; /* index to longest matching substring */
{ int s_size; /* number of chars in string */
symbol * s; /* search string */
int substring_i;/* index to longest matching substring */
int result; /* result of the lookup */
int (*function) (struct SN_env *);
int (* function)(struct SN_env *);
};
extern symbol *create_s(void);
extern symbol * create_s(void);
extern void lose_s(symbol * p);
extern int in_grouping(struct SN_env * z, unsigned char *s, int min, int max);
extern int in_grouping_b(struct SN_env * z, unsigned char *s, int min, int max);
extern int out_grouping(struct SN_env * z, unsigned char *s, int min, int max);
extern int out_grouping_b(struct SN_env * z, unsigned char *s, int min, int max);
extern int skip_utf8(const symbol * p, int c, int lb, int l, int n);
extern int in_range(struct SN_env * z, int min, int max);
extern int in_range_b(struct SN_env * z, int min, int max);
extern int out_range(struct SN_env * z, int min, int max);
extern int out_range_b(struct SN_env * z, int min, int max);
extern int in_grouping_U(struct SN_env * z, unsigned char * s, int min, int max);
extern int in_grouping_b_U(struct SN_env * z, unsigned char * s, int min, int max);
extern int out_grouping_U(struct SN_env * z, unsigned char * s, int min, int max);
extern int out_grouping_b_U(struct SN_env * z, unsigned char * s, int min, int max);
extern int in_grouping(struct SN_env * z, unsigned char * s, int min, int max);
extern int in_grouping_b(struct SN_env * z, unsigned char * s, int min, int max);
extern int out_grouping(struct SN_env * z, unsigned char * s, int min, int max);
extern int out_grouping_b(struct SN_env * z, unsigned char * s, int min, int max);
extern int eq_s(struct SN_env * z, int s_size, symbol * s);
extern int eq_s_b(struct SN_env * z, int s_size, symbol * s);
......@@ -36,16 +43,16 @@ extern int eq_v_b(struct SN_env * z, symbol * p);
extern int find_among(struct SN_env * z, struct among * v, int v_size);
extern int find_among_b(struct SN_env * z, struct among * v, int v_size);
extern symbol *increase_size(symbol * p, int n);
extern int replace_s(struct SN_env * z, int c_bra, int c_ket, int s_size, const symbol * s);
extern void slice_from_s(struct SN_env * z, int s_size, symbol * s);
extern void slice_from_v(struct SN_env * z, symbol * p);
extern void slice_del(struct SN_env * z);
extern int replace_s(struct SN_env * z, int c_bra, int c_ket, int s_size, const symbol * s, int * adjustment);
extern int slice_from_s(struct SN_env * z, int s_size, symbol * s);
extern int slice_from_v(struct SN_env * z, symbol * p);
extern int slice_del(struct SN_env * z);
extern void insert_s(struct SN_env * z, int bra, int ket, int s_size, symbol * s);
extern void insert_v(struct SN_env * z, int bra, int ket, symbol * p);
extern int insert_s(struct SN_env * z, int bra, int ket, int s_size, symbol * s);
extern int insert_v(struct SN_env * z, int bra, int ket, symbol * p);
extern symbol *slice_to(struct SN_env * z, symbol * p);
extern symbol *assign_to(struct SN_env * z, symbol * p);
extern symbol * slice_to(struct SN_env * z, symbol * p);
extern symbol * assign_to(struct SN_env * z, symbol * p);
extern void debug(struct SN_env * z, int number, int line_count);
This diff is collapsed.
/* This file was generated automatically by the Snowball to ANSI C compiler */
extern struct SN_env *russian_create_env(void);
extern void russian_close_env(struct SN_env * z);
#ifdef __cplusplus
extern "C" {
#endif
extern struct SN_env * russian_KOI8_R_create_env(void);
extern void russian_KOI8_R_close_env(struct SN_env * z);
extern int russian_KOI8_R_stem(struct SN_env * z);
#ifdef __cplusplus
}
#endif
extern int russian_stem(struct SN_env * z);
This diff is collapsed.
# $PostgreSQL: pgsql/contrib/tsearch2/wordparser/Makefile,v 1.5 2003/11/29 19:51:36 pgsql Exp $
# $PostgreSQL: pgsql/contrib/tsearch2/wordparser/Makefile,v 1.6 2005/09/15 11:14:18 teodor Exp $
subdir = contrib/tsearch2/wordparser
PG_CPPFLAGS = -I$(srcdir)/..
SUBOBJS = parser.o deflex.o
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS) parser.c
ifdef USE_PGXS
PGXS = $(shell pg_config --pgxs)
include $(PGXS)
else
subdir = contrib/tsearch2
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
PG_CPPFLAGS = -I$(srcdir)/..
override CFLAGS += $(CFLAGS_SL)
SUBOBJS = parser.o deflex.o
all: SUBSYS.o
parser.c: parser.l
......@@ -22,6 +29,4 @@ endif
SUBSYS.o: $(SUBOBJS)
$(LD) $(LDREL) $(LDOUT) $@ $^
EXTRA_CLEAN = SUBSYS.o $(SUBOBJS) parser.c
include $(top_srcdir)/contrib/contrib-global.mk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment