From 2fed5f0ad806869139d0e0b1ffc30c517e6baf20 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 9 Nov 2020 19:49:04 +0900 Subject: lib/racc/statetransitiontable.rb: Make the racc output stable Racc calls `Array#sort!` to build a state transition table. As `Array#sort!` is not a stable sort, the output may differ depending upon the environment. This changeset makes the sort stable manually, and updates all expectation files. --- lib/racc/statetransitiontable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/racc') diff --git a/lib/racc/statetransitiontable.rb b/lib/racc/statetransitiontable.rb index 5d1288ca58..78b6da9086 100644 --- a/lib/racc/statetransitiontable.rb +++ b/lib/racc/statetransitiontable.rb @@ -231,7 +231,7 @@ module Racc map = '-' * 10240 # sort long to short - entries.sort! {|a,b| b[0].size <=> a[0].size } + entries.sort_by!.with_index {|a,i| [-a[0].size, i] } entries.each do |arr, chkval, expr, min, ptri| if upper + arr.size > map.size -- cgit v1.2.1