Remove nested functions
authorWilliam Lash <william.lash@gmail.com>
Mon, 21 Jan 2019 15:40:46 +0000 (15:40 +0000)
committerDavid Griffith <dave@661.org>
Mon, 21 Jan 2019 15:40:46 +0000 (15:40 +0000)
src/sdl/Makefile
src/sdl/sf_osfdlg.c
src/sdl/sf_util.c

index 319835e2bd01de0a404fca0683234fbff8868f5a..570005d87b529537e321cf7c9f754e276cf24dc6 100644 (file)
@@ -2,8 +2,10 @@
 
 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 \
@@ -33,7 +35,7 @@ clean:
 
 %.o: %.c
 %.o: %.c %.d
-       $(CC) -MMD -MP $(CFLAGS) -c $<
+       $(CC) -MMD -MP $(CFLAGS) -fPIC -fpic -c $<
 
 $(DEPS):;
 
index 7c38f82da81ba94c66ac112c7d94e9686fb88685..e4cc82a52fdebe42cd64b540a7a2c05a9e9b38a8 100644 (file)
@@ -501,6 +501,16 @@ STATIC char *resolvedir( char *dir, char *res, int size)
   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)
   {
@@ -512,16 +522,6 @@ STATIC ENTRY * dodir(
   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);
@@ -564,9 +564,9 @@ STATIC ENTRY * dodir(
   *resdend = 0;
 
   n = 0;
-  exhaust(dirs);
+  exhaust(dirs, &res, &n);
   *ndirs = n;
-  exhaust(files);
+  exhaust(files, &res, &n);
   *ntot = n;
 
   if (res)
index 17b2a36f8903feae61c07d84ba3a59fc25d44b21..89596ab817c93d19c0e401291eecf0da8584d96c 100644 (file)
@@ -883,19 +883,19 @@ char * sf_GetProfileString( const char *sect, const char *id, char * def)
 
 #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);
@@ -905,7 +905,7 @@ static int myunzip( int csize, byte *cdata, byte *udata)
   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;
        }