From: Peter Verthez Date: Sun, 9 Dec 2001 17:26:06 +0000 (+0000) Subject: Look for encoding configuration file in current directory AND in package X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=8831b70a872f0999a1de7082064559956d45171a;p=gedcom-parse.git Look for encoding configuration file in current directory AND in package data directory. --- diff --git a/gedcom/encoding.c b/gedcom/encoding.c index d306dfa..5fdaba5 100644 --- a/gedcom/encoding.c +++ b/gedcom/encoding.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "gedcom_internal.h" #include "encoding.h" @@ -84,7 +85,16 @@ void init_encodings() char charwidth[MAXBUF + 1]; char iconv_n[MAXBUF + 1]; in = fopen(ENCODING_CONF_FILE, "r"); - if (in != NULL) { + if (in == NULL) { + char path[PATH_MAX]; + sprintf(path, "%s/%s", PKGDATADIR, ENCODING_CONF_FILE); + in = fopen(path, "r"); + } + if (in == NULL) { + gedcom_warning("Could not open encoding configuration file '%s'", + ENCODING_CONF_FILE); + } + else { while (fgets(buffer, sizeof(buffer), in) != NULL) { if (buffer[strlen(buffer) - 1] != '\n') { gedcom_error("Line too long in encoding configuration file '%s'", @@ -104,10 +114,6 @@ void init_encodings() } fclose(in); } - else { - gedcom_warning("Could not open encoding configuration file '%s'", - ENCODING_CONF_FILE); - } } }