diff --git a/sim_BuildROMs.c b/sim_BuildROMs.c index 1166fb79..d2181293 100644 --- a/sim_BuildROMs.c +++ b/sim_BuildROMs.c @@ -321,7 +321,9 @@ if (0 == sim_read_ROM_include(include_filename, } } -if (NULL == (iFile = fopen (include_filename, "w"))) { +/* Open output file in binary mode for consistency with all simh + source files that have CRLF line endings with explicit writes of \r\n */ +if (NULL == (iFile = fopen (include_filename, "wb"))) { printf ("Error Opening '%s' for output: %s\n", include_filename, strerror(errno)); free (ROMData); return -1; @@ -332,29 +334,29 @@ if (load_filename) else load_filename = rom_filename; time (&now); -fprintf (iFile, "#ifndef ROM_%s_H\n", rom_array_name); -fprintf (iFile, "#define ROM_%s_H 0\n", rom_array_name); -fprintf (iFile, "/*\n"); +fprintf (iFile, "#ifndef ROM_%s_H\r\n", rom_array_name); +fprintf (iFile, "#define ROM_%s_H 0\r\n", rom_array_name); +fprintf (iFile, "/*\r\n"); fprintf (iFile, " %s produced at %s", include_filename, ctime(&now)); fprintf (iFile, " from %s which was last modified at %s", rom_filename, ctime(&statb.st_mtime)); -fprintf (iFile, " file size: %d (0x%X) - checksum: 0x%08X\n", (int)statb.st_size, (int)statb.st_size, checksum); -fprintf (iFile, " This file is a generated file and should NOT be edited or changed by hand.\n"); +fprintf (iFile, " file size: %d (0x%X) - checksum: 0x%08X\r\n", (int)statb.st_size, (int)statb.st_size, checksum); +fprintf (iFile, " This file is a generated file and should NOT be edited or changed by hand.\r\n"); if (Comments) - fprintf (iFile, "\n %s\n\n", Comments); -fprintf (iFile, "*/\n"); -fprintf (iFile, "#define BOOT_CODE_SIZE 0x%X\n", (int)statb.st_size); -fprintf (iFile, "#define BOOT_CODE_FILENAME \"%s\"\n", load_filename); -fprintf (iFile, "#define BOOT_CODE_ARRAY %s\n", rom_array_name); + fprintf (iFile, "\n %s\r\n\r\n", Comments); +fprintf (iFile, "*/\r\n"); +fprintf (iFile, "#define BOOT_CODE_SIZE 0x%X\r\n", (int)statb.st_size); +fprintf (iFile, "#define BOOT_CODE_FILENAME \"%s\"\r\n", load_filename); +fprintf (iFile, "#define BOOT_CODE_ARRAY %s\r\n", rom_array_name); fprintf (iFile, "unsigned char %s[] = {", rom_array_name); for (bytes_written=0;bytes_written