| 1 |
Explicitely sort the elements (tags, attributes) in the generated files |
| 2 |
|
| 3 |
Otherwise, the diff easily become untractable from one run to the other. |
| 4 |
More generally, this also participate to the Reproducible effort. |
| 5 |
|
| 6 |
--- |
| 7 |
flexml.pl | 56 +++++++++++++++++------------------ |
| 8 |
testbed/missing-att.stderr.expected | 2 - |
| 9 |
testbed/multiple-att.stderr.expected | 2 - |
| 10 |
3 files changed, 30 insertions(+), 30 deletions(-) |
| 11 |
|
| 12 |
Index: b/flexml.pl |
| 13 |
=================================================================== |
| 14 |
--- a/flexml.pl |
| 15 |
+++ b/flexml.pl |
| 16 |
@@ -227,7 +227,7 @@ EOT |
| 17 |
sub api_functions { # Print XML application interface functions. |
| 18 |
my ($pre,$post) = @_; |
| 19 |
print "/* XML application entry points. */\n" if @tags; |
| 20 |
- for (@tags) { |
| 21 |
+ for (sort @tags) { |
| 22 |
print $pre . "void STag_${tagprefix}$ctag{$_}(void)$post\n" unless $startok{$_}; |
| 23 |
print $pre . "void ETag_${tagprefix}$ctag{$_}(void)$post\n" unless $endok{$_}; |
| 24 |
} |
| 25 |
@@ -236,7 +236,7 @@ sub api_functions { # Print XML applicat |
| 26 |
|
| 27 |
sub api_types { # Print XML application interface types. |
| 28 |
print "/* XML application data. */\n" if %atttype; |
| 29 |
- for (keys %atttype) { |
| 30 |
+ for (sort keys %atttype) { |
| 31 |
if (m.($Nmtoken)[/]($Nmtoken).xo) { |
| 32 |
my ($tag,$attribute) = ($1,$2); |
| 33 |
print "typedef $typeof{$_} AT_${tagprefix}$ctag{$tag}_$catt{$attribute};\n"; |
| 34 |
@@ -254,7 +254,7 @@ sub api_data { # Print XML application i |
| 35 |
print "extern char *${tagprefix}bufferstack;\n"; |
| 36 |
print "#define ${tagprefix}pcdata (${tagprefix}bufferstack + ${tagprefix}pcdata_ix)\n"; |
| 37 |
|
| 38 |
- for (keys %atttype) { |
| 39 |
+ for (sort keys %atttype) { |
| 40 |
if (m.($Nmtoken)[/]($Nmtoken).xo) { |
| 41 |
print $pre . "AT_${tagprefix}$ctag{$1}_$catt{$2} AX_${tagprefix}$ctag{$1}_$catt{$2};\n"; |
| 42 |
print "#define A_${tagprefix}$ctag{$1}_$catt{$2} "; |
| 43 |
@@ -1004,7 +1004,7 @@ print STDOUT "Post-processing DTD.\n" if |
| 44 |
} |
| 45 |
|
| 46 |
# Complete all states with their `empty' equivalents. |
| 47 |
-for my $tag (@tags) { |
| 48 |
+for my $tag (sort @tags) { |
| 49 |
|
| 50 |
# Complete and prune instates and endstates... |
| 51 |
my %ins = (); |
| 52 |
@@ -1035,13 +1035,13 @@ for my $tag (@tags) { |
| 53 |
} |
| 54 |
|
| 55 |
# Completion done...now store'em right back. |
| 56 |
- $instates{$tag} = join ',', keys %ins if %ins; |
| 57 |
- $endstates{$tag} = join ',', keys %ens if %ens; |
| 58 |
- $exittrans{$tag} = join ',', map "$_=>$exits{$_}", keys %exits if %exits; |
| 59 |
+ $instates{$tag} = join ',', sort keys %ins if %ins; |
| 60 |
+ $endstates{$tag} = join ',', sort keys %ens if %ens; |
| 61 |
+ $exittrans{$tag} = join ',', map "$_=>$exits{$_}", sort keys %exits if %exits; |
| 62 |
} |
| 63 |
|
| 64 |
if (not %roottags) { |
| 65 |
- for (@tags) { $roottags{$_} = 'true'; } |
| 66 |
+ for (sort @tags) { $roottags{$_} = 'true'; } |
| 67 |
} |
| 68 |
|
| 69 |
# Handling prefix |
| 70 |
@@ -1118,7 +1118,7 @@ if ($debug) { |
| 71 |
print '%source = (' . printhash(\%source) . ")\n"; |
| 72 |
print "\n"; |
| 73 |
|
| 74 |
- print '@tags = (' . join(',',@tags) . ")\n"; |
| 75 |
+ print '@tags = (' . join(',',sort @tags) . ")\n"; |
| 76 |
print '%ctag = (' . printhash(\%ctag) . ")\n"; |
| 77 |
|
| 78 |
print '%states = (' . printhash(\%states) . ")\n"; |
| 79 |
@@ -1288,7 +1288,7 @@ if ($scanner or $standalone) { |
| 80 |
} |
| 81 |
elsif ( /^FLEXML_START_CONDITIONS$/ ) { |
| 82 |
|
| 83 |
- for (@tags) { |
| 84 |
+ for (sort @tags) { |
| 85 |
my $c = $ctag{$_}; |
| 86 |
print "%x" |
| 87 |
. ($roottags{$_} ? " ROOT_${tagprefix}$c" : "") |
| 88 |
@@ -1317,7 +1317,7 @@ if ($scanner or $standalone) { |
| 89 |
for ('PROLOG','DOCTYPE','EPILOG','INCOMMENT','INPI','VALUE1','VALUE2','CDATA') { |
| 90 |
print " ${tagprefix}statenames[$_] = NULL;\n"; |
| 91 |
} |
| 92 |
- for my $tag (@tags) { |
| 93 |
+ for my $tag (sort @tags) { |
| 94 |
my $c = $ctag{$tag}; |
| 95 |
print " ${tagprefix}statenames[ROOT_${tagprefix}$c] = NULL;\n" if $roottags{$tag}; |
| 96 |
print " ${tagprefix}statenames[AL_${tagprefix}$c] = NULL;\n"; |
| 97 |
@@ -1333,7 +1333,7 @@ if ($scanner or $standalone) { |
| 98 |
: ( $uri ? "(\"'$uri'\"|\"\\\"$uri\\\"\")" |
| 99 |
: "(\"'$dtd'\"|\"\\\"$dtd\\\"\")" ); |
| 100 |
|
| 101 |
- for (keys %roottags) { |
| 102 |
+ for (sort keys %roottags) { |
| 103 |
my $c = $ctag{$_}; |
| 104 |
print " \"<!DOCTYPE\"{S}\"$_\"{S}" |
| 105 |
. "SYSTEM{S}" . $sysid . "{s}\">\" SET(ROOT_${tagprefix}$c);\n"; |
| 106 |
@@ -1348,10 +1348,10 @@ if ($scanner or $standalone) { |
| 107 |
elsif ( /^FLEXML_RULES$/ ) { |
| 108 |
|
| 109 |
# Dump all parameter entity declarations. |
| 110 |
- for (keys %parameter) { printsource($_); } |
| 111 |
+ for (sort keys %parameter) { printsource($_); } |
| 112 |
|
| 113 |
# Dump all start and empty tag recognition rules. |
| 114 |
- for my $tag (@tags) { |
| 115 |
+ for my $tag (sort @tags) { |
| 116 |
|
| 117 |
my $myctag = $ctag{$tag}; |
| 118 |
my @myattributes = (exists $attlist{$tag} ? split /,/,"$attlist{$tag}" : ()); |
| 119 |
@@ -1359,7 +1359,7 @@ if ($scanner or $standalone) { |
| 120 |
|
| 121 |
# Tag's source element and attribute declarations. |
| 122 |
printsource($tag); |
| 123 |
- for my $attribute (@myattributes) { |
| 124 |
+ for my $attribute (sort @myattributes) { |
| 125 |
printsource("$tag/$attribute"); |
| 126 |
} |
| 127 |
|
| 128 |
@@ -1368,12 +1368,12 @@ if ($scanner or $standalone) { |
| 129 |
if (exists $exittrans{$tag}) { |
| 130 |
$exitswitch .= " switch (YY_START) {\n"; |
| 131 |
my %casesto = (); |
| 132 |
- for (split /,/,$exittrans{$tag}) { |
| 133 |
+ for (sort split /,/,$exittrans{$tag}) { |
| 134 |
if (m/^($Name)=>($Name)$/o) { |
| 135 |
$casesto{$2} .= "case $1: "; |
| 136 |
} |
| 137 |
} |
| 138 |
- for (keys %casesto) { |
| 139 |
+ for (sort keys %casesto) { |
| 140 |
$exitswitch .= " $casesto{$_}SET($_); break;\n" |
| 141 |
} |
| 142 |
$exitswitch .= " }\n"; |
| 143 |
@@ -1389,7 +1389,7 @@ if ($scanner or $standalone) { |
| 144 |
if (exists $instates{$tag}) { |
| 145 |
for (split /,/,$instates{$tag}) { $ins{$_} = 'true'; } |
| 146 |
} |
| 147 |
- my $str = '<' . join(',', grep {$ins{$_} eq 'false'} keys %ins); |
| 148 |
+ my $str = '<' . join(',', grep {$ins{$_} eq 'false'} sort keys %ins); |
| 149 |
if ($str ne '<') { |
| 150 |
print "$str>\"<$tag\"{s} FAIL(\"Starting tag <$tag> is not allowed here.\");\n"; |
| 151 |
} |
| 152 |
@@ -1409,7 +1409,7 @@ if ($scanner or $standalone) { |
| 153 |
# "\"<$tag\"{s} {\n"; |
| 154 |
print ">\"<$tag\"{s} {\n"; |
| 155 |
|
| 156 |
- for my $attribute (@myattributes) { |
| 157 |
+ for my $attribute (sort @myattributes) { |
| 158 |
print " AX_${tagprefix}${myctag}_$catt{$attribute} = " . $initof{"$tag/$attribute"} . ";\n"; |
| 159 |
print " ${tagprefix}${myctag}_$catt{$attribute}_isset = 0;\n"; |
| 160 |
} |
| 161 |
@@ -1425,7 +1425,7 @@ if ($scanner or $standalone) { |
| 162 |
print "\n"; |
| 163 |
print "<AL_${tagprefix}$myctag>{\n"; |
| 164 |
|
| 165 |
- for my $attribute (@myattributes) { |
| 166 |
+ for my $attribute (sort @myattributes) { |
| 167 |
my $type; # set by conditions |
| 168 |
|
| 169 |
if ($type = $enumtype{"$tag/$attribute"}) { |
| 170 |
@@ -1481,7 +1481,7 @@ if ($scanner or $standalone) { |
| 171 |
# - the end of a start tag means to enter the contents after |
| 172 |
# checking that all required attributes were set. |
| 173 |
print " \">\" {\n"; |
| 174 |
- for my $attribute (@myattributes) { |
| 175 |
+ for my $attribute (sort @myattributes) { |
| 176 |
if ($required{"$tag/$attribute"}) { |
| 177 |
print " if (!AX_${tagprefix}$ctag{$tag}_" . variablify($attribute) . ")" |
| 178 |
. " FAIL(\"Required attribute `$attribute' not set for `$tag' element.\");\n"; |
| 179 |
@@ -1496,7 +1496,7 @@ if ($scanner or $standalone) { |
| 180 |
# - accept and handle empty tags straight away, |
| 181 |
if ($empty{$tag}) { |
| 182 |
print " \"/>\" {\n"; |
| 183 |
- for my $attribute (@myattributes) { |
| 184 |
+ for my $attribute (sort @myattributes) { |
| 185 |
if ($required{"$tag/$attribute"}) { |
| 186 |
print " if (!AX_${tagprefix}$ctag{$tag}_" . variablify($attribute) . ")" |
| 187 |
. " FAIL(\"Required attribute `$attribute' not set for `$tag' element.\");\n"; |
| 188 |
@@ -1559,7 +1559,7 @@ if ($scanner or $standalone) { |
| 189 |
elsif ( /FLEXML_MIXED([,>])/ ) { |
| 190 |
|
| 191 |
if (%mixed) { |
| 192 |
- print "$`" . join(',', map("IN_$ctag{$_}", keys %mixed)) . "$1$'"; |
| 193 |
+ print "$`" . join(',', map("IN_$ctag{$_}", sort keys %mixed)) . "$1$'"; |
| 194 |
} |
| 195 |
else { |
| 196 |
print "$`IMPOSSIBLE$1$'"; |
| 197 |
@@ -1569,7 +1569,7 @@ if ($scanner or $standalone) { |
| 198 |
elsif ( /FLEXML_NON_MIXED([,>])/ ) { |
| 199 |
|
| 200 |
my $sep = $`; |
| 201 |
- for (@tags) { |
| 202 |
+ for (sort @tags) { |
| 203 |
print $sep . ($roottags{$_} ? "ROOT_${tagprefix}$ctag{$_}," : "") |
| 204 |
. "AL_${tagprefix}$ctag{$_}"; |
| 205 |
print ",$states{$_}" if $properempty{$_} or $children{$_}; |
| 206 |
@@ -1582,14 +1582,14 @@ if ($scanner or $standalone) { |
| 207 |
|
| 208 |
print "$`" |
| 209 |
. join(',', map(($roottags{$_} ? "ROOT_${tagprefix}$ctag{$_}," : "") |
| 210 |
- . "AL_${tagprefix}$ctag{$_},$states{$_}", @tags)) |
| 211 |
+ . "AL_${tagprefix}$ctag{$_},$states{$_}", sort @tags)) |
| 212 |
. "$1$'"; |
| 213 |
|
| 214 |
} |
| 215 |
elsif ( /^FLEXML_ENTITIES$/ ) { |
| 216 |
|
| 217 |
# Process general entities. |
| 218 |
- for my $ent (keys %entity) { |
| 219 |
+ for my $ent (sort keys %entity) { |
| 220 |
printsource("%$ent;"); |
| 221 |
print " \"&$ent;\" ENTITYTEXT(\"" . $entity{$ent} . "\");\n"; |
| 222 |
} |
| 223 |
@@ -1605,8 +1605,8 @@ if ($scanner or $standalone) { |
| 224 |
elsif ( /^FLEXML_FINAL$/ and not $nofail ) { |
| 225 |
|
| 226 |
# Catch-all error cases. |
| 227 |
- for my $tag (@tags) { |
| 228 |
- for (split ',',$states{$tag}) { |
| 229 |
+ for my $tag (sort @tags) { |
| 230 |
+ for (sort split ',',$states{$tag}) { |
| 231 |
print "<$_>{\n"; |
| 232 |
print " . FAIL(\"Unrecognized `%c' in $_.\",yytext[0]);\n"; |
| 233 |
print " [\\n] FAIL(\"Unrecognized newline in $_.\");\n"; |
| 234 |
Index: b/testbed/missing-att.stderr.expected |
| 235 |
=================================================================== |
| 236 |
--- a/testbed/missing-att.stderr.expected |
| 237 |
+++ b/testbed/missing-att.stderr.expected |
| 238 |
@@ -1 +1 @@ |
| 239 |
-Invalid XML (state 13): Required attribute `batt' not set for `bar' element. |
| 240 |
+Invalid XML (state 10): Required attribute `batt' not set for `bar' element. |
| 241 |
Index: b/testbed/multiple-att.stderr.expected |
| 242 |
=================================================================== |
| 243 |
--- a/testbed/multiple-att.stderr.expected |
| 244 |
+++ b/testbed/multiple-att.stderr.expected |
| 245 |
@@ -1 +1 @@ |
| 246 |
-Invalid XML (state 13): Multiple definition of attribute batt in <bar> |
| 247 |
+Invalid XML (state 10): Multiple definition of attribute batt in <bar> |