# HG changeset patch # User Ethan Blanton # Date 1069731059 0 # Node ID e293d0c42ccb8315753ada9829117f646f06bf2c # Parent dc88428762c9837f20230c0438a02f11f7b9b999 [gaim-migrate @ 8252] "Hi, my name is Gaim ... and I'm addicted to glib 2.0." committer: Tailor Script diff -r dc88428762c9 -r e293d0c42ccb src/gtkblist.c --- a/src/gtkblist.c Tue Nov 25 02:23:25 2003 +0000 +++ b/src/gtkblist.c Tue Nov 25 03:30:59 2003 +0000 @@ -1132,7 +1132,7 @@ s = uris; do { - if (g_str_has_prefix(*s, "file://")) { + if (gaim_str_has_prefix(*s, "file://")) { char *file = g_strstrip(*s + strlen ("file://")); serv_send_file(buddy->account->gc, buddy->name, file); @@ -1193,7 +1193,7 @@ /* Count how many files the user is trying to send */ do { - if (g_str_has_prefix (*s, "file://")) + if (gaim_str_has_prefix (*s, "file://")) n++; } while (*(++s)); diff -r dc88428762c9 -r e293d0c42ccb src/log.c --- a/src/log.c Tue Nov 25 02:23:25 2003 +0000 +++ b/src/log.c Tue Nov 25 03:30:59 2003 +0000 @@ -246,7 +246,7 @@ { GDir *dir; GList *list = NULL; - const char *filename, *tmp; + const char *filename; char *me = g_strdup(gaim_normalize(account, gaim_account_get_username(account))); const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO @@ -260,8 +260,7 @@ return NULL; } while ((filename = g_dir_read_name(dir))) { - tmp = filename + (strlen(filename) - strlen(ext)); - if (tmp > filename && !strcmp(tmp, ext)) { + if (gaim_str_has_suffix(filename, ext)) { const char *l = filename; struct tm time; GaimLog *log; diff -r dc88428762c9 -r e293d0c42ccb src/util.c --- a/src/util.c Tue Nov 25 02:23:25 2003 +0000 +++ b/src/util.c Tue Nov 25 03:30:59 2003 +0000 @@ -1532,6 +1532,26 @@ return dest; } +gboolean +gaim_str_has_prefix(const char *s, const char *p) +{ + if (!strncmp(s, p, strlen(p))) + return TRUE; + + return FALSE; +} + +gboolean +gaim_str_has_suffix(const char *s, const char *x) +{ + int off = strlen(s) - strlen(x); + + if (off >= 0 && !strcmp(s + off, x)) + return TRUE; + + return FALSE; +} + char * gaim_str_add_cr(const char *text) { diff -r dc88428762c9 -r e293d0c42ccb src/util.h --- a/src/util.h Tue Nov 25 02:23:25 2003 +0000 +++ b/src/util.h Tue Nov 25 03:30:59 2003 +0000 @@ -322,6 +322,28 @@ const char *gaim_normalize(const GaimAccount *account, const char *str); /** + * Compares two strings to see if the first contains the second as + * a proper prefix. + * + * @param s The string to check. + * @param p The prefix in question. + * + * @return TRUE if p is a prefix of s, otherwise FALSE. + */ +gboolean gaim_str_has_prefix(const char *s, const char *p); + +/** + * Compares two strings to see if the second is a proper suffix + * of the first. + * + * @param s The string to check. + * @param x The suffix in question. + * + * @return TRUE if x is a a suffix of s, otherwise FALSE. + */ +gboolean gaim_str_has_suffix(const char *s, const char *x); + +/** * Looks for %n, %d, or %t in a string, and replaces them with the * specified name, date, and time, respectively. *