1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[localization] alright, using locale.h for a source was a bad idea

* MinGW is unhappy about the conflict with <locale.h>
* Also add MinGW and MSVC targets, and address MinGW warnings
This commit is contained in:
Pete Batard 2013-06-22 00:40:48 +01:00
parent 92789377db
commit 2a03582bfc
8 changed files with 30 additions and 20 deletions

View file

@ -169,7 +169,7 @@
<ClCompile Include="..\dos.c" /> <ClCompile Include="..\dos.c" />
<ClCompile Include="..\icon.c" /> <ClCompile Include="..\icon.c" />
<ClCompile Include="..\iso.c" /> <ClCompile Include="..\iso.c" />
<ClCompile Include="..\locale.c" /> <ClCompile Include="..\localization.c" />
<ClCompile Include="..\net.c" /> <ClCompile Include="..\net.c" />
<ClCompile Include="..\parser.c" /> <ClCompile Include="..\parser.c" />
<ClCompile Include="..\rufus.c" /> <ClCompile Include="..\rufus.c" />
@ -186,7 +186,7 @@
<ClInclude Include="..\libcdio\cdio\iso9660.h" /> <ClInclude Include="..\libcdio\cdio\iso9660.h" />
<ClInclude Include="..\libcdio\cdio\logging.h" /> <ClInclude Include="..\libcdio\cdio\logging.h" />
<ClInclude Include="..\libcdio\cdio\udf.h" /> <ClInclude Include="..\libcdio\cdio\udf.h" />
<ClInclude Include="..\locale.h" /> <ClInclude Include="..\localization.h" />
<ClInclude Include="..\msapi_utf8.h" /> <ClInclude Include="..\msapi_utf8.h" />
<ClInclude Include="..\dos.h" /> <ClInclude Include="..\dos.h" />
<ClInclude Include="..\registry.h" /> <ClInclude Include="..\registry.h" />

View file

@ -60,7 +60,7 @@
<ClCompile Include="..\stdfn.c"> <ClCompile Include="..\stdfn.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\locale.c"> <ClCompile Include="..\localization.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
@ -104,7 +104,7 @@
<ClInclude Include="..\registry.h"> <ClInclude Include="..\registry.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\locale.h"> <ClInclude Include="..\localization.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>

View file

@ -36,6 +36,7 @@ SOURCES=rufus.c \
stdlg.c \ stdlg.c \
icon.c \ icon.c \
parser.c \ parser.c \
localization.c \
net.c \ net.c \
iso.c \ iso.c \
dos.c \ dos.c \

View file

@ -9,7 +9,7 @@ pkg_v_rc_0 = @echo " RC $@";
%_rc.o: %.rc %_rc.o: %.rc
$(pkg_v_rc)$(WINDRES) $(AM_RCFLAGS) -i $< -o $@ $(pkg_v_rc)$(WINDRES) $(AM_RCFLAGS) -i $< -o $@
rufus_SOURCES = drive.c icon.c parser.c iso.c net.c dos.c dos_locale.c badblocks.c syslinux.c vhd.c format.c stdio.c stdfn.c stdlg.c rufus.c rufus_SOURCES = drive.c icon.c parser.c localization.c iso.c net.c dos.c dos_locale.c badblocks.c syslinux.c vhd.c format.c stdio.c stdfn.c stdlg.c rufus.c
rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./libcdio $(AM_CFLAGS) rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./libcdio $(AM_CFLAGS)
rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows
rufus_LDADD = rufus_rc.o ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \ rufus_LDADD = rufus_rc.o ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \

View file

