Skip to content

Commit

Permalink
goyacc: fix unstable sorted yyXLAT output
Browse files Browse the repository at this point in the history
When two strings have the same lowercase value, break-even by comparing
case-sensitively.
  • Loading branch information
kennytm committed Nov 3, 2018
1 parent 7ec62ab commit 50457f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 9 additions & 1 deletion goyacc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,15 @@ func (s symsUsed) Less(i, j int) bool {
return false
}

return strings.ToLower(s[i].sym.Name) < strings.ToLower(s[j].sym.Name)
caseFoldedCompare := strings.Compare(strings.ToLower(s[i].sym.Name), strings.ToLower(s[j].sym.Name))
if caseFoldedCompare < 0 {
return true
}
if caseFoldedCompare > 0 {
return false
}

return s[i].sym.Name < s[j].sym.Name
}

func main1(in string) (err error) {
Expand Down
14 changes: 7 additions & 7 deletions parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 50457f2

Please sign in to comment.