From f376a8013e9a6c81250712da72064f2356764999 Mon Sep 17 00:00:00 2001 From: David Welch Date: Fri, 4 Jan 2002 03:12:13 +0000 Subject: [PATCH] Fixes so wmc compiled on non-windows platforms svn path=/trunk/; revision=2482 --- reactos/tools/wmc/makefile | 21 +++++----- reactos/tools/wmc/misc.c | 77 +++++++++++++++++++++++++++++++++++++ reactos/tools/wmc/windows.h | 3 ++ reactos/tools/wmc/wmc.h | 2 + 4 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 reactos/tools/wmc/misc.c create mode 100644 reactos/tools/wmc/windows.h diff --git a/reactos/tools/wmc/makefile b/reactos/tools/wmc/makefile index f43b9e127ec..5de3fa87959 100644 --- a/reactos/tools/wmc/makefile +++ b/reactos/tools/wmc/makefile @@ -7,35 +7,38 @@ TARGET=wmc$(EXE_POSTFIX) all: $(TARGET) -OBJECTS = getopt.o lang.o mcl.o utils.o wmc.o write.o y_tab.o +OBJECTS = getopt.o lang.o mcl.o utils.o wmc.o write.o y_tab.o misc.o CLEAN_FILES = *.o wmc$(EXE_POSTFIX) wmc$(EXE_POSTFIX): $(OBJECTS) - $(HOST_CC) $(OBJECTS) -o wmc$(EXE_POSTFIX) + $(HOST_CC) $(OBJECTS) -g -o wmc$(EXE_POSTFIX) HOST_CFLAGS = -I. getopt.o: getopt.c - $(HOST_CC) $(HOST_CFLAGS) -c getopt.c -o getopt.o + $(HOST_CC) $(HOST_CFLAGS) -g -c getopt.c -o getopt.o lang.o: lang.c - $(HOST_CC) $(HOST_CFLAGS) -c lang.c -o lang.o + $(HOST_CC) $(HOST_CFLAGS) -g -c lang.c -o lang.o + +misc.o: misc.c + $(HOST_CC) $(HOST_CFLAGS) -g -c misc.c -o misc.o mcl.o: mcl.c - $(HOST_CC) $(HOST_CFLAGS) -c mcl.c -o mcl.o + $(HOST_CC) $(HOST_CFLAGS) -g -c mcl.c -o mcl.o utils.o: utils.c - $(HOST_CC) $(HOST_CFLAGS) -c utils.c -o utils.o + $(HOST_CC) $(HOST_CFLAGS) -g -c utils.c -o utils.o wmc.o: wmc.c - $(HOST_CC) $(HOST_CFLAGS) -c wmc.c -o wmc.o + $(HOST_CC) $(HOST_CFLAGS) -g -c wmc.c -o wmc.o write.o: write.c - $(HOST_CC) $(HOST_CFLAGS) -c write.c -o write.o + $(HOST_CC) $(HOST_CFLAGS) -g -c write.c -o write.o y_tab.o: y_tab.c - $(HOST_CC) $(HOST_CFLAGS) -c y_tab.c -o y_tab.o + $(HOST_CC) $(HOST_CFLAGS) -g -c y_tab.c -o y_tab.o ifeq ($(HOST),mingw32-linux) clean: diff --git a/reactos/tools/wmc/misc.c b/reactos/tools/wmc/misc.c new file mode 100644 index 00000000000..885c69d801f --- /dev/null +++ b/reactos/tools/wmc/misc.c @@ -0,0 +1,77 @@ +#ifdef __unix__ +#include +#include +#include + +typedef unsigned short UINT; +typedef unsigned int DWORD; +typedef const unsigned char* LPCSTR; +typedef wchar_t* LPWSTR; +typedef unsigned char* LPSTR; +typedef const wchar_t* LPCWSTR; +typedef unsigned int* LPBOOL; + +int +stricmp(const char* s1, const char* s2) +{ + return(strcasecmp(s1, s2)); +} + +int +WideCharToMultiByte( + UINT CodePage, + DWORD dwFlags, + LPCWSTR lpWideCharStr, + int cchWideChar, + LPSTR lpMultiByteStr, + int cchMultiByte, + LPCSTR lpDefaultChar, + LPBOOL lpUsedDefaultChar) +{ + unsigned int i = 0; + if (cchWideChar == -1) + { + while(*lpWideCharStr != 0) + { + wctomb(lpMultiByteStr, *lpWideCharStr); + lpMultiByteStr++; + lpWideCharStr++; + i++; + } + } + else + { + while(i < cchWideChar) + { + wctomb(lpMultiByteStr, *lpWideCharStr); + lpMultiByteStr++; + lpWideCharStr++; + i++; + } + } + return(i); +} + +int +MultiByteToWideChar( + UINT CodePage, + DWORD dwFlags, + LPCSTR lpMultiByteStr, + int cchMultiByte, + LPWSTR lpWideCharStr, + int cchWideChar) +{ + int i, j; + + i = j = 0; + while (i < cchMultiByte && lpMultiByteStr[i] != 0) + { + i = i + mbtowc(&lpWideCharStr[j], &lpMultiByteStr[i], + cchMultiByte - i); + j++; + } + lpWideCharStr[j] = 0; + j++; + return(j); +} +#endif diff --git a/reactos/tools/wmc/windows.h b/reactos/tools/wmc/windows.h new file mode 100644 index 00000000000..1f3e094651d --- /dev/null +++ b/reactos/tools/wmc/windows.h @@ -0,0 +1,3 @@ +#include +typedef wchar_t WCHAR; +typedef unsigned short int WORD; diff --git a/reactos/tools/wmc/wmc.h b/reactos/tools/wmc/wmc.h index 5446bee8b57..9ac5ad61083 100644 --- a/reactos/tools/wmc/wmc.h +++ b/reactos/tools/wmc/wmc.h @@ -71,4 +71,6 @@ void add_token(tok_e type, const WCHAR *name, int tok, int cp, const WCHAR *alia token_t *lookup_token(const WCHAR *s); void get_tokentable(token_t **tab, int *len); +#define _alloca alloca + #endif