@ -44,12 +44,13 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES = CONFIG_CLEAN_VPATH_FILES =
PROGRAMS = $(noinst_PROGRAMS) PROGRAMS = $(noinst_PROGRAMS)
am_rufus_OBJECTS = rufus-drive.$(OBJEXT) rufus-icon.$(OBJEXT) \ am_rufus_OBJECTS = rufus-drive.$(OBJEXT) rufus-icon.$(OBJEXT) \
rufus-parser.$(OBJEXT) rufus-iso.$(OBJEXT) rufus-net.$(OBJEXT) \ rufus-parser.$(OBJEXT) rufus-localization.$(OBJEXT) \
rufus-dos.$(OBJEXT) rufus-dos_locale.$(OBJEXT) \ rufus-iso.$(OBJEXT) rufus-net.$(OBJEXT) rufus-dos.$(OBJEXT) \
rufus-badblocks.$(OBJEXT) rufus-syslinux.$(OBJEXT) \ rufus-dos_locale.$(OBJEXT) rufus-badblocks.$(OBJEXT) \
rufus-vhd.$(OBJEXT) rufus-format.$(OBJEXT) \ rufus-syslinux.$(OBJEXT) rufus-vhd.$(OBJEXT) \
rufus-stdio.$(OBJEXT) rufus-stdfn.$(OBJEXT) \ rufus-format.$(OBJEXT) rufus-stdio.$(OBJEXT) \
rufus-stdlg.$(OBJEXT) rufus-rufus.$(OBJEXT) rufus-stdfn.$(OBJEXT) rufus-stdlg.$(OBJEXT) \
rufus-rufus.$(OBJEXT)
rufus_OBJECTS = $(am_rufus_OBJECTS) rufus_OBJECTS = $(am_rufus_OBJECTS)
rufus_DEPENDENCIES = rufus_rc.o ms-sys/libmssys.a \ rufus_DEPENDENCIES = rufus_rc.o ms-sys/libmssys.a \
syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \ syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \
@ -184,7 +185,7 @@ SUBDIRS = ms-sys syslinux/libfat syslinux/libinstaller libcdio/iso9660 libcdio/u
pkg_v_rc = $(pkg_v_rc_$(V)) pkg_v_rc = $(pkg_v_rc_$(V))
pkg_v_rc_ = $(pkg_v_rc_$(AM_DEFAULT_VERBOSITY)) pkg_v_rc_ = $(pkg_v_rc_$(AM_DEFAULT_VERBOSITY))
pkg_v_rc_0 = @echo " RC $@"; pkg_v_rc_0 = @echo " RC $@";
rufus_SOURCES = drive.c icon.c parser.c iso.c net.c dos.c dos_locale.c badblocks.c syslinux.c vhd.c format.c stdio.c stdfn.c stdlg.c rufus.c rufus_SOURCES = drive.c icon.c parser.c localization.c iso.c net.c dos.c dos_locale.c badblocks.c syslinux.c vhd.c format.c stdio.c stdfn.c stdlg.c rufus.c
rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./libcdio $(AM_CFLAGS) rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./libcdio $(AM_CFLAGS)
rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows
rufus_LDADD = rufus_rc.o ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \ rufus_LDADD = rufus_rc.o ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \
@ -269,6 +270,14 @@ rufus-parser.obj: parser.c
$(AM_V_CC) @AM_BACKSLASH@ $(AM_V_CC) @AM_BACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-parser.obj `if test -f 'parser.c'; then $(CYGPATH_W) 'parser.c'; else $(CYGPATH_W) '$(srcdir)/parser.c'; fi` $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-parser.obj `if test -f 'parser.c'; then $(CYGPATH_W) 'parser.c'; else $(CYGPATH_W) '$(srcdir)/parser.c'; fi`
rufus-localization.o: localization.c
$(AM_V_CC) @AM_BACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-localization.o `test -f 'localization.c' || echo '$(srcdir)/'`localization.c
rufus-localization.obj: localization.c
$(AM_V_CC) @AM_BACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-localization.obj `if test -f 'localization.c'; then $(CYGPATH_W) 'localization.c'; else $(CYGPATH_W) '$(srcdir)/localization.c'; fi`
rufus-iso.o: iso.c rufus-iso.o: iso.c
$(AM_V_CC) @AM_BACKSLASH@ $(AM_V_CC) @AM_BACKSLASH@
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-iso.o `test -f 'iso.c' || echo '$(srcdir)/'`iso.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-iso.o `test -f 'iso.c' || echo '$(srcdir)/'`iso.c

View file

@ -31,7 +31,7 @@
#include "rufus.h" #include "rufus.h"
#include "resource.h" #include "resource.h"
#include "msapi_utf8.h" #include "msapi_utf8.h"
#include "locale.h" #include "localization.h"
#define LOC_CTRL(x) { #x, x } #define LOC_CTRL(x) { #x, x }

View file

@ -33,7 +33,7 @@
#include "rufus.h" #include "rufus.h"
#include "msapi_utf8.h" #include "msapi_utf8.h"
#include "locale.h" #include "localization.h"
static const wchar_t wspace[] = L" \t"; static const wchar_t wspace[] = L" \t";
@ -74,9 +74,9 @@ static loc_cmd* get_loc_cmd(wchar_t wc, wchar_t* wline) {
} }
r = i; r = i;
// locate ending quote // locate ending quote
while ((wline[i] != 0) && (wline[i] != L'"') || ((wline[i] == L'"') && (wline[i-1] == L'\\'))) { while ((wline[i] != 0) && ((wline[i] != L'"') || ((wline[i] == L'"') && (wline[i-1] == L'\\')))) {
if ((wline[i] == L'"') && (wline[i-1] == L'\\')) { if ((wline[i] == L'"') && (wline[i-1] == L'\\')) {
wcscpy_s(&wline[i-1], i+wcslen(&wline[i]), &wline[i]); wcscpy(&wline[i-1], &wline[i]);
} else { } else {
i++; i++;
} }
@ -126,8 +126,8 @@ static void* get_loc_data_line(wchar_t* wline)
size_t i = 0; size_t i = 0;
wchar_t t; wchar_t t;
loc_cmd* lcmd = NULL; loc_cmd* lcmd = NULL;
char* locale = "en-US"; // char* locale = "en-US";
BOOL seek_locale = TRUE; // BOOL seek_locale = TRUE;
if ((wline == NULL) || (wline[0] == 0)) if ((wline == NULL) || (wline[0] == 0))
return NULL; return NULL;
@ -164,12 +164,12 @@ static __inline void *_reallocf(void *ptr, size_t size)
// Parse a Rufus localization command file (ANSI, UTF-8 or UTF-16) // Parse a Rufus localization command file (ANSI, UTF-8 or UTF-16)
char* get_loc_data_file(const char* filename) char* get_loc_data_file(const char* filename)
{ {
wchar_t *wdata= NULL, *wfilename = NULL, *wbuf = NULL; wchar_t *wfilename = NULL, *wbuf = NULL;
size_t wbufsize = 1024; // size in wchar_t size_t wbufsize = 1024; // size in wchar_t
FILE* fd = NULL; FILE* fd = NULL;
char *ret = NULL; char *ret = NULL;
size_t i = 0; size_t i = 0;
int r, line_nr_incr = 1; int r = 0, line_nr_incr = 1;
wchar_t wc = 0, last_wc; wchar_t wc = 0, last_wc;
BOOL eol = FALSE; BOOL eol = FALSE;