Commit d3e36da7 authored by Tom Lane's avatar Tom Lane

Make the standard stopword files be sought relative to share_dir, so

that a tsearch2 installation can be relocatable.
parent 4347cc23
# $PostgreSQL: pgsql/contrib/tsearch2/Makefile,v 1.7 2004/08/20 20:13:09 momjian Exp $ # $PostgreSQL: pgsql/contrib/tsearch2/Makefile,v 1.8 2004/10/17 23:09:31 tgl Exp $
MODULE_big = tsearch2 MODULE_big = tsearch2
OBJS = dict_ex.o dict.o snmap.o stopword.o common.o prs_dcfg.o \ OBJS = dict_ex.o dict.o snmap.o stopword.o common.o prs_dcfg.o \
...@@ -39,8 +39,7 @@ $(SUBDIRS:%=%-recursive): ...@@ -39,8 +39,7 @@ $(SUBDIRS:%=%-recursive):
$(MAKE) -C $(subst -recursive,,$@) SUBSYS.o $(MAKE) -C $(subst -recursive,,$@) SUBSYS.o
tsearch2.sql: tsearch.sql.in tsearch2.sql: tsearch.sql.in
sed -e 's,MODULE_PATHNAME,$$libdir/$(MODULE_big),g' \ sed -e 's,MODULE_PATHNAME,$$libdir/$(MODULE_big),g' $< >$@
-e 's,DATA_PATH,$(datadir)/contrib,g' $< >$@
untsearch2.sql: untsearch.sql.in untsearch2.sql: untsearch.sql.in
cp $< $@ cp $< $@
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
* stopword library * stopword library
* Teodor Sigaev <teodor@sigaev.ru> * Teodor Sigaev <teodor@sigaev.ru>
*/ */
#include <errno.h> #include "postgres.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h> #include <ctype.h>
#include "postgres.h" #include "miscadmin.h"
#include "common.h" #include "common.h"
#include "dict.h" #include "dict.h"
...@@ -51,10 +51,23 @@ readstoplist(text *in, StopList * s) ...@@ -51,10 +51,23 @@ readstoplist(text *in, StopList * s)
if (in && VARSIZE(in) - VARHDRSZ > 0) if (in && VARSIZE(in) - VARHDRSZ > 0)
{ {
char *filename = text2char(in); char *filename = text2char(in);
FILE *hin = NULL; FILE *hin;
char buf[STOPBUFLEN]; char buf[STOPBUFLEN];
int reallen = 0; int reallen = 0;
/* if path is relative, take it as relative to share dir */
if (!is_absolute_path(filename))
{
char sharepath[MAXPGPATH];
char *absfn;
get_share_path(my_exec_path, sharepath);
absfn = palloc(strlen(sharepath) + strlen(filename) + 2);
sprintf(absfn, "%s/%s", sharepath, filename);
pfree(filename);
filename = absfn;
}
if ((hin = fopen(filename, "r")) == NULL) if ((hin = fopen(filename, "r")) == NULL)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CONFIG_FILE_ERROR), (errcode(ERRCODE_CONFIG_FILE_ERROR),
......
...@@ -77,7 +77,7 @@ CREATE FUNCTION snb_lexize(internal,internal,int4) ...@@ -77,7 +77,7 @@ CREATE FUNCTION snb_lexize(internal,internal,int4)
insert into pg_ts_dict select insert into pg_ts_dict select
'en_stem', 'en_stem',
'snb_en_init(text)', 'snb_en_init(text)',
'DATA_PATH/english.stop', 'contrib/english.stop',
'snb_lexize(internal,internal,int4)', 'snb_lexize(internal,internal,int4)',
'English Stemmer. Snowball.' 'English Stemmer. Snowball.'
; ;
...@@ -90,7 +90,7 @@ CREATE FUNCTION snb_ru_init(text) ...@@ -90,7 +90,7 @@ CREATE FUNCTION snb_ru_init(text)
insert into pg_ts_dict select insert into pg_ts_dict select
'ru_stem', 'ru_stem',
'snb_ru_init(text)', 'snb_ru_init(text)',
'DATA_PATH/russian.stop', 'contrib/russian.stop',
'snb_lexize(internal,internal,int4)', 'snb_lexize(internal,internal,int4)',
'Russian Stemmer. Snowball.' 'Russian Stemmer. Snowball.'
; ;
......
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