X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom%2Fencoding.c;h=e0140b2f1dff7d32e24743748f10b42004d74f21;hb=4c78192cf17bde2f3c6bff7bb90757c21d1e3792;hp=469854b0d8528aa78203db911c594f70cb8a547c;hpb=015d4f6782128a884085c6d6958e4509aeb96655;p=gedcom-parse.git diff --git a/gedcom/encoding.c b/gedcom/encoding.c index 469854b..e0140b2 100644 --- a/gedcom/encoding.c +++ b/gedcom/encoding.c @@ -22,7 +22,6 @@ /* $Name$ */ #include -#include #include #include #include @@ -36,10 +35,7 @@ #define GCONV_SEARCH_PATH "GCONV_PATH" #define MAXBUF 255 -/* -static iconv_t cd_to_internal = (iconv_t) -1; -*/ -static ENCODING the_enc = ONE_BYTE; +static Encoding the_enc = ONE_BYTE; static hash_t *encodings = NULL; const char* charwidth_string[] = { "1", "2_HILO", "2_LOHI" }; @@ -83,10 +79,12 @@ void add_encoding(const char *gedcom_n, const char* charwidth, MEMORY_ERROR; } -char* get_encoding(const char* gedcom_n, ENCODING enc) +char* get_encoding(const char* gedcom_n, Encoding enc) { char *key; hnode_t *node; + + if (encodings == NULL) return NULL; key = (char*)malloc(strlen(gedcom_n) + strlen(charwidth_string[enc]) + 3); @@ -222,6 +220,7 @@ void init_encodings() if (buffer[strlen(buffer) - 1] != '\n') { gedcom_error(_("Line too long in encoding configuration file '%s'"), ENCODING_CONF_FILE); + line_no = 0; return; } else if ((buffer[0] != '#') && (strcmp(buffer, "\n") != 0)) { @@ -231,10 +230,12 @@ void init_encodings() else { gedcom_error(_("Missing data in encoding configuration file '%s'"), ENCODING_CONF_FILE); + line_no = 0; return; } } } + line_no = 0; if (fclose(in) != 0) { gedcom_warning(_("Error closing file '%s': %s"), ENCODING_CONF_FILE, strerror(errno)); @@ -243,7 +244,7 @@ void init_encodings() } } -void set_encoding_width(ENCODING enc) +void set_encoding_width(Encoding enc) { the_enc = enc; }