1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added glib < 2.30 compatibility function

This commit is contained in:
James Booth 2013-01-30 00:48:32 +00:00
parent 957bea19e4
commit 0ef52901c9
2 changed files with 21 additions and 1 deletions

View File

@ -43,6 +43,21 @@ struct curl_data_t
static size_t _data_callback(void *ptr, size_t size, size_t nmemb, void *data); static size_t _data_callback(void *ptr, size_t size, size_t nmemb, void *data);
// taken from glib 2.30.3
gchar *
p_utf8_substring(const gchar *str, glong start_pos, glong end_pos)
{
gchar *start, *end, *out;
start = g_utf8_offset_to_pointer (str, start_pos);
end = g_utf8_offset_to_pointer (start, end_pos - start_pos);
out = g_malloc (end - start + 1);
memcpy (out, start, end - start);
out[end - start] = 0;
return out;
}
// backwards compatibility for GLib version < 2.28 // backwards compatibility for GLib version < 2.28
void void

View File

@ -27,7 +27,11 @@
#include <glib.h> #include <glib.h>
#if !GLIB_CHECK_VERSION(2,28,0) #if !GLIB_CHECK_VERSION(2,28,0)
#define g_slist_free_full(items, free_func) p_slist_free_full(items, free_func) #define g_slist_free_full(items, free_func) p_slist_free_full(items, free_func)
#endif
#if !GLIB_CHECK_VERSION(2,30,0)
#define g_utf8_substring(str, start_pos, end_pos) p_utf8_substring(str, start_pos, end_pos)
#endif #endif
#ifndef NOTIFY_CHECK_VERSION #ifndef NOTIFY_CHECK_VERSION
@ -50,6 +54,7 @@
resource = NULL; \ resource = NULL; \
} }
gchar* p_utf8_substring(const gchar *str, glong start_pos, glong end_pos);
void p_slist_free_full(GSList *items, GDestroyNotify free_func); void p_slist_free_full(GSList *items, GDestroyNotify free_func);
void create_dir(char *name); void create_dir(char *name);
char * str_replace(const char *string, const char *substr, char * str_replace(const char *string, const char *substr,