mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
mlr -O regexp bugfix (#767)
This commit is contained in:
parent
7642f7ede6
commit
8e975c9d39
7 changed files with 48 additions and 12 deletions
2
Makefile
2
Makefile
|
|
@ -72,4 +72,4 @@ release_tarball: build check
|
|||
./create-release-tarball
|
||||
|
||||
# Go does its own dependency management, outside of make.
|
||||
.PHONY: build check unit_test regression_test fmt dev
|
||||
.PHONY: build mlr check unit_test regression_test fmt dev
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
|
|
@ -157,23 +158,18 @@ func inferNormally(input string, inferBool bool) *Mlrval {
|
|||
return MlrvalFromString(input)
|
||||
}
|
||||
|
||||
var octalDetector = regexp.MustCompile("^-?0[0-9]+")
|
||||
|
||||
func inferWithOctalSuppress(input string, inferBool bool) *Mlrval {
|
||||
output := inferNormally(input, inferBool)
|
||||
if output.mvtype != MT_INT && output.mvtype != MT_FLOAT {
|
||||
return output
|
||||
}
|
||||
|
||||
if input[0] == '0' && len(input) > 1 {
|
||||
c := input[1]
|
||||
if c != 'x' && c != 'X' && c != 'b' && c != 'B' {
|
||||
return MlrvalFromString(input)
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(input, "-0") && len(input) > 2 {
|
||||
c := input[2]
|
||||
if c != 'x' && c != 'X' && c != 'b' && c != 'B' {
|
||||
return MlrvalFromString(input)
|
||||
}
|
||||
if octalDetector.MatchString(input) {
|
||||
return MlrvalFromString(input)
|
||||
} else {
|
||||
return output
|
||||
}
|
||||
|
||||
return output
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ x t y z
|
|||
0123 float 84 83.5
|
||||
07 float 8 7.5
|
||||
08 float 9 8.5
|
||||
0 float 1 0.5
|
||||
0. float 1 0.5
|
||||
0.0 float 1 0.5
|
||||
0.01 float 1.01 0.51
|
||||
0b0100 float 5 4.5
|
||||
0x1000 float 4097 4096.5
|
||||
-123 float -122 -122.5
|
||||
|
|
@ -13,3 +17,7 @@ x t y z
|
|||
-0x1000 float -4095 -4095.5
|
||||
-07 float -6 -6.5
|
||||
-08 float -7 -7.5
|
||||
-0 float 1 0.5
|
||||
-0. float 1 0.5
|
||||
-0.0 float 1 0.5
|
||||
-0.01 float 0.99 0.49
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ x t y z
|
|||
0123 string (error) (error)
|
||||
07 string (error) (error)
|
||||
08 string (error) (error)
|
||||
0 int 1 0.5
|
||||
0. float 1 0.5
|
||||
0.0 float 1 0.5
|
||||
0.01 float 1.01 0.51
|
||||
0b0100 int 5 4.5
|
||||
0x1000 int 4097 4096.5
|
||||
-123 int -122 -122.5
|
||||
|
|
@ -13,3 +17,7 @@ x t y z
|
|||
-0x1000 int -4095 -4095.5
|
||||
-07 string (error) (error)
|
||||
-08 string (error) (error)
|
||||
-0 int 1 0.5
|
||||
-0. float 1 0.5
|
||||
-0.0 float 1 0.5
|
||||
-0.01 float 0.99 0.49
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ x t y z
|
|||
0123 string (error) (error)
|
||||
07 string (error) (error)
|
||||
08 string (error) (error)
|
||||
0 string (error) (error)
|
||||
0. string (error) (error)
|
||||
0.0 string (error) (error)
|
||||
0.01 string (error) (error)
|
||||
0b0100 string (error) (error)
|
||||
0x1000 string (error) (error)
|
||||
-123 string (error) (error)
|
||||
|
|
@ -13,3 +17,7 @@ x t y z
|
|||
-0x1000 string (error) (error)
|
||||
-07 string (error) (error)
|
||||
-08 string (error) (error)
|
||||
-0 string (error) (error)
|
||||
-0. string (error) (error)
|
||||
-0.0 string (error) (error)
|
||||
-0.01 string (error) (error)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ x t y z
|
|||
0123 int 84 83.5
|
||||
07 int 8 7.5
|
||||
08 float 9 8.5
|
||||
0 int 1 0.5
|
||||
0. float 1 0.5
|
||||
0.0 float 1 0.5
|
||||
0.01 float 1.01 0.51
|
||||
0b0100 int 5 4.5
|
||||
0x1000 int 4097 4096.5
|
||||
-123 int -122 -122.5
|
||||
|
|
@ -13,3 +17,7 @@ x t y z
|
|||
-0x1000 int -4095 -4095.5
|
||||
-07 int -6 -6.5
|
||||
-08 float -7 -7.5
|
||||
-0 int 1 0.5
|
||||
-0. float 1 0.5
|
||||
-0.0 float 1 0.5
|
||||
-0.01 float 0.99 0.49
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ x
|
|||
0123
|
||||
07
|
||||
08
|
||||
0
|
||||
0.
|
||||
0.0
|
||||
0.01
|
||||
0b0100
|
||||
0x1000
|
||||
-123
|
||||
|
|
@ -13,3 +17,7 @@ x
|
|||
-0x1000
|
||||
-07
|
||||
-08
|
||||
-0
|
||||
-0.
|
||||
-0.0
|
||||
-0.01
|
||||
|
|
|
|||
|
Loading…
Add table
Add a link
Reference in a new issue