X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom%2Fmultilex.c;h=cff8608f049337a143c1dca78265807dfc7bcdad;hb=77989125b676e463aa052e0fd22f5bcb98d0ff77;hp=a6ea0faa20caa258deadb7640659f7008f68e507;hpb=8093e53a57e174b019f07760f5bf815271ceee9b;p=gedcom-parse.git diff --git a/gedcom/multilex.c b/gedcom/multilex.c index a6ea0fa..cff8608 100644 --- a/gedcom/multilex.c +++ b/gedcom/multilex.c @@ -1,11 +1,22 @@ -/* This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * +/* The lexer multiplexer for Gedcom. + Copyright (C) 2001 The Genes Development Team + This file is part of the Gedcom parser library. + Contributed by Peter Verthez , 2001. - (C) 2001 by The Genes Development Team - Original author: Peter Verthez (Peter.Verthez@advalvas.be) -*/ + The Gedcom parser library is free software; you can redistribute it + and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The Gedcom parser library is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the Gedcom parser library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ /* $Id$ */ /* $Name$ */ @@ -60,34 +71,34 @@ int determine_encoding(FILE* f) fread(first, 1, 2, f); if ((first[0] == '0') && (first[1] == ' ')) { - gedcom_message("One-byte encoding"); + gedcom_debug_print(_("One-byte encoding")); fseek(f, 0, 0); return ONE_BYTE; } else if ((first[0] == '\0') && (first[1] == '0')) { - gedcom_message("Two-byte encoding, high-low"); + gedcom_debug_print(_("Two-byte encoding, high-low")); fseek(f, 0, 0); return TWO_BYTE_HILO; } else if ((first[0] == '\xFE') && (first[1] == '\xFF')) { - gedcom_message("Two-byte encoding, high-low, with BOM"); + gedcom_debug_print(_("Two-byte encoding, high-low, with BOM")); return TWO_BYTE_HILO; } else if ((first[0] == '0') && (first[1] == '\0')) { - gedcom_message("Two-byte encoding, low-high"); + gedcom_debug_print(_("Two-byte encoding, low-high")); fseek(f, 0, 0); return TWO_BYTE_LOHI; } else if ((first[0] == '\xFF') && (first[1] == '\xFE')) { - gedcom_message("Two-byte encoding, low-high, with BOM"); + gedcom_debug_print(_("Two-byte encoding, low-high, with BOM")); return TWO_BYTE_LOHI; } else { - gedcom_message("Unknown encoding, falling back to one-byte"); + gedcom_warning(_("Unknown encoding, falling back to one-byte")); fseek(f, 0, 0); return ONE_BYTE; } @@ -97,22 +108,33 @@ int gedcom_parse_file(char* file_name) { ENCODING enc; int result = 1; - FILE* file = fopen (file_name, "r"); + FILE* file; + + char *save_textdom = textdomain(NULL); + setlocale(LC_ALL, ""); /* In fact only necessary if main program doesn't + do this */ + bindtextdomain(PACKAGE, LOCALEDIR); + bind_textdomain_codeset(PACKAGE, INTERNAL_ENCODING); + textdomain(PACKAGE); + line_no = 1; + file = fopen(file_name, "r"); if (!file) { - gedcom_error("Could not open file '%s'\n", file_name); - return 1; + gedcom_error(_("Could not open file '%s'"), file_name); } - - init_encodings(); - enc = determine_encoding(file); - - if (lexer_init(enc, file)) { - result = gedcom_parse(); + else { + init_encodings(); + enc = determine_encoding(file); + + if (lexer_init(enc, file)) { + line_no = 1; + result = gedcom_parse(); + } + lexer_close(); + fclose(file); } - lexer_close(); - fclose(file); - + + textdomain(save_textdom); return result; }