X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/charset/blobdiff_plain/c6d25d8d73da77087aa3e413af2ae72f6300891f..387b57a52c3104263042fc8365e1603bbfe51c13:/sbcsgen.pl diff --git a/sbcsgen.pl b/sbcsgen.pl index 02aaa0f..d5b83a8 100644 --- a/sbcsgen.pl +++ b/sbcsgen.pl @@ -7,6 +7,8 @@ $infile = "sbcs.dat"; $infile = shift @ARGV if defined $ARGV[0]; $outfile = "sbcsdat.c"; $outfile = shift @ARGV if defined $ARGV[0]; +$outheader = "sbcsdat.h"; +$outheader = shift @ARGV if defined $ARGV[0]; open FOO, $infile; open BAR, ">$outfile"; @@ -65,11 +67,37 @@ foreach $i (@charsetnames) { print "\n"; print "#endif /* ENUM_CHARSETS */\n"; +close BAR; + +open BAR, ">$outheader"; +select BAR; + +print "/*\n"; +print " * sbcsdat.h - header file for SBCS data structures.\n"; +print " *\n"; +print " * Generated by sbcsgen.pl from sbcs.dat.\n"; +print " * You should edit those files rather than editing this one.\n"; +print " */\n"; +print "\n"; +print "#ifndef charset_sbcsdat_h\n"; +print "#define charset_sbcsdat_h\n"; +print "\n"; +print "#include \"charset.h\"\n"; +print "#include \"internal.h\"\n"; +print "\n"; +foreach $i (@charsetnames) { + print "extern const sbcs_data sbcsdata_$i;\n"; +} +print "\n"; +print "#endif /* charset_sbcsdat_h */\n"; + +close BAR; + sub outcharset($$$) { my ($name, $vals, $sortpriority) = @_; my ($prefix, $i, @sorted); - print "static const sbcs_data data_$name = {\n"; + print "const sbcs_data sbcsdata_$name = {\n"; print " {\n"; $prefix = " "; @sorted = (); @@ -107,5 +135,5 @@ sub outcharset($$$) { printf "\n },\n %d\n", $j; print "};\n"; print "const charset_spec charset_$name = {\n" . - " $name, read_sbcs, write_sbcs, &data_$name\n};\n\n"; + " $name, read_sbcs, write_sbcs, &sbcsdata_$name\n};\n\n"; }