File tree 3 files changed +13
-5
lines changed
3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ pub fn main() !void {
109
109
defer file .close ();
110
110
var contents = try file .reader ().readAllAlloc (arena , 100 * 1024 * 1024 );
111
111
112
- // filter out comments
112
+ // filter out comments (both /**/ and // styles)
113
113
var i : usize = 0 ;
114
114
var k : usize = 0 ;
115
115
var in_comment = false ;
@@ -126,6 +126,14 @@ pub fn main() !void {
126
126
i += 2 ;
127
127
continue ;
128
128
}
129
+
130
+ if (! in_comment and std .mem .eql (u8 , contents [i .. ][0.. 2], "//" )) {
131
+ // skip until we get to a newline
132
+ while (contents [i ] != '\n ' ) {
133
+ i += 1 ;
134
+ }
135
+ continue ;
136
+ }
129
137
}
130
138
131
139
if (! in_comment ) {
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ pub fn main() !void {
134
134
break ;
135
135
} else {
136
136
const vline = versionstack .pop ();
137
- try outwriter .print ("#endif /*{s}*/\n " , .{vline });
137
+ try outwriter .print ("#endif /*_ZIG_UH_| {s}*/\n " , .{vline });
138
138
}
139
139
}
140
140
@@ -158,7 +158,7 @@ pub fn main() !void {
158
158
first_v = false ;
159
159
try outwriter .print ("defined {s}" , .{version });
160
160
}
161
- try outwriter .print (" OR _ZIG_UH_TEST \n " , .{});
161
+ try outwriter .print (" OR _ZIG_UH_ \n " , .{});
162
162
163
163
try versionstack .append (versionline );
164
164
@@ -173,7 +173,7 @@ pub fn main() !void {
173
173
174
174
while (versionstack .items .len > 0 ) {
175
175
const versionline = versionstack .pop ();
176
- try outwriter .print ("#endif /*{s}*/\n " , .{versionline });
176
+ try outwriter .print ("#endif /*_ZIG_UH_| {s}*/\n " , .{versionline });
177
177
}
178
178
}
179
179
}
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ pub fn main() !void {
92
92
if (debug ) std .debug .print ("trimmed {s}\n " , .{trimmed });
93
93
if (std .mem .startsWith (u8 , trimmed , "if" )) {
94
94
if (debug ) std .debug .print ("- if\n " , .{});
95
- if (std .mem .indexOf (u8 , trimmed , "_ZIG_UH_TEST " ) != null ) {
95
+ if (std .mem .indexOf (u8 , trimmed , "_ZIG_UH_ " ) != null ) {
96
96
if (std .mem .indexOf (u8 , trimmed , versionStr ) != null ) {
97
97
try outputing .append (3 );
98
98
} else {
You can’t perform that action at this time.
0 commit comments