Fix compile errors and get rid of glib dependency

This commit is contained in:
Cacodemon345
2021-08-22 22:37:37 +06:00
parent 39fea69d5c
commit f6af2b0162
3 changed files with 38 additions and 2 deletions

View File

@@ -127,5 +127,4 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_subdirectory(win)
else()
add_subdirectory(unix)
target_link_libraries(86Box glib-2.0)
endif()

View File

@@ -33,7 +33,7 @@
#else
/* Declare these functions to avoid warnings. They will redirect to strcasecmp and strncasecmp respectively. */
extern int stricmp(const char* s1, const char* s2);
extern int strnicmp(const char* s1, const char* s2, int n);
extern int strnicmp(const char* s1, const char* s2, size_t n);
#endif
#if defined(UNIX) && defined(FREEBSD) || defined(__APPLE__)

View File

@@ -94,3 +94,40 @@ g_strv_length(gchar **str_array)
++i;
return i;
}
/* Implementation borrowed from GLib itself. */
gsize
g_strlcpy (gchar *dest,
const gchar *src,
gsize dest_size)
{
gchar *d = dest;
const gchar *s = src;
gsize n = dest_size;
if (dest == NULL) return 0;
if (src == NULL) return 0;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0)
do
{
gchar c = *s++;
*d++ = c;
if (c == 0)
break;
}
while (--n != 0);
/* If not enough room in dest, add NUL and traverse rest of src */
if (n == 0)
{
if (dest_size != 0)
*d = 0;
while (*s++)
;
}
return s - src - 1; /* count does not include NUL */
}