Changes to allow XP to work again. See comment in Makefile.MinGW regarding -DANSI_CFG.

This commit is contained in:
waltje
2017-05-31 01:22:52 -04:00
parent 044e3ba8ea
commit 287323aa3a
2 changed files with 36 additions and 19 deletions

View File

@@ -8,7 +8,7 @@
# #
# Modified Makefile for Win32 MinGW 32-bit environment. # Modified Makefile for Win32 MinGW 32-bit environment.
# #
# Version: @(#)Makefile.mingw 1.0.18 2017/05/28 # Version: @(#)Makefile.mingw 1.0.19 2017/05/30
# #
# Authors: Kotori, <oubattler@gmail.com> # Authors: Kotori, <oubattler@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com> # Fred N. van Kempen, <decwiz@yahoo.com>
@@ -30,6 +30,7 @@ endif
# Add feature selections here. # Add feature selections here.
# -DBUGGER adds the ISA BusBugger emulation. # -DBUGGER adds the ISA BusBugger emulation.
# -DANSI_CFG forces the config file to ANSI encoding.
ifndef EXTRAS ifndef EXTRAS
EXTRAS = EXTRAS =
endif endif

View File

@@ -1,6 +1,10 @@
/* Copyright holders: Sarah Walker /* Copyright holders: Sarah Walker
see COPYING for more details * see COPYING for more details
*/ *
* NOTE: Forcing config files to be in Unicode encoding breaks it on
* Windows XP, and possibly also Vista. Use -DANSI_CFG for use
* on these systems.
*/
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
@@ -136,24 +140,26 @@ static char ename[256];
void config_load(wchar_t *fn) void config_load(wchar_t *fn)
{ {
int c; section_t *current_section;
section_t *new_section; section_t *new_section;
entry_t *new_entry; entry_t *new_entry;
FILE *f;
int c;
int sd = 0, ed = 0, data_pos; int sd = 0, ed = 0, data_pos;
FILE *f = _wfopen(fn, L"rt, ccs=UNICODE"); #ifdef ANSI_CFG
section_t *current_section; f = _wfopen(fn, L"rt");
#else
memset(&config_head, 0, sizeof(list_t)); f = _wfopen(fn, L"rt, ccs=UNICODE");
#endif
current_section = malloc(sizeof(section_t));
memset(current_section, 0, sizeof(section_t));
list_add(&current_section->list, &config_head);
if (!f) if (!f)
return; return;
current_section = malloc(sizeof(section_t));
memset(current_section, 0x00, sizeof(section_t));
memset(&config_head, 0x00, sizeof(list_t));
list_add(&current_section->list, &config_head);
while (1) while (1)
{ {
memset(cfgbuffer, 0, 2048); memset(cfgbuffer, 0, 2048);
@@ -229,7 +235,11 @@ void config_load(wchar_t *fn)
void config_new(void) void config_new(void)
{ {
#ifdef ANSI_CFG
FILE *f = _wfopen(config_file, L"wt");
#else
FILE *f = _wfopen(config_file, L"wt, ccs=UNICODE"); FILE *f = _wfopen(config_file, L"wt, ccs=UNICODE");
#endif
fclose(f); fclose(f);
} }
@@ -692,13 +702,19 @@ static wchar_t wname[512];
void config_save(wchar_t *fn) void config_save(wchar_t *fn)
{ {
FILE *f = _wfopen(fn, L"wt, ccs=UNICODE");
section_t *current_section; section_t *current_section;
FILE *f;
int fl = 0; int fl = 0;
current_section = (section_t *)config_head.next; #ifdef ANSI_CFG
f = _wfopen(fn, L"wt");
#else
f = _wfopen(fn, L"wt, ccs=UNICODE");
#endif
if (f == NULL)
return;
current_section = (section_t *)config_head.next;
while (current_section) while (current_section)
{ {
entry_t *current_entry; entry_t *current_entry;
@@ -746,9 +762,9 @@ void config_save(wchar_t *fn)
} }
static wchar_t *read_nvr_path; static wchar_t *read_nvr_path;
/* General */ /* General */
static void loadconfig_general(void) static void loadconfig_general(void)
{ {