]> git.pld-linux.org Git - packages/mutt.git/blob - mutt-imap_mxcmp.patch
- bring some sanity and usability to configuration
[packages/mutt.git] / mutt-imap_mxcmp.patch
1 --- mutt-1.5.17/imap/util.c.orig        2007-04-12 22:44:40.000000000 +0200
2 +++ mutt-1.5.17/imap/util.c     2007-11-13 15:57:52.000000000 +0100
3 @@ -262,13 +262,44 @@
4    return 0;
5  }
6  
7 -/* silly helper for mailbox name string comparisons, because of INBOX */
8 +/* Silly helper for mailbox name string comparisons, because of INBOX 
9 + * and different folder delimiters. Warning: unlike strcmp this funtion
10 + * won't tell which mailbox is 'greater'. */
11  int imap_mxcmp (const char* mx1, const char* mx2)
12  {
13 +  int result;
14 +  int i,j;
15 +  char c1,c2;
16 +
17    if (!ascii_strcasecmp (mx1, "INBOX") && !ascii_strcasecmp (mx2, "INBOX"))
18      return 0;
19 -  
20 -  return mutt_strcmp (mx1, mx2);
21 +
22 +  result = mutt_strcmp (mx1, mx2);
23 +
24 +  if (result == 0 || !ImapDelimChars || !ImapDelimChars[0]) {
25 +    /* exactly equal or no ImapDelimChars -- we are done */
26 +    return 0;
27 +  }
28 +
29 +  if (!mx1 || !mx2) return 1;
30 +
31 +  /* compare with normalized delimiters 
32 +   * (so "INBOX.something" equals "INBOX./something") */
33 +  for(i=0,j=0; mx1[i] && mx2[j]; i++, j++) {
34 +    c1 = mx1[i];
35 +    c2 = mx2[j];
36 +    if (strchr(ImapDelimChars, c1)) {
37 +      c1 = ImapDelimChars[0];
38 +      while(mx1[i+1] && strchr(ImapDelimChars, mx1[i+1])) i+=1;
39 +    }
40 +    if (strchr(ImapDelimChars, c2)) {
41 +      c2 = ImapDelimChars[0];
42 +      while(mx2[j+1] && strchr(ImapDelimChars, mx2[j+1])) j+=1;
43 +    }
44 +    if (c1 != c2) return 1;
45 +  }
46 +  if (mx1[i] || mx2[j]) return 1;
47 +  return 0;
48  }
49  
50  /* imap_pretty_mailbox: called by mutt_pretty_mailbox to make IMAP paths
This page took 0.031834 seconds and 3 git commands to generate.