From: Kevin Day Date: Thu, 14 Nov 2019 03:04:55 +0000 (-0600) Subject: Bugfix: string to number conversions should handle leading 0's as a valid number X-Git-Tag: 0.5.0~392 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=3080dcecaf1a538f60ad97a07552aedb1f6bed38;p=fll Bugfix: string to number conversions should handle leading 0's as a valid number --- diff --git a/level_0/f_conversion/c/conversion.c b/level_0/f_conversion/c/conversion.c index 6cbf5fc..ed2b7f0 100644 --- a/level_0/f_conversion/c/conversion.c +++ b/level_0/f_conversion/c/conversion.c @@ -776,12 +776,12 @@ extern "C" { if (string[i] == 0x30) { j = i + 1; - // immediate next value must be either '0', 'x', 'X', 'd', 'D', 'o', 'O', 'b', or 'B'. + // Immediate next value must be either a number, 'x', 'X', 'd', 'D', 'o', 'O', 'b', or 'B'. if (j > location.stop) { *number = 0; return f_none; } - else if (string[j] == 0x30) { + else if (string[j] > 0x29 || string[j] < 0x3a) { mode = 10; } else if (string[j] == 0x78 || string[j] == 0x58) { @@ -925,12 +925,12 @@ extern "C" { if (string[i] == 0x30) { j = i + 1; - // immediate next value must be either '0', 'x', 'X', 'd', 'D', 'o', 'O', 'b', or 'B'. + // Immediate next value must be either a number, 'x', 'X', 'd', 'D', 'o', 'O', 'b', or 'B'. if (j > location.stop) { *number = 0; return f_none; } - else if (string[j] == 0x30) { + else if (string[j] > 0x29 || string[j] < 0x3a) { mode = 10; } else if (string[j] == 0x78 || string[j] == 0x58) {