mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Show a warning instead of crashing with 'String too big into StringsBuffer' when loading options.txt/fontscache.txt
Also fix makefile again
This commit is contained in:
parent
303f951587
commit
5495faa800
92
src/Makefile
92
src/Makefile
@ -4,6 +4,9 @@ COMMITSHA=$(shell git rev-parse --short HEAD)
|
|||||||
ENAME=ClassiCube
|
ENAME=ClassiCube
|
||||||
DEL=rm
|
DEL=rm
|
||||||
JOBS=1
|
JOBS=1
|
||||||
|
CC=gcc
|
||||||
|
CFLAGS=-w -g -pipe -rdynamic
|
||||||
|
LDFLAGS=-g -rdynamic
|
||||||
|
|
||||||
ifndef $(PLAT)
|
ifndef $(PLAT)
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
@ -13,48 +16,51 @@ ifndef $(PLAT)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC_web=emcc
|
ifeq ($(PLAT),web)
|
||||||
OEXT_web=.html
|
CC=emcc
|
||||||
CFLAGS_web=-w -g
|
OEXT=.html
|
||||||
LDFLAGS_web=-s WASM=1 -s NO_EXIT_RUNTIME=1 -s FETCH=1 --preload-file texpacks/default.zip@texpacks/default.zip
|
CFLAGS=-w -g
|
||||||
|
LDFLAGS=-s WASM=1 -s NO_EXIT_RUNTIME=1 -s FETCH=1 --preload-file texpacks/default.zip@texpacks/default.zip
|
||||||
|
endif
|
||||||
|
|
||||||
CC_mingw=gcc
|
ifeq ($(PLAT),mingw)
|
||||||
LIBS_mingw=-mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9
|
OEXT=.exe
|
||||||
OEXT_mingw=.exe
|
CFLAGS=-w -g -pipe
|
||||||
CFLAGS_mingw=-w -g -pipe
|
LDFLAGS=-g
|
||||||
|
LIBS=-mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9
|
||||||
|
endif
|
||||||
|
|
||||||
CC_linux=gcc
|
ifeq ($(PLAT),linux)
|
||||||
LIBS_linux=-lX11 -lpthread -lGL -lm -lopenal -ldl -lcurl
|
LIBS=-lX11 -lpthread -lGL -lm -lopenal -ldl -lcurl
|
||||||
CFLAGS_linux=-w -g -pipe -rdynamic
|
endif
|
||||||
|
|
||||||
CC_sunos=gcc
|
ifeq ($(PLAT),sunos)
|
||||||
LIBS_sunos=-lm -lsocket -lX11 -lGL -lcurl -lopenal
|
LIBS=-lm -lsocket -lX11 -lGL -lcurl -lopenal
|
||||||
CFLAGS_sunos=-w -g -pipe -rdynamic
|
endif
|
||||||
|
|
||||||
CC_darwin=gcc
|
ifeq ($(PLAT),darwin)
|
||||||
LIBS_darwin=-lcurl
|
LIBS=-lcurl
|
||||||
LDFLAGS_darwin=-framework Carbon -framework AGL -framework OpenAL -framework OpenGL
|
LDFLAGS=-rdynamic -framework Carbon -framework AGL -framework OpenAL -framework OpenGL
|
||||||
CFLAGS_darwin=-w -g -pipe -rdynamic
|
endif
|
||||||
|
|
||||||
BSDLIBS=-lcurl -lexecinfo -lopenal -lGL -lX11
|
ifeq ($(PLAT),freebsd)
|
||||||
|
CC=clang
|
||||||
|
CFLAGS=-w -g -pipe -rdynamic -I /usr/local/include
|
||||||
|
LDFLAGS=-L /usr/local/lib
|
||||||
|
LIBS=-lcurl -lexecinfo -lopenal -lGL -lX11 -lm -lpthread
|
||||||
|
endif
|
||||||
|
|
||||||
CC_freebsd=clang
|
ifeq ($(PLAT),openbsd)
|
||||||
LIBS_freebsd=$(BSDLIBS) -lm -lpthread
|
CFLAGS=-w -g -pipe -rdynamic -I /usr/X11R6/include -I /usr/local/include
|
||||||
INCDIRS_freebsd=-I /usr/local/include
|
LDFLAGS=-L /usr/X11R6/lib -L /usr/local/lib
|
||||||
LDFLAGS_freebsd=-L /usr/local/lib
|
LIBS=-lcurl -lexecinfo -lopenal -lGL -lX11
|
||||||
CFLAGS_freebsd=-w -g -pipe -rdynamic
|
endif
|
||||||
|
|
||||||
CC_openbsd=gcc
|
ifeq ($(PLAT),netbsd)
|
||||||
LIBS_openbsd=$(BSDLIBS)
|
CFLAGS=-w -g -pipe -rdynamic -I /usr/X11R7/include -I /usr/pkg/include
|
||||||
INCDIRS_openbsd=-isystem /usr/X11R6/include -isystem /usr/local/include
|
LDFLAGS=-L /usr/X11R7/lib -L /usr/pkg/lib
|
||||||
LDFLAGS_openbsd=-L /usr/X11R6/lib -L /usr/local/lib
|
LIBS=-lcurl -lexecinfo -lopenal -lGL -lX11
|
||||||
CFLAGS_openbsd=-w -g -pipe -rdynamic
|
endif
|
||||||
|
|
||||||
CC_netbsd=gcc
|
|
||||||
LIBS_netbsd=$(BSDLIBS)
|
|
||||||
INCDIRS_netbsd=-I /usr/X11R7/include -I /usr/pkg/include
|
|
||||||
LDFLAGS_netbsd=-L /usr/X11R7/lib -L /usr/pkg/lib
|
|
||||||
CFLAGS_netbsd=-w -g -pipe -rdynamic
|
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
DEL=del
|
DEL=del
|
||||||
@ -64,40 +70,26 @@ default: $(PLAT)
|
|||||||
|
|
||||||
web:
|
web:
|
||||||
$(MAKE) $(ENAME) PLAT=web -j$(JOBS)
|
$(MAKE) $(ENAME) PLAT=web -j$(JOBS)
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
$(MAKE) $(ENAME) PLAT=linux -j$(JOBS)
|
$(MAKE) $(ENAME) PLAT=linux -j$(JOBS)
|
||||||
|
|
||||||
mingw:
|
mingw:
|
||||||
$(MAKE) $(ENAME) PLAT=mingw -j$(JOBS)
|
$(MAKE) $(ENAME) PLAT=mingw -j$(JOBS)
|
||||||
|
|
||||||
solaris:
|
solaris:
|
||||||
$(MAKE) $(ENAME) PLAT=sunos -j$(JOBS)
|
$(MAKE) $(ENAME) PLAT=sunos -j$(JOBS)
|
||||||
|
|
||||||
osx:
|
osx:
|
||||||
$(MAKE) $(ENAME) PLAT=darwin -j$(JOBS)
|
$(MAKE) $(ENAME) PLAT=darwin -j$(JOBS)
|
||||||
|
|
||||||
freebsd:
|
freebsd:
|
||||||
$(MAKE) $(ENAME) PLAT=freebsd -j$(JOBS)
|
$(MAKE) $(ENAME) PLAT=freebsd -j$(JOBS)
|
||||||
|
|
||||||
openbsd:
|
openbsd:
|
||||||
$(MAKE) $(ENAME) PLAT=openbsd -j$(JOBS)
|
$(MAKE) $(ENAME) PLAT=openbsd -j$(JOBS)
|
||||||
|
|
||||||
netbsd:
|
netbsd:
|
||||||
$(MAKE) $(ENAME) PLAT=netbsd -j$(JOBS)
|
$(MAKE) $(ENAME) PLAT=netbsd -j$(JOBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(DEL) $(OBJECTS)
|
$(DEL) $(OBJECTS)
|
||||||
|
|
||||||
CC=$(CC_$(PLAT))
|
|
||||||
LIBS=$(LIBS_$(PLAT))
|
|
||||||
OEXT=$(OEXT_$(PLAT))
|
|
||||||
CFLAGS=$(CFLAGS_$(PLAT))
|
|
||||||
LDFLAGS=$(LDFLAGS_$(PLAT))
|
|
||||||
INCDIRS=$(INCDIRS_$(PLAT))
|
|
||||||
|
|
||||||
$(ENAME): $(OBJECTS)
|
$(ENAME): $(OBJECTS)
|
||||||
$(CC) $(LDFLAGS) -o $@$(OEXT) $(OBJECTS) $(LIBS)
|
$(CC) $(LDFLAGS) -o $@$(OEXT) $(OBJECTS) $(LIBS)
|
||||||
|
|
||||||
$(OBJECTS): %.o : %.c
|
$(OBJECTS): %.o : %.c
|
||||||
$(CC) $(CFLAGS) $(INCDIRS) -DCC_COMMIT_SHA=\"$(COMMITSHA)\" -c $< -o $@
|
$(CC) $(CFLAGS) -DCC_COMMIT_SHA=\"$(COMMITSHA)\" -c $< -o $@
|
||||||
|
@ -752,8 +752,6 @@ bool Convert_ParseBool(const String* str, bool* value) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------StringsBuffer------------------------------------------------------*
|
*------------------------------------------------------StringsBuffer------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
#define STRINGSBUFFER_LEN_SHIFT 9
|
|
||||||
#define STRINGSBUFFER_LEN_MASK 0x1FFUL
|
|
||||||
#define STRINGSBUFFER_BUFFER_EXPAND_SIZE 8192
|
#define STRINGSBUFFER_BUFFER_EXPAND_SIZE 8192
|
||||||
|
|
||||||
CC_NOINLINE static void StringsBuffer_Init(StringsBuffer* buffer) {
|
CC_NOINLINE static void StringsBuffer_Init(StringsBuffer* buffer) {
|
||||||
@ -791,7 +789,7 @@ String StringsBuffer_UNSAFE_Get(StringsBuffer* buffer, int i) {
|
|||||||
void StringsBuffer_Add(StringsBuffer* buffer, const String* str) {
|
void StringsBuffer_Add(StringsBuffer* buffer, const String* str) {
|
||||||
int textOffset;
|
int textOffset;
|
||||||
/* StringsBuffer hasn't been initalised yet, do it here */
|
/* StringsBuffer hasn't been initalised yet, do it here */
|
||||||
if (!buffer->_FlagsBufferSize) { StringsBuffer_Init(buffer); }
|
if (!buffer->_FlagsBufferSize) StringsBuffer_Init(buffer);
|
||||||
|
|
||||||
if (buffer->Count == buffer->_FlagsBufferSize) {
|
if (buffer->Count == buffer->_FlagsBufferSize) {
|
||||||
buffer->FlagsBuffer = Utils_Resize(buffer->FlagsBuffer, &buffer->_FlagsBufferSize,
|
buffer->FlagsBuffer = Utils_Resize(buffer->FlagsBuffer, &buffer->_FlagsBufferSize,
|
||||||
|
@ -200,6 +200,9 @@ CC_API bool Convert_ParseBool(const String* str, bool* value);
|
|||||||
|
|
||||||
#define STRINGSBUFFER_BUFFER_DEF_SIZE 4096
|
#define STRINGSBUFFER_BUFFER_DEF_SIZE 4096
|
||||||
#define STRINGSBUFFER_FLAGS_DEF_ELEMS 256
|
#define STRINGSBUFFER_FLAGS_DEF_ELEMS 256
|
||||||
|
#define STRINGSBUFFER_LEN_SHIFT 9
|
||||||
|
#define STRINGSBUFFER_LEN_MASK 0x1FFUL
|
||||||
|
|
||||||
typedef struct StringsBuffer_ {
|
typedef struct StringsBuffer_ {
|
||||||
char* TextBuffer; /* Raw characters of all entries */
|
char* TextBuffer; /* Raw characters of all entries */
|
||||||
uint32_t* FlagsBuffer; /* Private flags for each entry */
|
uint32_t* FlagsBuffer; /* Private flags for each entry */
|
||||||
|
@ -310,6 +310,14 @@ void EntryList_Load(struct EntryList* list, EntryList_Filter filter) {
|
|||||||
if (!entry.length) continue;
|
if (!entry.length) continue;
|
||||||
if (filter && !filter(&entry)) continue;
|
if (filter && !filter(&entry)) continue;
|
||||||
|
|
||||||
|
/* Sometimes file becomes corrupted and replaced with NULL */
|
||||||
|
/* If don't prevent this here, client aborts in StringsBuffer_Add */
|
||||||
|
if (entry.length > STRINGSBUFFER_LEN_MASK) {
|
||||||
|
entry.length = 0;
|
||||||
|
String_Format1(&entry, "Skipping extremely long line in %c, file may have been corrupted", list->Filename);
|
||||||
|
Logger_WarnFunc(&entry); continue;
|
||||||
|
}
|
||||||
|
|
||||||
String_UNSAFE_Separate(&entry, list->Separator, &key, &value);
|
String_UNSAFE_Separate(&entry, list->Separator, &key, &value);
|
||||||
EntryList_Set(list, &key, &value);
|
EntryList_Set(list, &key, &value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user