| author | |
| committer | |
| log | ac2930332104cf1d1f51edca922b502ef3bd3f89 |
| tree | 06ffbc7c3921a3c6d14cb83fde246620b67075ae |
| parent | bf7ebfa67af78da3ad40869cc61aecb594f9fc74 |
| parent | e72f1d5ae70b78046c27d0b7fc12ee4b69380b2a |
| signature |
std.Build.Step.ConfigHeader (cmake): fix offset calculation for multiple substitutions on a single line3 files changed, 110 insertions(+), 6 deletions(-)
lib/std/Build/Step/ConfigHeader.zig+4-4| ... | @@ -537,7 +537,7 @@ fn replace_variables( | ... | @@ -537,7 +537,7 @@ fn replace_variables( |
| 537 | switch (value) { | 537 | switch (value) { |
| 538 | .boolean => |b| { | 538 | .boolean => |b| { |
| 539 | const buf = try std.fmt.allocPrint(allocator, "{s}{}{s}", .{ beginline, @intFromBool(b), endline }); | 539 | const buf = try std.fmt.allocPrint(allocator, "{s}{}{s}", .{ beginline, @intFromBool(b), endline }); |
| 540 | last_index = start_index + 1; | 540 | last_index = prefix_index + 1; |
| 541 | 541 | ||
| 542 | allocator.free(content_buf); | 542 | allocator.free(content_buf); |
| 543 | content_buf = buf; | 543 | content_buf = buf; |
| ... | @@ -546,14 +546,14 @@ fn replace_variables( | ... | @@ -546,14 +546,14 @@ fn replace_variables( |
| 546 | const buf = try std.fmt.allocPrint(allocator, "{s}{}{s}", .{ beginline, i, endline }); | 546 | const buf = try std.fmt.allocPrint(allocator, "{s}{}{s}", .{ beginline, i, endline }); |
| 547 | const isNegative = i < 0; | 547 | const isNegative = i < 0; |
| 548 | const digits = (if (0 < i) std.math.log10(@abs(i)) else 0) + 1; | 548 | const digits = (if (0 < i) std.math.log10(@abs(i)) else 0) + 1; |
| 549 | last_index = start_index + @intFromBool(isNegative) + digits + 1; | 549 | last_index = prefix_index + @intFromBool(isNegative) + digits; |
| 550 | 550 | ||
| 551 | allocator.free(content_buf); | 551 | allocator.free(content_buf); |
| 552 | content_buf = buf; | 552 | content_buf = buf; |
| 553 | }, | 553 | }, |
| 554 | .string, .ident => |x| { | 554 | .string, .ident => |x| { |
| 555 | const buf = try std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ beginline, x, endline }); | 555 | const buf = try std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ beginline, x, endline }); |
| 556 | last_index = start_index + x.len + 1; | 556 | last_index = prefix_index + x.len; |
| 557 | 557 | ||
| 558 | allocator.free(content_buf); | 558 | allocator.free(content_buf); |
| 559 | content_buf = buf; | 559 | content_buf = buf; |
| ... | @@ -561,7 +561,7 @@ fn replace_variables( | ... | @@ -561,7 +561,7 @@ fn replace_variables( |
| 561 | 561 | ||
| 562 | else => { | 562 | else => { |
| 563 | const buf = try std.fmt.allocPrint(allocator, "{s}{s}", .{ beginline, endline }); | 563 | const buf = try std.fmt.allocPrint(allocator, "{s}{s}", .{ beginline, endline }); |
| 564 | last_index = start_index + 1; | 564 | last_index = prefix_index; |
| 565 | 565 | ||
| 566 | allocator.free(content_buf); | 566 | allocator.free(content_buf); |
| 567 | content_buf = buf; | 567 | content_buf = buf; |
test/standalone/cmakedefine/config.h.cmake+53-1| ... | @@ -49,12 +49,24 @@ | ... | @@ -49,12 +49,24 @@ |
| 49 | // no substition | 49 | // no substition |
| 50 | // @noval@ | 50 | // @noval@ |
| 51 | 51 | ||
| 52 | // no substition | ||
| 53 | // @noval@@noval@ | ||
| 54 | |||
| 55 | // no substition | ||
| 56 | // @noval@.@noval@ | ||
| 57 | |||
| 52 | // 1 | 58 | // 1 |
| 53 | // @trueval@ | 59 | // @trueval@ |
| 54 | 60 | ||
| 55 | // 0 | 61 | // 0 |
| 56 | // @falseval@ | 62 | // @falseval@ |
| 57 | 63 | ||
| 64 | // 10 | ||
| 65 | // @trueval@@falseval@ | ||
| 66 | |||
| 67 | // 0.1 | ||
| 68 | // @falseval@.@trueval@ | ||
| 69 | |||
| 58 | // 0 | 70 | // 0 |
| 59 | // @zeroval@ | 71 | // @zeroval@ |
| 60 | 72 | ||
| ... | @@ -64,21 +76,47 @@ | ... | @@ -64,21 +76,47 @@ |
| 64 | // 10 | 76 | // 10 |
| 65 | // @tenval@ | 77 | // @tenval@ |
| 66 | 78 | ||
| 79 | // 01 | ||
| 80 | // @zeroval@@oneval@ | ||
| 81 | |||
| 82 | // 0.10 | ||
| 83 | // @zeroval@.@tenval@ | ||
| 84 | |||
| 67 | // test | 85 | // test |
| 68 | // @stringval@ | 86 | // @stringval@ |
| 69 | 87 | ||
| 88 | // testtest | ||
| 89 | // @stringval@@stringval@ | ||
| 90 | |||
| 91 | // test.test | ||
| 92 | // @stringval@.@stringval@ | ||
| 93 | |||
| 94 | // test10 | ||
| 95 | // @noval@@stringval@@trueval@@zeroval@ | ||
| 70 | 96 | ||
| 71 | // ${} substition | 97 | // ${} substition |
| 72 | 98 | ||
| 73 | // removal | 99 | // no substition |
| 74 | // ${noval} | 100 | // ${noval} |
| 75 | 101 | ||
| 102 | // no substition | ||
| 103 | // ${noval}${noval} | ||
| 104 | |||
| 105 | // no substition | ||
| 106 | // ${noval}.${noval} | ||
| 107 | |||
| 76 | // 1 | 108 | // 1 |
| 77 | // ${trueval} | 109 | // ${trueval} |
| 78 | 110 | ||
| 79 | // 0 | 111 | // 0 |
| 80 | // ${falseval} | 112 | // ${falseval} |
| 81 | 113 | ||
| 114 | // 10 | ||
| 115 | // ${trueval}${falseval} | ||
| 116 | |||
| 117 | // 0.1 | ||
| 118 | // ${falseval}.${trueval} | ||
| 119 | |||
| 82 | // 0 | 120 | // 0 |
| 83 | // ${zeroval} | 121 | // ${zeroval} |
| 84 | 122 | ||
| ... | @@ -88,6 +126,20 @@ | ... | @@ -88,6 +126,20 @@ |
| 88 | // 10 | 126 | // 10 |
| 89 | // ${tenval} | 127 | // ${tenval} |
| 90 | 128 | ||
| 129 | // 01 | ||
| 130 | // ${zeroval}${oneval} | ||
| 131 | |||
| 132 | // 0.10 | ||
| 133 | // ${zeroval}.${tenval} | ||
| 134 | |||
| 91 | // test | 135 | // test |
| 92 | // ${stringval} | 136 | // ${stringval} |
| 93 | 137 | ||
| 138 | // testtest | ||
| 139 | // ${stringval}${stringval} | ||
| 140 | |||
| 141 | // test.test | ||
| 142 | // ${stringval}.${stringval} | ||
| 143 | |||
| 144 | // test10 | ||
| 145 | // ${noval}${stringval}${trueval}${zeroval} |
test/standalone/cmakedefine/expected.h+53-1| ... | @@ -49,12 +49,24 @@ | ... | @@ -49,12 +49,24 @@ |
| 49 | // no substition | 49 | // no substition |
| 50 | // | 50 | // |
| 51 | 51 | ||
| 52 | // no substition | ||
| 53 | // | ||
| 54 | |||
| 55 | // no substition | ||
| 56 | // . | ||
| 57 | |||
| 52 | // 1 | 58 | // 1 |
| 53 | // 1 | 59 | // 1 |
| 54 | 60 | ||
| 55 | // 0 | 61 | // 0 |
| 56 | // 0 | 62 | // 0 |
| 57 | 63 | ||
| 64 | // 10 | ||
| 65 | // 10 | ||
| 66 | |||
| 67 | // 0.1 | ||
| 68 | // 0.1 | ||
| 69 | |||
| 58 | // 0 | 70 | // 0 |
| 59 | // 0 | 71 | // 0 |
| 60 | 72 | ||
| ... | @@ -64,21 +76,47 @@ | ... | @@ -64,21 +76,47 @@ |
| 64 | // 10 | 76 | // 10 |
| 65 | // 10 | 77 | // 10 |
| 66 | 78 | ||
| 79 | // 01 | ||
| 80 | // 01 | ||
| 81 | |||
| 82 | // 0.10 | ||
| 83 | // 0.10 | ||
| 84 | |||
| 67 | // test | 85 | // test |
| 68 | // test | 86 | // test |
| 69 | 87 | ||
| 88 | // testtest | ||
| 89 | // testtest | ||
| 90 | |||
| 91 | // test.test | ||
| 92 | // test.test | ||
| 93 | |||
| 94 | // test10 | ||
| 95 | // test10 | ||
| 70 | 96 | ||
| 71 | // substition | 97 | // substition |
| 72 | 98 | ||
| 73 | // removal | 99 | // no substition |
| 74 | // | 100 | // |
| 75 | 101 | ||
| 102 | // no substition | ||
| 103 | // | ||
| 104 | |||
| 105 | // no substition | ||
| 106 | // . | ||
| 107 | |||
| 76 | // 1 | 108 | // 1 |
| 77 | // 1 | 109 | // 1 |
| 78 | 110 | ||
| 79 | // 0 | 111 | // 0 |
| 80 | // 0 | 112 | // 0 |
| 81 | 113 | ||
| 114 | // 10 | ||
| 115 | // 10 | ||
| 116 | |||
| 117 | // 0.1 | ||
| 118 | // 0.1 | ||
| 119 | |||
| 82 | // 0 | 120 | // 0 |
| 83 | // 0 | 121 | // 0 |
| 84 | 122 | ||
| ... | @@ -88,6 +126,20 @@ | ... | @@ -88,6 +126,20 @@ |
| 88 | // 10 | 126 | // 10 |
| 89 | // 10 | 127 | // 10 |
| 90 | 128 | ||
| 129 | // 01 | ||
| 130 | // 01 | ||
| 131 | |||
| 132 | // 0.10 | ||
| 133 | // 0.10 | ||
| 134 | |||
| 91 | // test | 135 | // test |
| 92 | // test | 136 | // test |
| 93 | 137 | ||
| 138 | // testtest | ||
| 139 | // testtest | ||
| 140 | |||
| 141 | // test.test | ||
| 142 | // test.test | ||
| 143 | |||
| 144 | // test10 | ||
| 145 | // test10 |