| ... | @@ -292,10 +292,27 @@ const DocData = struct { | ... | @@ -292,10 +292,27 @@ const DocData = struct { |
| 292 | if (options.whitespace) |*ws| ws.indent_level += 1; | 292 | if (options.whitespace) |*ws| ws.indent_level += 1; |
| 293 | while (it.next()) |kv| : (idx += 1) { | 293 | while (it.next()) |kv| : (idx += 1) { |
| 294 | if (options.whitespace) |ws| try ws.outputIndent(w); | 294 | if (options.whitespace) |ws| try ws.outputIndent(w); |
| 295 | try w.print("\"{s}\": {d}", .{ | 295 | const builtin = @import("builtin"); |
| 296 | kv.key_ptr.*.sub_file_path, | 296 | if (builtin.target.os.tag == .windows) { |
| 297 | kv.value_ptr.*, | 297 | try w.print("\"", .{}); |
| 298 | }); | 298 | for (kv.key_ptr.*.sub_file_path) |c| { |
| | 299 | if (c == '\\') { |
| | 300 | try w.print("\\", .{}); |
| | 301 | try w.print("\\", .{}); |
| | 302 | } else { |
| | 303 | try w.print("{c}", .{c}); |
| | 304 | } |
| | 305 | } |
| | 306 | try w.print("\"", .{}); |
| | 307 | try w.print(": {d}", .{ |
| | 308 | kv.value_ptr.*, |
| | 309 | }); |
| | 310 | } else { |
| | 311 | try w.print("\"{s}\": {d}", .{ |
| | 312 | kv.key_ptr.*.sub_file_path, |
| | 313 | kv.value_ptr.*, |
| | 314 | }); |
| | 315 | } |
| 299 | if (idx != self.data.count() - 1) try w.writeByte(','); | 316 | if (idx != self.data.count() - 1) try w.writeByte(','); |
| 300 | try w.writeByte('\n'); | 317 | try w.writeByte('\n'); |
| 301 | } | 318 | } |