Mercurial > pidgin.yaz
changeset 7628:e293d0c42ccb
[gaim-migrate @ 8252]
"Hi, my name is Gaim ... and I'm addicted to glib 2.0."
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Tue, 25 Nov 2003 03:30:59 +0000 |
parents | dc88428762c9 |
children | 778624d3fced |
files | src/gtkblist.c src/log.c src/util.c src/util.h |
diffstat | 4 files changed, 46 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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));
--- 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;
--- 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) {
--- 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. *