diff options
author | H. Peter Anvin <hpa@zytor.com> | 2006-09-07 21:40:34 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2006-09-07 21:40:34 -0700 |
commit | 7c7fbc81a1f34bb068007a159eec715f5bf3b30f (patch) | |
tree | 0bf31beb12f85b2012bc9878e5ce80b63641f007 | |
parent | 32db11c1dbcb3f9ce65d7a841d743dc8c91e6971 (diff) | |
download | libucd-7c7fbc81a1f34bb068007a159eec715f5bf3b30f.tar.gz |
Include both the long and short tags when creating enumerations.libucd-0.2.1-5.0.0
-rw-r--r-- | CHANGES | 6 | ||||
-rwxr-xr-x | makeenums.pl | 25 |
2 files changed, 23 insertions, 8 deletions
@@ -1,3 +1,9 @@ +Changes in version 0.2.1-5.0.0: + +- The C standard permits an enumeration to have tags with duplicate + value (ISO/IEC 9899:1999 (E) 6.7.2.2.3), so when there are both long + and short forms of the same name, include both in the header file. + Changes in version 0.2-5.0.0: - Updated UCD to version 5.0.0 from the Unicode Consortium. diff --git a/makeenums.pl b/makeenums.pl index c803d18..24fcd41 100755 --- a/makeenums.pl +++ b/makeenums.pl @@ -68,6 +68,8 @@ while( defined($line = <LIST>) ) { open(FRAG, '>', "enums/${longname}.c") or die; print FRAG "#include \"libucd_int.h\"\n"; print FRAG "static const struct libucd_enum_names enum_names[] = {\n"; + + $seqpos = 0; } elsif ( $line =~ /\;/ ) { $line =~ s/\s*\#.*$//; # Remove comments @list = split(/\s*;\s*/, $line); @@ -83,16 +85,23 @@ while( defined($line = <LIST>) ) { # Write ucd.h + # $na is the preferred name, $nx the alternate ($na = $list[$whichname]) =~ tr/-/_/; - $nx = $list[1-$whichname]; - $nx = ($nx eq 'n/a') ? '' : "/* $nx */"; + ($nx = $list[1-$whichname]) =~ tr/-/_/; - if ( defined($epos) ) { - printf UCD_H " %-30s = %3d, %s\n", - "UC_\U${shortname}\E_${na}", $epos, $nx; - } else { - printf UCD_H " %-40s %s\n", - "UC_\U${shortname}\E_${na},", $nx; + # If the Unicode Consortium defines a numeric value, + # use that, otherwise use the sequential order in enum.list. + # For that reason, enum.list should be maintained manually + # and entries may only be added to the end of lists. + + $epos = defined($epos) ? $epos : $seqpos; + $seqpos++; + + printf UCD_H " %s = %d,\n", + "UC_\U${shortname}\E_${na}", $epos; + if ($nx ne 'n/a' && $nx ne $na && $nx) { + printf UCD_H " %s = %d,\n", + "UC_\U${shortname}\E_${nx}", $epos; } # Write generator fragment |