summaryrefslogtreecommitdiff
path: root/src/mongo/gotools/common/json/hex.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/gotools/common/json/hex.go')
-rw-r--r--src/mongo/gotools/common/json/hex.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/gotools/common/json/hex.go b/src/mongo/gotools/common/json/hex.go
new file mode 100644
index 00000000000..625dcab6493
--- /dev/null
+++ b/src/mongo/gotools/common/json/hex.go
@@ -0,0 +1,13 @@
+package json
+
+// Transition function for recognizing hexadecimal numbers.
+// Adapted from encoding/json/scanner.go.
+
+// stateHex is the state after reading `0x` or `0X`.
+func stateHex(s *scanner, c int) int {
+ if '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' {
+ s.step = stateHex
+ return scanContinue
+ }
+ return stateEndValue(s, c)
+}