| ... | ... | @@ -5602,16 +5602,18 @@ fn parseCNumLit(c: *Context, m: *MacroCtx) ParseError!Node { |
| 5602 | 5602 | }, |
| 5603 | 5603 | .FloatLiteral => |suffix| { |
| 5604 | 5604 | if (suffix != .none) lit_bytes = lit_bytes[0 .. lit_bytes.len - 1]; |
| 5605 | | const dot_index = mem.indexOfScalar(u8, lit_bytes, '.').?; |
| 5606 | | if (dot_index == 0) { |
| 5607 | | lit_bytes = try std.fmt.allocPrint(c.arena, "0{s}", .{lit_bytes}); |
| 5608 | | } else if (dot_index + 1 == lit_bytes.len or !std.ascii.isDigit(lit_bytes[dot_index + 1])) { |
| 5609 | | // If the literal lacks a digit after the `.`, we need to |
| 5610 | | // add one since `1.` or `1.e10` would be invalid syntax in Zig. |
| 5611 | | lit_bytes = try std.fmt.allocPrint(c.arena, "{s}0{s}", .{ |
| 5612 | | lit_bytes[0 .. dot_index + 1], |
| 5613 | | lit_bytes[dot_index + 1 ..], |
| 5614 | | }); |
| 5605 | |
| 5606 | if (mem.indexOfScalar(u8, lit_bytes, '.')) |dot_index| { |
| 5607 | if (dot_index == 0) { |
| 5608 | lit_bytes = try std.fmt.allocPrint(c.arena, "0{s}", .{lit_bytes}); |
| 5609 | } else if (dot_index + 1 == lit_bytes.len or !std.ascii.isDigit(lit_bytes[dot_index + 1])) { |
| 5610 | // If the literal lacks a digit after the `.`, we need to |
| 5611 | // add one since `1.` or `1.e10` would be invalid syntax in Zig. |
| 5612 | lit_bytes = try std.fmt.allocPrint(c.arena, "{s}0{s}", .{ |
| 5613 | lit_bytes[0 .. dot_index + 1], |
| 5614 | lit_bytes[dot_index + 1 ..], |
| 5615 | }); |
| 5616 | } |
| 5615 | 5617 | } |
| 5616 | 5618 | |
| 5617 | 5619 | if (suffix == .none) |