@@ -159,7 +159,7 @@ pub fn cgen(files []ast.File, table &table.Table, pref &pref.Preferences) string
159
159
//
160
160
g.finish ()
161
161
//
162
-
162
+
163
163
b := strings.new_builder (250000 )
164
164
b.writeln (g.hashes ())
165
165
b.writeln (g.comptime_defines.str ())
@@ -3162,7 +3162,7 @@ fn (mut g Gen) gen_str_for_array(info table.Array, styp, str_fn_name string) {
3162
3162
} else {
3163
3163
g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, ${field_styp} _str(it));' )
3164
3164
}
3165
- g.auto_str_funcs.writeln ('\t\t if (i != a.len-1) {' )
3165
+ g.auto_str_funcs.writeln ('\t\t if (i < a.len-1) {' )
3166
3166
g.auto_str_funcs.writeln ('\t\t\t strings__Builder_write(&sb, tos3(", "));' )
3167
3167
g.auto_str_funcs.writeln ('\t\t }' )
3168
3168
g.auto_str_funcs.writeln ('\t }' )
@@ -3187,11 +3187,11 @@ fn (mut g Gen) gen_str_for_array_fixed(info table.ArrayFixed, styp, str_fn_name
3187
3187
} else if sym.kind in [.f32 , .f64 ] {
3188
3188
g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, _STR("%g ", a[i]));' )
3189
3189
} else if sym.kind == .string {
3190
- g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, _STR("\\ " %.*s\\ " ", a[i].len, a[i].str));' )
3190
+ g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, _STR("\' %.*s\' ", a[i].len, a[i].str));' )
3191
3191
} else {
3192
3192
g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, ${field_styp} _str(a[i]));' )
3193
3193
}
3194
- g.auto_str_funcs.writeln ('\t\t if (i != $ info.size -1) {' )
3194
+ g.auto_str_funcs.writeln ('\t\t if (i < ${ info.size-1} ) {' )
3195
3195
g.auto_str_funcs.writeln ('\t\t\t strings__Builder_write(&sb, tos3(", "));' )
3196
3196
g.auto_str_funcs.writeln ('\t\t }' )
3197
3197
g.auto_str_funcs.writeln ('\t }' )
@@ -3218,14 +3218,14 @@ fn (mut g Gen) gen_str_for_map(info table.Map, styp, str_fn_name string) {
3218
3218
g.auto_str_funcs.writeln ('\t strings__Builder_write(&sb, tos3("{"));' )
3219
3219
g.auto_str_funcs.writeln ('\t for (unsigned int i = 0; i < m.key_values.size; i++) {' )
3220
3220
g.auto_str_funcs.writeln ('\t\t string key = (*(string*)DenseArray_get(m.key_values, i));' )
3221
- g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, _STR("\\ " %.*s\\ " ", key.len, key.str));' )
3221
+ g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, _STR("\' %.*s\' ", key.len, key.str));' )
3222
3222
g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, tos3(": "));' )
3223
3223
g.auto_str_funcs.write ('\t $val_styp it = (*($val_styp *)map_get3(' )
3224
3224
g.auto_str_funcs.write ('m, (*(string*)DenseArray_get(m.key_values, i))' )
3225
3225
g.auto_str_funcs.write (', ' )
3226
3226
g.auto_str_funcs.writeln (' &($val_styp []) { $zero }));' )
3227
3227
if val_sym.kind == .string {
3228
- g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, _STR("\\ " %.*s\\ " ", it.len, it.str));' )
3228
+ g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, _STR("\' %.*s\' ", it.len, it.str));' )
3229
3229
} else if val_sym.kind == .struct_ && ! val_sym.has_method ('str' ) {
3230
3230
g.auto_str_funcs.writeln ('\t\t strings__Builder_write(&sb, ${val_styp} _str(it,0));' )
3231
3231
} else if val_sym.kind in [.f32 , .f64 ] {
0 commit comments