From 2fea3b70ce247c9dc66fbdefa98007befef8116b Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 19 Aug 2005 09:24:39 +0000 Subject: path_cmp(): allow both '/' and G_DIR_SEPARATOR as separator. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@495 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 5 +++++ ChangeLog.ja | 5 +++++ src/utils.c | 14 ++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/ChangeLog b/ChangeLog index 91e8b4ff..d7b0e96f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-08-19 + + * src/utils.c: path_cmp(): allow both '/' and G_DIR_SEPARATOR as + separator. + 2005-08-19 * src/folder.c: diff --git a/ChangeLog.ja b/ChangeLog.ja index 29c0bfe1..e9cc6a7b 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,8 @@ +2005-08-19 + + * src/utils.c: path_cmp(): '/' と G_DIR_SEPARATOR の両方をセパレータ + として許可するようにした。 + 2005-08-19 * src/folder.c: diff --git a/src/utils.c b/src/utils.c index 5b931492..a72b4e8a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -300,6 +300,9 @@ gint strcmp2(const gchar *s1, const gchar *s2) gint path_cmp(const gchar *s1, const gchar *s2) { gint len1, len2; +#ifdef G_OS_WIN32 + gchar *s1_, *s2_; +#endif if (s1 == NULL || s2 == NULL) return -1; if (*s1 == '\0' || *s2 == '\0') return -1; @@ -307,10 +310,21 @@ gint path_cmp(const gchar *s1, const gchar *s2) len1 = strlen(s1); len2 = strlen(s2); +#ifdef G_OS_WIN32 + Xstrdup_a(s1_, s1, return -1); + Xstrdup_a(s2_, s2, return -1); + subst_char(s1_, '/', G_DIR_SEPARATOR); + subst_char(s2_, '/', G_DIR_SEPARATOR); + if (s1_[len1 - 1] == G_DIR_SEPARATOR) len1--; + if (s2_[len2 - 1] == G_DIR_SEPARATOR) len2--; + + return strncmp(s1_, s2_, MAX(len1, len2)); +#else if (s1[len1 - 1] == G_DIR_SEPARATOR) len1--; if (s2[len2 - 1] == G_DIR_SEPARATOR) len2--; return strncmp(s1, s2, MAX(len1, len2)); +#endif } /* remove trailing return code */ -- cgit v1.2.3