diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/knarc/Makefile | 3 | ||||
-rw-r--r-- | tools/msgenc/Makefile | 3 | ||||
-rw-r--r-- | tools/msgenc/msgenc.cpp | 9 | ||||
-rw-r--r-- | tools/mwasmarm_patcher/mwasmarm_patcher.c | 6 |
4 files changed, 10 insertions, 11 deletions
diff --git a/tools/knarc/Makefile b/tools/knarc/Makefile index 1c33e9f6..7dc8bd24 100644 --- a/tools/knarc/Makefile +++ b/tools/knarc/Makefile @@ -1,7 +1,6 @@ CXXFLAGS := -std=c++17 -O2 -Wall -Wno-switch CFLAGS := -O2 -Wall -Wno-switch -WSLENV ?= no ifeq ($(OS),Windows_NT) C_SRCS := fnmatch.c LDFLAGS += -lstdc++fs @@ -11,11 +10,9 @@ UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) LDFLAGS += -lstdc++ -lc++ -lc else -ifneq ($(WSLENV),) LDFLAGS += -lstdc++fs endif endif -endif CXX_SRCS := Source.cpp Narc.cpp C_OBJS := $(C_SRCS:%.c=%.o) CXX_OBJS := $(CXX_SRCS:%.cpp=%.o) diff --git a/tools/msgenc/Makefile b/tools/msgenc/Makefile index f6ddc439..05253e8b 100644 --- a/tools/msgenc/Makefile +++ b/tools/msgenc/Makefile @@ -1,7 +1,6 @@ CXXFLAGS := -std=c++17 -O2 -Wall -Wno-switch CFLAGS := -O2 -Wall -Wno-switch -WSLENV ?= no ifeq ($(OS),Windows_NT) LDFLAGS += -lstdc++fs else @@ -9,11 +8,9 @@ UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) LDFLAGS += -lstdc++ -lc++ -lc else -ifneq ($(WSLENV),) LDFLAGS += -lstdc++fs endif endif -endif CXX_SRCS := msgenc.cpp HEADERS := diff --git a/tools/msgenc/msgenc.cpp b/tools/msgenc/msgenc.cpp index bc5e9eab..314fbce1 100644 --- a/tools/msgenc/msgenc.cpp +++ b/tools/msgenc/msgenc.cpp @@ -49,7 +49,7 @@ u16string ReadTextFileU16LE(path filename) { ss << "read error in " << filename; throw runtime_error(ss.str()); } - if (bom != u'\uFEFF') { + if (bom != u'\uFEFF' && bom != u'\uFFFE') { stringstream ss; ss << "invalid bom in " << filename; throw runtime_error(ss.str()); @@ -63,7 +63,12 @@ u16string ReadTextFileU16LE(path filename) { ss << "read error in " << filename; throw runtime_error(ss.str()); } - buf[count] = L'\0'; + if (bom == u'\uFFFE') { + for (int i = 0; i < count; i++) { + buf[i] = (buf[i] << 8) | (buf[i] >> 8); + } + } + buf[count] = u'\0'; fclose(file); return buf; } diff --git a/tools/mwasmarm_patcher/mwasmarm_patcher.c b/tools/mwasmarm_patcher/mwasmarm_patcher.c index 7d15820d..e5ad3272 100644 --- a/tools/mwasmarm_patcher/mwasmarm_patcher.c +++ b/tools/mwasmarm_patcher/mwasmarm_patcher.c @@ -80,7 +80,7 @@ unsigned char * calculate_sha1 (const void * data, unsigned length) { uint32_t state[5] = {0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0};
const char * current;
unsigned remaining;
- for (current = data, remaining = length; remaining >= 64; current += 64, remaining -= 64) sha1_process_block(current, state);
+ for (current = data, remaining = length; remaining >= 64; current += 64, remaining -= 64) sha1_process_block((const uint8_t *)current, state);
// technically only {0} is necessary, but better safe than sorry
unsigned char last_block[64] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -224,9 +224,9 @@ int main(int argc, char *argv[]) { }
free(string);
- unsigned char buf[SHA_DIGEST_LENGTH*2];
+ char buf[SHA_DIGEST_LENGTH*2];
for (int i=0; i < SHA_DIGEST_LENGTH; i++) {
- sprintf((unsigned char*)&(buf[i*2]), "%02x", sha1[i]);
+ sprintf(&(buf[i*2]), "%02x", sha1[i]);
}
free(sha1);
|