#include <stdarg.h>
#include <locale.h>
#include <errno.h>
+#include <iconv.h>
#include "gedcom.h"
#include "utf8-locale.h"
#define OUTFILE "testgedcom.out"
FILE* outfile = NULL;
+int quiet = 0;
void output(int to_stdout_too, char* format, ...)
{
if (outfile) {
vfprintf(outfile, format, ap);
}
- if (to_stdout_too) {
+ if (to_stdout_too && !quiet) {
vprintf(format, ap);
}
va_end(ap);
printf(" -da Debug setting: libgedcom + yacc debug messages\n");
printf(" -2 Run the test parse 2 times instead of once\n");
printf(" -3 Run the test parse 3 times instead of once\n");
+ printf(" -q No output to standard output\n");
}
Gedcom_ctxt header_start(int level, Gedcom_val xref, char *tag,
int tag_value)
{
char *converted = NULL;
+ int conv_fails = 0;
if (raw_value)
- converted = convert_utf8_to_locale(raw_value);
- output(0, "== %d %s (%d) %s (ctxt is %d)\n",
- level, tag, tag_value, converted, (int)ctxt);
+ converted = convert_utf8_to_locale(raw_value, &conv_fails);
+ output(0, "== %d %s (%d) %s (ctxt is %d, conversion failures: %d)\n",
+ level, tag, tag_value, converted, (int)ctxt, conv_fails);
}
void subscribe_callbacks()
else if (!strncmp(argv[i], "-3", 3)) {
run_times = 3;
}
+ else if (!strncmp(argv[i], "-q", 3)) {
+ quiet = 1;
+ }
else if (strncmp(argv[i], "-", 1)) {
file_name = argv[i];
break;
}
fclose(outfile);
if (result == 0) {
- printf("Parse succeeded\n");
+ output(1, "Parse succeeded\n");
return 0;
}
else {
- printf("Parse failed\n");
+ output(1, "Parse failed\n");
return 1;
}
}