aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-07-01 02:25:51 +0200
committerBruno Haible <bruno@clisp.org>2012-07-01 02:25:51 +0200
commit1f574c8a69e51e4d36698e803be6e510c9d45637 (patch)
tree25f16e25258d18e2a7c2d32f9f55c1433f994400
parent3326ae997aec4b5c558b3ef8edaa5d4c4df9f0e6 (diff)
downloadandroid-libiconv-1f574c8a69e51e4d36698e803be6e510c9d45637.tar.gz
android-libiconv-1f574c8a69e51e4d36698e803be6e510c9d45637.tar.bz2
android-libiconv-1f574c8a69e51e4d36698e803be6e510c9d45637.zip
Make it possible to run 'genaliases' on native Windows.
-rw-r--r--ChangeLog9
-rw-r--r--Makefile.devel10
-rw-r--r--lib/genaliases.c71
3 files changed, 61 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index a98e0f9..c7d6c7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-06-30 Bruno Haible <bruno@clisp.org>
+
+ Make it possible to run 'genaliases' on native Windows.
+ * lib/genaliases.c (main): Expect 3 arguments. Open the output files
+ explicitly. Complain if they don't exist. Improve error checking.
+ * Makefile.devel (lib/aliases*.h): Pass the output filenames as
+ arguments to genaliases.
+ Reported at <http://savannah.gnu.org/bugs/?36748>.
+
2012-05-13 Bruno Haible <bruno@clisp.org>
Tweak the GB18030 converter to map 0x8135F437 to U+E7C7.
diff --git a/Makefile.devel b/Makefile.devel
index c781577..e9bd88b 100644
--- a/Makefile.devel
+++ b/Makefile.devel
@@ -104,7 +104,7 @@ include/iconv.h.build.in : include/iconv.h.in include/export.h
lib/aliases.h lib/canonical.h lib/canonical_local.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
$(CC) $(CFLAGS) lib/genaliases.c -o genaliases
- ./genaliases > lib/aliases.gperf 3> canonical.sh 4> canonical_local.sh
+ ./genaliases lib/aliases.gperf canonical.sh canonical_local.sh
$(RM) genaliases
$(GPERF) -m 10 lib/aliases.gperf > tmp.h
$(CP) tmp.h lib/aliases.h
@@ -114,7 +114,7 @@ lib/aliases.h lib/canonical.h lib/canonical_local.h : lib/encodings.def lib/enco
lib/aliases_sysaix.h lib/canonical_sysaix.h lib/canonical_local_sysaix.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
$(CC) $(CFLAGS) -DUSE_AIX_ALIASES lib/genaliases.c -o genaliases
- ./genaliases > lib/aliases_sysaix.gperf 3> canonical.sh 4> canonical_local.sh
+ ./genaliases lib/aliases_sysaix.gperf canonical.sh canonical_local.sh
$(RM) genaliases
$(GPERF) -m 10 lib/aliases_sysaix.gperf > tmp.h
$(CP) tmp.h lib/aliases_sysaix.h
@@ -124,7 +124,7 @@ lib/aliases_sysaix.h lib/canonical_sysaix.h lib/canonical_local_sysaix.h : lib/e
lib/aliases_syshpux.h lib/canonical_syshpux.h lib/canonical_local_syshpux.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
$(CC) $(CFLAGS) -DUSE_HPUX_ALIASES lib/genaliases.c -o genaliases
- ./genaliases > lib/aliases_syshpux.gperf 3> canonical.sh 4> canonical_local.sh
+ ./genaliases lib/aliases_syshpux.gperf canonical.sh canonical_local.sh
$(RM) genaliases
$(GPERF) -m 10 lib/aliases_syshpux.gperf > tmp.h
$(CP) tmp.h lib/aliases_syshpux.h
@@ -134,7 +134,7 @@ lib/aliases_syshpux.h lib/canonical_syshpux.h lib/canonical_local_syshpux.h : li
lib/aliases_sysosf1.h lib/canonical_sysosf1.h lib/canonical_local_sysosf1.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
$(CC) $(CFLAGS) -DUSE_OSF1_ALIASES lib/genaliases.c -o genaliases
- ./genaliases > lib/aliases_sysosf1.gperf 3> canonical.sh 4> canonical_local.sh
+ ./genaliases lib/aliases_sysosf1.gperf canonical.sh canonical_local.sh
$(RM) genaliases
$(GPERF) -m 10 lib/aliases_sysosf1.gperf > tmp.h
$(CP) tmp.h lib/aliases_sysosf1.h
@@ -144,7 +144,7 @@ lib/aliases_sysosf1.h lib/canonical_sysosf1.h lib/canonical_local_sysosf1.h : li
lib/aliases_syssolaris.h lib/canonical_syssolaris.h lib/canonical_local_syssolaris.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c
$(CC) $(CFLAGS) -DUSE_SOLARIS_ALIASES lib/genaliases.c -o genaliases
- ./genaliases > lib/aliases_syssolaris.gperf 3> canonical.sh 4> canonical_local.sh
+ ./genaliases lib/aliases_syssolaris.gperf canonical.sh canonical_local.sh
$(RM) genaliases
$(GPERF) -m 10 lib/aliases_syssolaris.gperf > tmp.h
$(CP) tmp.h lib/aliases_syssolaris.h
diff --git a/lib/genaliases.c b/lib/genaliases.c
index d37137c..0efdbb0 100644
--- a/lib/genaliases.c
+++ b/lib/genaliases.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2001, 2003, 2005, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2001, 2003, 2005, 2008, 2012 Free Software Foundation, Inc.
This file is part of the GNU LIBICONV Library.
The GNU LIBICONV Library is free software; you can redistribute it
@@ -55,49 +55,72 @@ static void emit_encoding (FILE* out1, FILE* out2, const char* const* names, siz
emit_alias(out1, *names, c_name);
}
-int main ()
+int main (int argc, char* argv[])
{
- FILE* stdout2;
-
- printf("struct alias { int name; unsigned int encoding_index; };\n");
- printf("%%struct-type\n");
- printf("%%language=ANSI-C\n");
- printf("%%define hash-function-name aliases_hash\n");
- printf("%%define lookup-function-name aliases_lookup\n");
- printf("%%7bit\n");
- printf("%%readonly-tables\n");
- printf("%%global-table\n");
- printf("%%define word-array-name aliases\n");
- printf("%%pic\n");
- printf("%%%%\n");
+ char* aliases_file_name;
+ char* canonical_sh_file_name;
+ char* canonical_local_sh_file_name;
+ FILE* aliases_file;
+ FILE* canonical_sh_file;
+
+ if (argc != 4) {
+ fprintf(stderr, "Usage: genaliases aliases.gperf canonical.sh canonical_local.sh\n");
+ exit(1);
+ }
+
+ aliases_file_name = argv[1];
+ canonical_sh_file_name = argv[2];
+ canonical_local_sh_file_name = argv[3];
+
+ aliases_file = fopen(aliases_file_name, "w");
+ if (aliases_file == NULL) {
+ fprintf(stderr, "Could not open '%s' for writing\n", aliases_file_name);
+ exit(1);
+ }
+
+ fprintf(aliases_file, "struct alias { int name; unsigned int encoding_index; };\n");
+ fprintf(aliases_file, "%%struct-type\n");
+ fprintf(aliases_file, "%%language=ANSI-C\n");
+ fprintf(aliases_file, "%%define hash-function-name aliases_hash\n");
+ fprintf(aliases_file, "%%define lookup-function-name aliases_lookup\n");
+ fprintf(aliases_file, "%%7bit\n");
+ fprintf(aliases_file, "%%readonly-tables\n");
+ fprintf(aliases_file, "%%global-table\n");
+ fprintf(aliases_file, "%%define word-array-name aliases\n");
+ fprintf(aliases_file, "%%pic\n");
+ fprintf(aliases_file, "%%%%\n");
#define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
{ \
static const char* const names[] = BRACIFY xxx_names; \
- emit_encoding(stdout,stdout2,names,sizeof(names)/sizeof(names[0]),#xxx); \
+ emit_encoding(aliases_file,canonical_sh_file,names,sizeof(names)/sizeof(names[0]),#xxx); \
}
#define BRACIFY(...) { __VA_ARGS__ }
-#define DEFALIAS(xxx_alias,xxx) emit_alias(stdout,xxx_alias,#xxx);
+#define DEFALIAS(xxx_alias,xxx) emit_alias(aliases_file,xxx_alias,#xxx);
- stdout2 = fdopen(3, "w");
- if (stdout2 == NULL)
+ canonical_sh_file = fopen(canonical_sh_file_name, "w");
+ if (canonical_sh_file == NULL) {
+ fprintf(stderr, "Could not open '%s' for writing\n", canonical_sh_file_name);
exit(1);
+ }
#include "encodings.def"
- if (fclose(stdout2))
+ if (ferror(canonical_sh_file) || fclose(canonical_sh_file))
exit(1);
- stdout2 = fdopen(4, "w");
- if (stdout2 == NULL)
+ canonical_sh_file = fopen(canonical_local_sh_file_name, "w");
+ if (canonical_sh_file == NULL) {
+ fprintf(stderr, "Could not open '%s' for writing\n", canonical_local_sh_file_name);
exit(1);
+ }
#include "encodings_local.def"
- if (fclose(stdout2))
+ if (ferror(canonical_sh_file) || fclose(canonical_sh_file))
exit(1);
#undef DEFALIAS
#undef BRACIFY
#undef DEFENCODING
- if (ferror(stdout) || fclose(stdout))
+ if (ferror(aliases_file) || fclose(aliases_file))
exit(1);
exit(0);
}