Return "" for rune < 0 in strconv.

This commit is contained in:
Jeroen van Rijn
2024-09-08 00:32:46 +02:00
parent 1ab0745ca8
commit 300b01d77d
+10 -10
View File
@@ -7,8 +7,8 @@ Parses a boolean value from the input string
**Inputs** **Inputs**
- s: The input string - s: The input string
- true: "1", "t", "T", "true", "TRUE", "True" - true: "1", "t", "T", "true", "TRUE", "True"
- false: "0", "f", "F", "false", "FALSE", "False" - false: "0", "f", "F", "false", "FALSE", "False"
- n: An optional pointer to an int to store the length of the parsed substring (default: nil) - n: An optional pointer to an int to store the length of the parsed substring (default: nil)
**Returns** **Returns**
@@ -203,7 +203,7 @@ Parses an unsigned 64-bit integer value from the input string without a prefix,
**Inputs** **Inputs**
- str: The input string to parse - str: The input string to parse
- base: The base of the number system to use for parsing - base: The base of the number system to use for parsing
- Must be between 1 and 16 (inclusive) - Must be between 1 and 16 (inclusive)
- n: An optional pointer to an int to store the length of the parsed substring (default: nil) - n: An optional pointer to an int to store the length of the parsed substring (default: nil)
Example: Example:
@@ -264,8 +264,8 @@ Parses an unsigned 64-bit integer value from the input string, using the specifi
**Inputs** **Inputs**
- str: The input string to parse - str: The input string to parse
- base: The base of the number system to use for parsing (default: 0) - base: The base of the number system to use for parsing (default: 0)
- If base is 0, it will be inferred based on the prefix in the input string (e.g. '0x' for hexadecimal) - If base is 0, it will be inferred based on the prefix in the input string (e.g. '0x' for hexadecimal)
- If base is not 0, it will be used for parsing regardless of any prefix in the input string - If base is not 0, it will be used for parsing regardless of any prefix in the input string
- n: An optional pointer to an int to store the length of the parsed substring (default: nil) - n: An optional pointer to an int to store the length of the parsed substring (default: nil)
Example: Example:
@@ -339,8 +339,8 @@ Parses a signed integer value from the input string, using the specified base or
**Inputs** **Inputs**
- s: The input string to parse - s: The input string to parse
- base: The base of the number system to use for parsing (default: 0) - base: The base of the number system to use for parsing (default: 0)
- If base is 0, it will be inferred based on the prefix in the input string (e.g. '0x' for hexadecimal) - If base is 0, it will be inferred based on the prefix in the input string (e.g. '0x' for hexadecimal)
- If base is not 0, it will be used for parsing regardless of any prefix in the input string - If base is not 0, it will be used for parsing regardless of any prefix in the input string
Example: Example:
@@ -382,8 +382,8 @@ Parses an unsigned integer value from the input string, using the specified base
**Inputs** **Inputs**
- s: The input string to parse - s: The input string to parse
- base: The base of the number system to use for parsing (default: 0, inferred) - base: The base of the number system to use for parsing (default: 0, inferred)
- If base is 0, it will be inferred based on the prefix in the input string (e.g. '0x' for hexadecimal) - If base is 0, it will be inferred based on the prefix in the input string (e.g. '0x' for hexadecimal)
- If base is not 0, it will be used for parsing regardless of any prefix in the input string - If base is not 0, it will be used for parsing regardless of any prefix in the input string
Example: Example:
@@ -1729,7 +1729,7 @@ quote_rune :: proc(buf: []byte, r: rune) -> string {
} }
} }
if buf == nil { if buf == nil || r < 0 {
return "" return ""
} }