~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to camel/camel-mime-filter-linewrap.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
                } else if (isspace (*p)) {
87
87
                        if (nchars >= linewrap->wrap_len) {
88
88
                                *q++ = '\n';
89
 
                                p++;
 
89
                                while (p < inend && isspace (*p))
 
90
                                        p++;
90
91
                                nchars = 0;
91
92
                        } else {
92
93
                                *q++ = *p++;
 
94
                                nchars++;
93
95
                        }
94
96
                } else {
95
97
                        *q++ = *p++;
97
99
                }
98
100
 
99
101
                /* line is getting way too long, we must force a wrap here */
100
 
                if (nchars >= (linewrap->max_len - 1) && *p != '\n') {
101
 
                        *q++ = '\n';
102
 
                        *q++ = linewrap->indent;
103
 
                        nchars = 0;
 
102
                if (nchars >= linewrap->max_len && *p != '\n') {
 
103
                        gboolean wrapped = FALSE;
 
104
 
 
105
                        if (isspace (*p)) {
 
106
                                while (p < inend && isspace (*p) && *p != '\n')
 
107
                                        p++;
 
108
                        } else if ((linewrap->flags & CAMEL_MIME_FILTER_LINEWRAP_WORD) != 0) {
 
109
                                gchar *r = q - 1;
 
110
 
 
111
                                /* find the first space backward */
 
112
                                while (r > f->outbuf && !isspace (*r))
 
113
                                        r--;
 
114
 
 
115
                                if (r > f->outbuf && *r != '\n') {
 
116
                                        /* found some valid */
 
117
                                        *r = '\n';
 
118
                                        wrapped = TRUE;
 
119
 
 
120
                                        if ((linewrap->flags & CAMEL_MIME_FILTER_LINEWRAP_NOINDENT) == 0) {
 
121
                                                gchar *s = q + 1;
 
122
 
 
123
                                                while (s > r) {
 
124
                                                        *s = *(s - 1);
 
125
                                                        s--;
 
126
                                                }
 
127
 
 
128
                                                *r = linewrap->indent;
 
129
                                                q++;
 
130
                                        }
 
131
 
 
132
                                        nchars = q - r - 1;
 
133
                                }
 
134
                        }
 
135
 
 
136
                        if (!wrapped) {
 
137
                                *q++ = '\n';
 
138
                                if ((linewrap->flags & CAMEL_MIME_FILTER_LINEWRAP_NOINDENT) == 0) {
 
139
                                        *q++ = linewrap->indent;
 
140
                                        nchars = 1;
 
141
                                } else
 
142
                                        nchars = 0;
 
143
                        }
104
144
                }
105
145
        }
106
146
 
128
168
}
129
169
 
130
170
CamelMimeFilter *
131
 
camel_mime_filter_linewrap_new (guint preferred_len, guint max_len, gchar indent_char)
 
171
camel_mime_filter_linewrap_new (guint preferred_len, guint max_len, gchar indent_char, guint32 flags)
132
172
{
133
173
        CamelMimeFilterLinewrap *linewrap =
134
174
                CAMEL_MIME_FILTER_LINEWRAP (camel_object_new (CAMEL_MIME_FILTER_LINEWRAP_TYPE));
137
177
        linewrap->wrap_len = preferred_len;
138
178
        linewrap->max_len = max_len;
139
179
        linewrap->nchars = 0;
 
180
        linewrap->flags = flags | (indent_char == 0 ? CAMEL_MIME_FILTER_LINEWRAP_NOINDENT : 0);
140
181
 
141
182
        return (CamelMimeFilter *) linewrap;
142
183
}