From: Peter Verthez Date: Sun, 9 Dec 2001 18:25:25 +0000 (+0000) Subject: Put data directory of libgedcom in the GCONV_PATH (for the ANSEL encoding X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=4e88e899a5e86212eb2586d00e0ee7fdf6bdde4e;p=gedcom-parse.git Put data directory of libgedcom in the GCONV_PATH (for the ANSEL encoding module). --- diff --git a/gedcom/encoding.c b/gedcom/encoding.c index 5fdaba5..de7770c 100644 --- a/gedcom/encoding.c +++ b/gedcom/encoding.c @@ -15,11 +15,13 @@ #include #include #include +#include #include "gedcom_internal.h" #include "encoding.h" #define INTERNAL_ENCODING "UTF8" #define ENCODING_CONF_FILE "gedcom.enc" +#define GCONV_SEARCH_PATH "GCONV_PATH" #define MAXBUF 255 static iconv_t cd_to_internal = (iconv_t) -1; @@ -84,6 +86,34 @@ void init_encodings() char gedcom_n[MAXBUF + 1]; char charwidth[MAXBUF + 1]; char iconv_n[MAXBUF + 1]; + char *gconv_path; + + /* Add gedcom data directory to gconv search path */ + gconv_path = getenv(GCONV_SEARCH_PATH); + if (gconv_path == NULL || strstr(gconv_path, PKGDATADIR) == NULL) { + char *new_gconv_path; + if (gconv_path == NULL) { + new_gconv_path = (char *)malloc(strlen(GCONV_SEARCH_PATH) + + strlen(PKGDATADIR) + + 2); + sprintf(new_gconv_path, "%s=%s", GCONV_SEARCH_PATH, PKGDATADIR); + } + else { + new_gconv_path = (char *)malloc(strlen(GCONV_SEARCH_PATH) + + strlen(gconv_path) + + strlen(PKGDATADIR) + + 3); + sprintf(new_gconv_path, "%s=%s:%s", + GCONV_SEARCH_PATH, gconv_path, PKGDATADIR); + } + if (putenv(new_gconv_path) != 0) { + gedcom_warning("Failed updating environment variable %s", + GCONV_SEARCH_PATH); + } + printf("%s\n", new_gconv_path); + } + + /* Open gedcom configuration file and read */ in = fopen(ENCODING_CONF_FILE, "r"); if (in == NULL) { char path[PATH_MAX];