Move sf_searchfile() from sf_ftype.c to sf_fonts.c.
authorDavid Griffith <dave@661.org>
Sat, 24 Aug 2019 00:19:19 +0000 (17:19 -0700)
committerDavid Griffith <dave@661.org>
Sat, 24 Aug 2019 00:33:20 +0000 (17:33 -0700)
src/sdl/sf_fonts.c
src/sdl/sf_ftype.c

index afab5bc6c8061ef180aebb0aa037efee172debe8..256a307be3b81b65be3d50607de75b7954e25b76 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 // font handling
 
@@ -860,3 +861,32 @@ void sf_initfonts()
 
   }
 
+char * sf_searchfile( char *fn, int fnlen, char *buf, char *paths)
+  {
+  char *p;
+  if (!fn) return NULL;
+  if (!paths) paths = "";
+  if (fnlen < 0) fnlen = strlen(fn);
+  if (!fnlen) return NULL;
+  for (;;)
+    {
+    int plen;
+    p = strchr(paths,OS_PATHSEP);
+    if (p)
+       plen = p-paths;
+    else
+       plen = strlen(paths);
+    if (plen) strncpy(buf,paths,plen);
+    buf[plen] = 0;
+    if ((plen) && (buf[plen-1] != '\\') && (buf[plen-1] != '/'))
+       strcat(buf,"/");
+    plen = strlen(buf);
+    strncpy(buf+plen,fn,fnlen);
+    buf[plen+fnlen] = 0;
+//printf("try[%s]\n",buf);
+    if (access(buf,F_OK)==0) return buf;
+    if (p) paths = p+1;
+    else break;
+    }
+  return NULL;
+  }
index af6de4627f9285dda539d8c8906e9e5a7871f573..92773f2b7e46f1ec43186e34e831482618a6ac16 100644 (file)
@@ -3,7 +3,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <math.h>
 
 #include <ft2build.h>
 
 /////////////////////////////////////////////////////////////////
 
-char * sf_searchfile( char *fn, int fnlen, char *buf, char *paths)
-  {
-  char *p;
-  if (!fn) return NULL;
-  if (!paths) paths = "";
-  if (fnlen < 0) fnlen = strlen(fn);
-  if (!fnlen) return NULL;
-  for (;;)
-    {
-    int plen;
-    p = strchr(paths,OS_PATHSEP);
-    if (p)
-       plen = p-paths;
-    else
-       plen = strlen(paths);
-    if (plen) strncpy(buf,paths,plen);
-    buf[plen] = 0;
-    if ((plen) && (buf[plen-1] != '\\') && (buf[plen-1] != '/'))
-       strcat(buf,"/");
-    plen = strlen(buf);
-    strncpy(buf+plen,fn,fnlen);
-    buf[plen+fnlen] = 0;
-//printf("try[%s]\n",buf);
-    if (access(buf,F_OK)==0) return buf;
-    if (p) paths = p+1;
-    else break;
-    }
-  return NULL;
-  }
-
-/////////////////////////////////////////////////////////////////
-
 typedef struct {
   SFONT sfont;
   int ascent, descent, height;