Skip to content

Commit 715a28f

Browse files
committed
Move STRING_BUFFER from string.c to CMakeLists.txt, remove -Wno-pointer-sign and fix compiler warnings
1 parent 4a6763a commit 715a28f

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ include(CPack)
77
include(CTest)
88
include(TestBigEndian)
99

10-
set(CMAKE_C_FLAGS "-Wall -Wno-pointer-sign")
10+
set(CMAKE_C_FLAGS "-Wall")
1111
set(CMAKE_CXX_STANDARD 11)
1212
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1313
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
1414
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
1515
set(CPACK_PACKAGE_NAME "libs3dat")
1616

17+
set(STRING_BUFFER 1024)
18+
1719
TEST_BIG_ENDIAN(IS_BE)
1820

1921
option(FORCE_ICONV "Force iconv even if no iconv.h is found" OFF)

config.h.in

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
#cmakedefine USE_ICONV
55
#cmakedefine IS_BE
66
#cmakedefine PRIVATE_FILENAME
7+
#cmakedefine STRING_BUFFER @STRING_BUFFER@
78

89
#endif /*S3DAT_CONFIG_H*/

src/s3dat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ s3dat_frame_t* s3dat_frame(s3dat_ref_t* ani, uint32_t frame);
185185
bool s3dat_is_string(s3dat_ref_t* str);
186186

187187
bool s3dat_utf8(s3dat_ref_t* str);
188-
uint8_t* s3dat_strdata(s3dat_ref_t* str);
188+
char* s3dat_strdata(s3dat_ref_t* str);
189189

190190
//sound
191191
bool s3dat_is_sound(s3dat_ref_t* snd);

src/s3dat_internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct s3dat_string_t {
6262

6363
bool original_encoding;
6464
s3dat_language language;
65-
uint8_t* string_data;
65+
char* string_data;
6666
};
6767

