dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
gedcom-parse.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
General update of docs.
[gedcom-parse.git]
/
gedcom
/
multilex.c
diff --git
a/gedcom/multilex.c
b/gedcom/multilex.c
index b7becba94c7d6bf8d8012614e18e1f034f62014e..42b9f5000613e95c959b32e226e89578e1a2fe4a 100644
(file)
--- a/
gedcom/multilex.c
+++ b/
gedcom/multilex.c
@@
-1,5
+1,5
@@
/* The lexer multiplexer for Gedcom.
/* The lexer multiplexer for Gedcom.
- Copyright (C) 2001 The Genes Development Team
+ Copyright (C) 2001
,2002
The Genes Development Team
This file is part of the Gedcom parser library.
Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
This file is part of the Gedcom parser library.
Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
@@
-24,6
+24,7
@@
#include "gedcom_internal.h"
#include "multilex.h"
#include "encoding.h"
#include "gedcom_internal.h"
#include "multilex.h"
#include "encoding.h"
+#include "xref.h"
int line_no;
int line_no;
@@
-71,34
+72,34
@@
int determine_encoding(FILE* f)
fread(first, 1, 2, f);
if ((first[0] == '0') && (first[1] == ' ')) {
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'))
{
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'))
{
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'))
{
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'))
{
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 {
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;
}
fseek(f, 0, 0);
return ONE_BYTE;
}
@@
-110,29
+111,36
@@
int gedcom_parse_file(char* file_name)
int result = 1;
FILE* file;
int result = 1;
FILE* file;
+ char *save_locale = strdup(setlocale(LC_ALL, NULL));
char *save_textdom = textdomain(NULL);
char *save_textdom = textdomain(NULL);
- setlocale(LC_ALL, ""); /* In fact only necessary if main program doesn't
- do this */
+ setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
bindtextdomain(PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset(PACKAGE, INTERNAL_ENCODING);
textdomain(PACKAGE);
line_no = 1;
file = fopen(file_name, "r");
if (!file) {
textdomain(PACKAGE);
line_no = 1;
file = fopen(file_name, "r");
if (!file) {
- gedcom_error(_("Could not open file '%s'
\n
"), file_name);
+ gedcom_error(_("Could not open file '%s'"), file_name);
}
else {
init_encodings();
enc = determine_encoding(file);
if (lexer_init(enc, file)) {
}
else {
init_encodings();
enc = determine_encoding(file);
if (lexer_init(enc, file)) {
+ line_no = 1;
+ make_xref_table();
result = gedcom_parse();
result = gedcom_parse();
+ if (result == 0)
+ result = check_xref_table();
}
lexer_close();
fclose(file);
}
textdomain(save_textdom);
}
lexer_close();
fclose(file);
}
textdomain(save_textdom);
+ setlocale(LC_ALL, save_locale);
+ free(save_locale);
return result;
}
return result;
}