Skip to content

Commit d3e36da

Browse files
committed
Make the standard stopword files be sought relative to share_dir, so
that a tsearch2 installation can be relocatable.
1 parent 4347cc2 commit d3e36da

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

contrib/tsearch2/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/contrib/tsearch2/Makefile,v 1.7 2004/08/20 20:13:09 momjian Exp $
1+
# $PostgreSQL: pgsql/contrib/tsearch2/Makefile,v 1.8 2004/10/17 23:09:31 tgl Exp $
22

33
MODULE_big = tsearch2
44
OBJS = dict_ex.o dict.o snmap.o stopword.o common.o prs_dcfg.o \
@@ -39,8 +39,7 @@ $(SUBDIRS:%=%-recursive):
3939
$(MAKE) -C $(subst -recursive,,$@) SUBSYS.o
4040

4141
tsearch2.sql: tsearch.sql.in
42-
sed -e 's,MODULE_PATHNAME,$$libdir/$(MODULE_big),g' \
43-
-e 's,DATA_PATH,$(datadir)/contrib,g' $< >$@
42+
sed -e 's,MODULE_PATHNAME,$$libdir/$(MODULE_big),g' $< >$@
4443

4544
untsearch2.sql: untsearch.sql.in
4645
cp $< $@

contrib/tsearch2/stopword.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
* stopword library
33
* Teodor Sigaev <teodor@sigaev.ru>
44
*/
5-
#include <errno.h>
6-
#include <stdlib.h>
7-
#include <string.h>
5+
#include "postgres.h"
6+
87
#include <ctype.h>
98

10-
#include "postgres.h"
9+
#include "miscadmin.h"
10+
1111
#include "common.h"
1212
#include "dict.h"
1313

@@ -51,10 +51,23 @@ readstoplist(text *in, StopList * s)
5151
if (in && VARSIZE(in) - VARHDRSZ > 0)
5252
{
5353
char *filename = text2char(in);
54-
FILE *hin = NULL;
54+
FILE *hin;
5555
char buf[STOPBUFLEN];
5656
int reallen = 0;
5757

58+
/* if path is relative, take it as relative to share dir */
59+
if (!is_absolute_path(filename))
60+
{
61+
char sharepath[MAXPGPATH];
62+
char *absfn;
63+
64+
get_share_path(my_exec_path, sharepath);
65+
absfn = palloc(strlen(sharepath) + strlen(filename) + 2);
66+
sprintf(absfn, "%s/%s", sharepath, filename);
67+
pfree(filename);
68+
filename = absfn;
69+
}
70+
5871
if ((hin = fopen(filename, "r")) == NULL)
5972
ereport(ERROR,
6073
(errcode(ERRCODE_CONFIG_FILE_ERROR),

contrib/tsearch2/tsearch.sql.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ CREATE FUNCTION snb_lexize(internal,internal,int4)
7777
insert into pg_ts_dict select
7878
'en_stem',
7979
'snb_en_init(text)',
80-
'DATA_PATH/english.stop',
80+
'contrib/english.stop',
8181
'snb_lexize(internal,internal,int4)',
8282
'English Stemmer. Snowball.'
8383
;
@@ -90,7 +90,7 @@ CREATE FUNCTION snb_ru_init(text)
9090
insert into pg_ts_dict select
9191
'ru_stem',
9292
'snb_ru_init(text)',
93-
'DATA_PATH/russian.stop',
93+
'contrib/russian.stop',
9494
'snb_lexize(internal,internal,int4)',
9595
'Russian Stemmer. Snowball.'
9696
;

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