6868
struct s3dat_animation_t {

src/string.c

+12-14
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
#line __LINE__ "string.c"
44
#endif
55

6-
uint8_t* s3dat_internal_read_cstr(s3dat_t* handle, s3util_exception_t** throws) {
7-
#define STRING_BUFFER 1024
8-
9-
uint8_t* bfr = s3util_alloc_func(s3dat_memset(handle), STRING_BUFFER, throws);
6+
char* s3dat_internal_read_cstr(s3dat_t* handle, s3util_exception_t** throws) {
7+
char* bfr = s3util_alloc_func(s3dat_memset(handle), STRING_BUFFER, throws);
108
if(*throws != NULL) {
119
s3util_add_to_stack(s3dat_memset(handle), throws, __FILE__, __func__, __LINE__);
1210
return NULL;
@@ -23,7 +21,7 @@ uint8_t* s3dat_internal_read_cstr(s3dat_t* handle, s3util_exception_t** throws)
2321
}
2422

2523
if(pos+1 == bfr_size) {
26-
uint8_t* bfr2 = s3util_alloc_func(s3dat_memset(handle), bfr_size+STRING_BUFFER, throws);
24+
char* bfr2 = s3util_alloc_func(s3dat_memset(handle), bfr_size+STRING_BUFFER, throws);
2725
if(*throws != NULL) {
2826
s3util_add_to_stack(s3dat_memset(handle), throws, __FILE__, __func__, __LINE__);
2927
s3util_free_func(s3dat_memset(handle), bfr);
@@ -40,10 +38,10 @@ uint8_t* s3dat_internal_read_cstr(s3dat_t* handle, s3util_exception_t** throws)
4038
return bfr;
4139
}
4240

43-
void s3dat_internal_short(s3dat_t* handle, uint8_t** str) {
44-
uint8_t* bfr = *str;
41+
void s3dat_internal_short(s3dat_t* handle, char** str) {
42+
char* bfr = *str;
4543

46-
uint8_t* bfr2 = s3util_alloc_func(s3dat_memset(handle), strlen(bfr)+1, NULL);
44+
char* bfr2 = s3util_alloc_func(s3dat_memset(handle), strlen(bfr)+1, NULL);
4745
if(bfr2 == NULL) return;
4846

4947
strcpy(bfr2, bfr);
@@ -102,7 +100,7 @@ void s3dat_internal_iso8859_to_utf8(s3dat_t* handle, uint8_t** str, uint32_t len
102100
}
103101

104102
#ifdef USE_ICONV
105-
void s3dat_internal_iconv_dat_to_utf8(s3dat_t* handle, s3dat_language language, uint8_t* cstr, uint8_t** utf8_str, s3util_exception_t** throws) {
103+
void s3dat_internal_iconv_dat_to_utf8(s3dat_t* handle, s3dat_language language, char* cstr, char** utf8_str, s3util_exception_t** throws) {
106104
char* charset;
107105

108106
switch(language) {
@@ -128,14 +126,14 @@ void s3dat_internal_iconv_dat_to_utf8(s3dat_t* handle, s3dat_language language,
128126

129127
size_t inlen = strlen(cstr);
130128
size_t outlen = inlen*4+4;
131-
uint8_t* utf8s = s3util_alloc_func(s3dat_memset(handle), outlen, throws);
129+
char* utf8s = s3util_alloc_func(s3dat_memset(handle), outlen, throws);
132130
if(*throws != NULL) {
133131
s3util_add_to_stack(s3dat_memset(handle), throws, __FILE__, __func__, __LINE__);
134132
return;
135133
}
136134

137135
*utf8_str = utf8s;
138-
uint8_t* instr = cstr;
136+
char* instr = cstr;
139137

140138
if(iconv(iconv_s, (char**)&instr, &inlen, (char**)&utf8s, &outlen) == (size_t)-1) {
141139
s3util_free_func(s3dat_memset(handle), *utf8_str);
@@ -154,7 +152,7 @@ void s3dat_internal_extract_string(s3dat_t* handle, uint16_t text, uint16_t lang
154152
s3dat_internal_seek_func(handle, handle->string_index->sequences[text].pointers[language], S3UTIL_SEEK_SET, throws);
155153
S3UTIL_HANDLE_EXCEPTION(s3dat_memset(handle), throws, __FILE__, __func__, __LINE__);
156154

157-
uint8_t* cstr = s3dat_internal_read_cstr(handle, throws);
155+
char* cstr = s3dat_internal_read_cstr(handle, throws);
158156
S3UTIL_HANDLE_EXCEPTION(s3dat_memset(handle), throws, __FILE__, __func__, __LINE__);
159157

160158
s3dat_internal_short(handle, &cstr);
@@ -182,7 +180,7 @@ void s3dat_utf8_encoding_handler(s3dat_extracthandler_t* me, s3dat_res_t* res, s
182180
s3dat_string_t* string = res->res->data.str;
183181

184182
#ifdef USE_ICONV
185-
uint8_t* utf8_str = NULL;
183+
char* utf8_str = NULL;
186184
s3dat_internal_iconv_dat_to_utf8(handle, string->language, string->string_data, &utf8_str, throws);
187185

188186
if(*throws == NULL) {
@@ -206,7 +204,7 @@ bool s3dat_utf8(s3dat_ref_t* str) {
206204
return !str->data.str->original_encoding;
207205
}
208206

209-
uint8_t* s3dat_strdata(s3dat_ref_t* str) {
207+
char* s3dat_strdata(s3dat_ref_t* str) {
210208
if(!s3dat_is_string(str)) return NULL;
211209
return str->data.str->string_data;
212210
}

walk.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int width = 640, height = 360;
1212

1313
typedef struct {
1414
s3dat_t* parent;
15-
int tex_id;
15+
GLuint tex_id;
1616
uint16_t width;
1717
uint16_t height;
1818
int16_t xoff;
@@ -39,7 +39,7 @@ void bitmap_to_gl_handler(s3dat_extracthandler_t* me, s3dat_res_t* res, s3util_e
3939
gltex_t* texhandle = s3util_alloc_func(s3dat_memset(handle), sizeof(gltex_t), throws);
4040
S3UTIL_HANDLE_EXCEPTION(s3dat_memset(handle), throws, __FILE__, __func__, __LINE__);
4141

42-
int tex_id;
42+
GLuint tex_id;
4343
glGenTextures(1, &tex_id);
4444
glBindTexture(GL_TEXTURE_2D, tex_id);
4545
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);

0 commit comments

Comments
 (0)