+}
+
+void cleanup_encodings()
+{
+ hash_free(encodings);
+}
+
+/* Let function be called before main() */
+void update_gconv_search_path() __attribute__ ((constructor));
+
+void update_gconv_search_path()
+{
+ 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);
+ }
+ /* Ignore failures of putenv (can't do anything about it anyway) */
+ putenv(new_gconv_path);