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
Added message.c.
[gedcom-parse.git]
/
gedcom
/
multilex.c
diff --git
a/gedcom/multilex.c
b/gedcom/multilex.c
index 9a27c187f9867f56454e51cfc53f7ed69a620edb..8473624bad70c4c75899b715de7229b241788e9f 100644
(file)
--- a/
gedcom/multilex.c
+++ b/
gedcom/multilex.c
@@
-71,34
+71,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;
}
@@
-108,22
+108,32
@@
int gedcom_parse_file(char* file_name)
{
ENCODING enc;
int result = 1;
{
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);
+ textdomain(PACKAGE);
+
line_no = 1;
line_no = 1;
+ file = fopen(file_name, "r");
if (!file) {
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;
}
return result;
}