SDL_PKGS ?= libpng libjpeg sdl2 SDL2_mixer freetype2 zlib
-# Dependency generation requires GCC.
+# Dependency generation requires GCC or clang.
CC = gcc
+#CC = clang
+
CFLAGS += `pkg-config $(SDL_PKGS) --cflags`
SOURCES = sf_fonts.c sf_msg_en.c sf_resource.c sf_util.c \
%.o: %.c
%.o: %.c %.d
- $(CC) -MMD -MP $(CFLAGS) -c $<
+ $(CC) -MMD -MP $(CFLAGS) -fPIC -fpic -c $<
$(DEPS):;
return p;
}
+static void exhaust( ENTRY *e, ENTRY **resp, int *n)
+ {
+ if (!e) return;
+ exhaust(e->left, resp, n);
+ e->left = *resp;
+ *resp = e;
+ (*n)++;
+ exhaust(e->right, resp, n);
+ }
+
STATIC ENTRY * dodir(
char *dirname, char *pattern, char *resdir, int size, int *ndirs, int *ntot)
{
struct stat fst;
int n;
- void exhaust( ENTRY *e)
- {
- if (!e) return;
- exhaust(e->left);
- e->left = res;
- res = e;
- n++;
- exhaust(e->right);
- }
-
//printf("\ndodir\n");
if (!resolvedir(dirname,resdir,size)) return NULL;
resdend = resdir+strlen(resdir);
*resdend = 0;
n = 0;
- exhaust(dirs);
+ exhaust(dirs, &res, &n);
*ndirs = n;
- exhaust(files);
+ exhaust(files, &res, &n);
*ntot = n;
if (res)
#define pshort( b) (((int)((b)[1]) << 8) + (int)((b)[0]))
+static unsigned myin( void *d, byte **b){return 0;}
+static int myout( void *udata, byte *b, unsigned n)
+ {
+ memmove(udata,b,n); udata += n;
+ return 0;
+ }
+
static int myunzip( int csize, byte *cdata, byte *udata)
{
byte window[32768];
z_stream z;
int st;
- unsigned myin( void *d, byte **b){return 0;}
- int myout( void *d, byte *b, unsigned n)
- {
- memmove(udata,b,n); udata += n;
- return 0;
- }
-
memset(&z,0,sizeof(z));
st = inflateBackInit( &z, 15, window);
z.avail_in = csize;
for (;;){
- st = inflateBack( &z, myin, NULL, myout, NULL);
+ st = inflateBack( &z, myin, NULL, myout, udata);
if (st == Z_STREAM_END) break;
if (st) return st;
}