commit 8da2008d0055e2a6263de5ce82cce48c6299c7f0
parent b0ff37dbfb5ff45d19283c9715c4fcb0feea9321
Author: phoebos <ben@bvnf.space>
Date: Mon, 6 Jun 2022 16:43:53 +0100
explicitly use 0x0A to delimit lines and be sure to write in ASCII
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/uxndebug.c b/uxndebug.c
@@ -1,3 +1,4 @@
+#include <locale.h>
#include <stdio.h>
/*
@@ -469,15 +470,16 @@ save_debug_info(char *srcname) {
if (snprintf(debug_filename, 0x100, "%s.debug", srcname) < 0)
return 0;
- debug_file = fopen(debug_filename, "w");
+ debug_file = fopen(debug_filename, "wb");
if (debug_file == NULL)
return error(debug_filename, "Failed to open.");
+ /* Avoid writing '\n' because we can't depend on any particular representation. */
for (i = 0; i < p.length - TRIM; i++) {
if (dbg.tokens[i] == 0)
- fprintf(debug_file, "\n");
+ fprintf(debug_file, "%c", 0x0A);
else
- fprintf(debug_file, "%d\n", dbg.tokens[i]);
+ fprintf(debug_file, "%u%c", dbg.tokens[i], 0x0A);
}
fclose(debug_file);
@@ -488,6 +490,7 @@ int
main(int argc, char *argv[])
{
FILE *src, *dst;
+ setlocale(LC_ALL, "C");
if(argc < 3)
return !error("usage", "input.tal output.rom");
if(!(src = fopen(argv[1], "r")))