Silly of me to overlook it: another obvious way you might like to
[sgt/charset] / sbcsgen.pl
index d5b83a8..e2991b2 100644 (file)
@@ -35,6 +35,7 @@ my @sortpriority = ();
 
 while (<FOO>) {
     chomp;
+    y/\r\n//; # robustness in the face of strange line endings
     if (/^charset (.*)$/) {
        $charsetname = $1;
        @vals = ();
@@ -116,9 +117,10 @@ sub outcharset($$$) {
        }
     }
     print "\n    },\n    {\n";
-    @sorted = sort { $a->[1] == $b->[1] ?
-                    $b->[2] <=> $a->[2] :
-                    $a->[1] <=> $b->[1] } @sorted;
+    @sorted = sort { ($a->[1] == $b->[1] ?
+                     $b->[2] <=> $a->[2] :
+                     $a->[1] <=> $b->[1]) ||
+                     $a->[0] <=> $b->[0] } @sorted;
     $prefix = "    ";
     $uval = -1;
     for ($i = $j = 0; $i < scalar @sorted; $i++) {