]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/imap/imap_fetch.c
imap_fetch.c: output an extra space required before the
[citadel.git] / citadel / modules / imap / imap_fetch.c
index 9f08131dfb91e94d3882ab75d60a23832351f4ee..1e026ba939a2765345836dda20d82b7d52f98bab 100644 (file)
@@ -510,11 +510,11 @@ void imap_strip_headers(char *section) {
        if (!strncasecmp(which_fields, "HEADER.FIELDS.NOT", 17))
                headers_not = 1;
 
-       for (i=0; !IsEmptyStr(&which_fields[i]); ++i) {
+       for (i=0; which_fields[i]; ++i) {
                if (which_fields[i]=='(')
                        strcpy(which_fields, &which_fields[i+1]);
        }
-       for (i=0; !IsEmptyStr(&which_fields[i]); ++i) {
+       for (i=0; which_fields[i]; ++i) {
                if (which_fields[i]==')') {
                        which_fields[i] = 0;
                        break;
@@ -774,6 +774,7 @@ void imap_fetch_bodystructure_part(
        size_t i;
        char cbmaintype[128];
        char cbsubtype[128];
+       char iteration[128];
 
        if (cbtype != NULL) if (!IsEmptyStr(cbtype)) have_cbtype = 1;
        if (have_cbtype) {
@@ -785,6 +786,23 @@ void imap_fetch_bodystructure_part(
                strcpy(cbsubtype, "PLAIN");
        }
 
+       /* If this is the second or subsequent part of a multipart sequence,
+        * we need to output another space here.  We do this by obtaining the
+        * last subpart token of the partnum and converting it to a number.
+        */
+       if (strrchr(partnum, '.')) {
+               safestrncpy(iteration, (strrchr(partnum, '.')+1), sizeof iteration);
+       }
+       else {
+               safestrncpy(iteration, partnum, sizeof iteration);
+       }
+       if (atoi(iteration) > 1) {
+               cprintf(" ");
+       }
+
+
+       /* output loop */
+
        cprintf("(");
        imap_strout(cbmaintype);
        cprintf(" ");
@@ -1096,7 +1114,7 @@ void imap_handle_macros(char *str) {
        int i;
        int nest = 0;
 
-       for (i=0; !IsEmptyStr(&str[i]); ++i) {
+       for (i=0; str[i]; ++i) {
                if (str[i]=='(') ++nest;
                if (str[i]=='[') ++nest;
                if (str[i]=='<') ++nest;
@@ -1142,7 +1160,7 @@ int imap_extract_data_items(char **argv, char *items) {
        long initial_len;
 
        /* Convert all whitespace to ordinary space characters. */
-       for (i=0; !IsEmptyStr(&items[i]); ++i) {
+       for (i=0; items[i]; ++i) {
                if (isspace(items[i])) items[i]=' ';
        }