diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-04-22 02:00:47 +0000 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-04-22 02:00:47 +0000 |
commit | 1478250fdc3f944fe2b6bce7aec5b34d69ea23bd (patch) | |
tree | 7ca8edb7654e2fd27827ad6fed8daf5511875012 | |
parent | 5034f7daa719e137ff233fdd31682af165e7b1a5 (diff) | |
download | gmime-1478250fdc3f944fe2b6bce7aec5b34d69ea23bd.tar.gz |
Pull some fixes back from HEAD.
2002-04-21 Jeffrey Stedfast <fejj@ximian.com>
* gmime-parser.c: Pull some fixes back from HEAD.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | gmime-parser.c | 23 | ||||
-rw-r--r-- | gmime-stream.c | 16 | ||||
-rw-r--r-- | gmime/gmime-parser.c | 23 | ||||
-rw-r--r-- | gmime/gmime-stream.c | 16 |
5 files changed, 50 insertions, 32 deletions
@@ -1,3 +1,7 @@ +2002-04-21 Jeffrey Stedfast <fejj@ximian.com> + + * gmime-parser.c: Pull some fixes back from HEAD. + 2002-04-20 Jeffrey Stedfast <fejj@ximian.com> * gmime-part.c (g_mime_part_encoding_from_string): Added support diff --git a/gmime-parser.c b/gmime-parser.c index 6b1ca45d..7955ab7f 100644 --- a/gmime-parser.c +++ b/gmime-parser.c @@ -418,10 +418,13 @@ parser_step_headers (GMimeParser *parser) inend = parser->inend; header_backup (parser, inptr, inend - inptr); - header_parse (parser, hend); + /*header_parse (parser, hend);*/ headers_end: + if (priv->headerptr > priv->headerbuf) + header_parse (priv, hend); + parser->state = GMIME_PARSER_STATE_HEADERS_END; g_assert (inptr <= parser->inend); @@ -473,13 +476,16 @@ parser_skip_line (GMimeParser *parser) inptr = parser->inptr; do { - if (parser_fill (parser) <= 0) + if (parser_fill (parser) <= 0) { + inptr = priv->inptr; break; + } inptr = parser->inptr; inend = parser->inend; + *inend = '\n'; - while (inptr < inend && *inptr != '\n') + while (*inptr != '\n') inptr++; if (inptr < inend) @@ -490,7 +496,7 @@ parser_skip_line (GMimeParser *parser) parser->midline = FALSE; - parser->inptr = inptr + 1; + parser->inptr = MIN (inptr + 1, priv->inend); } enum { @@ -504,7 +510,7 @@ enum { g_byte_array_append (content, start, len); \ } G_STMT_END -#define possible_boundary(start, len) (len >= 3 && (start[0] == '-' && start[1] == '-')) +#define possible_boundary(start, len) (len >= 2 && (start[0] == '-' && start[1] == '-')) /* Optimization Notes: * @@ -531,12 +537,13 @@ parser_scan_content (GMimeParser *parser, GByteArray *content) g_assert (parser->inptr <= parser->inend); - start = inptr = parser->inptr; + inptr = parser->inptr; do { refill: nleft = parser->inend - inptr; if (parser_fill (parser) <= 0) { + start = priv->inptr; found = FOUND_EOS; break; } @@ -727,7 +734,7 @@ parser_construct_leaf_part (GMimeParser *parser, GMimeContentType *content_type, g_mime_part_set_content_type (mime_part, content_type); - /* skip empty line */ + /* skip empty line after headers */ parser_skip_line (parser); parser_scan_mime_part_content (parser, mime_part, found); @@ -818,7 +825,7 @@ parser_construct_multipart (GMimeParser *parser, GMimeContentType *content_type, g_mime_part_set_content_type (multipart, content_type); - /* skip empty line */ + /* skip empty line after headers */ parser_skip_line (parser); boundary = g_mime_content_type_get_parameter (content_type, "boundary"); diff --git a/gmime-stream.c b/gmime-stream.c index 79083dc9..9e3b6186 100644 --- a/gmime-stream.c +++ b/gmime-stream.c @@ -145,7 +145,7 @@ g_mime_stream_close (GMimeStream *stream) * * Tests the end-of-stream indicator for @stream. * - * Returns TRUE on EOS or FALSE otherwise. + * Returns %TRUE on EOS or %FALSE otherwise. **/ gboolean g_mime_stream_eos (GMimeStream *stream) @@ -186,12 +186,12 @@ g_mime_stream_reset (GMimeStream *stream) * the argument @offset according to the * directive @whence as follows: * - * GMIME_STREAM_SEEK_SET: The offset is set to @offset bytes. + * #GMIME_STREAM_SEEK_SET: The offset is set to @offset bytes. * - * GMIME_STREAM_SEEK_CUR: The offset is set to its current + * #GMIME_STREAM_SEEK_CUR: The offset is set to its current * location plus @offset bytes. * - * GMIME_STREAM_SEEK_END: The offset is set to the size of the + * #GMIME_STREAM_SEEK_END: The offset is set to the size of the * stream plus @offset bytes. * * Returns the resultant position on success or -1 on fail. @@ -307,7 +307,7 @@ g_mime_stream_unref (GMimeStream *stream) * @start: start boundary * @end: end boundary * - * Set the bounds on a stream. + * Sets the bounds on the stream @stream. **/ void g_mime_stream_set_bounds (GMimeStream *stream, off_t start, off_t end) @@ -331,7 +331,7 @@ g_mime_stream_set_bounds (GMimeStream *stream, off_t start, off_t end) * * Writes @string to @stream. * - * Returns the number of bytes written. + * Returns the number of bytes written or -1 on fail. **/ ssize_t g_mime_stream_write_string (GMimeStream *stream, const char *string) @@ -351,7 +351,7 @@ g_mime_stream_write_string (GMimeStream *stream, const char *string) * * Write formatted output to a stream. * - * Returns the number of bytes written. + * Returns the number of bytes written or -1 on fail. **/ ssize_t g_mime_stream_printf (GMimeStream *stream, const char *fmt, ...) @@ -384,7 +384,7 @@ g_mime_stream_printf (GMimeStream *stream, const char *fmt, ...) * * Attempts to write stream @src to stream @dest. * - * Returns the number of bytes written. + * Returns the number of bytes written or -1 on fail. **/ ssize_t g_mime_stream_write_to_stream (GMimeStream *src, GMimeStream *dest) diff --git a/gmime/gmime-parser.c b/gmime/gmime-parser.c index 6b1ca45d..7955ab7f 100644 --- a/gmime/gmime-parser.c +++ b/gmime/gmime-parser.c @@ -418,10 +418,13 @@ parser_step_headers (GMimeParser *parser) inend = parser->inend; header_backup (parser, inptr, inend - inptr); - header_parse (parser, hend); + /*header_parse (parser, hend);*/ headers_end: + if (priv->headerptr > priv->headerbuf) + header_parse (priv, hend); + parser->state = GMIME_PARSER_STATE_HEADERS_END; g_assert (inptr <= parser->inend); @@ -473,13 +476,16 @@ parser_skip_line (GMimeParser *parser) inptr = parser->inptr; do { - if (parser_fill (parser) <= 0) + if (parser_fill (parser) <= 0) { + inptr = priv->inptr; break; + } inptr = parser->inptr; inend = parser->inend; + *inend = '\n'; - while (inptr < inend && *inptr != '\n') + while (*inptr != '\n') inptr++; if (inptr < inend) @@ -490,7 +496,7 @@ parser_skip_line (GMimeParser *parser) parser->midline = FALSE; - parser->inptr = inptr + 1; + parser->inptr = MIN (inptr + 1, priv->inend); } enum { @@ -504,7 +510,7 @@ enum { g_byte_array_append (content, start, len); \ } G_STMT_END -#define possible_boundary(start, len) (len >= 3 && (start[0] == '-' && start[1] == '-')) +#define possible_boundary(start, len) (len >= 2 && (start[0] == '-' && start[1] == '-')) /* Optimization Notes: * @@ -531,12 +537,13 @@ parser_scan_content (GMimeParser *parser, GByteArray *content) g_assert (parser->inptr <= parser->inend); - start = inptr = parser->inptr; + inptr = parser->inptr; do { refill: nleft = parser->inend - inptr; if (parser_fill (parser) <= 0) { + start = priv->inptr; found = FOUND_EOS; break; } @@ -727,7 +734,7 @@ parser_construct_leaf_part (GMimeParser *parser, GMimeContentType *content_type, g_mime_part_set_content_type (mime_part, content_type); - /* skip empty line */ + /* skip empty line after headers */ parser_skip_line (parser); parser_scan_mime_part_content (parser, mime_part, found); @@ -818,7 +825,7 @@ parser_construct_multipart (GMimeParser *parser, GMimeContentType *content_type, g_mime_part_set_content_type (multipart, content_type); - /* skip empty line */ + /* skip empty line after headers */ parser_skip_line (parser); boundary = g_mime_content_type_get_parameter (content_type, "boundary"); diff --git a/gmime/gmime-stream.c b/gmime/gmime-stream.c index 79083dc9..9e3b6186 100644 --- a/gmime/gmime-stream.c +++ b/gmime/gmime-stream.c @@ -145,7 +145,7 @@ g_mime_stream_close (GMimeStream *stream) * * Tests the end-of-stream indicator for @stream. * - * Returns TRUE on EOS or FALSE otherwise. + * Returns %TRUE on EOS or %FALSE otherwise. **/ gboolean g_mime_stream_eos (GMimeStream *stream) @@ -186,12 +186,12 @@ g_mime_stream_reset (GMimeStream *stream) * the argument @offset according to the * directive @whence as follows: * - * GMIME_STREAM_SEEK_SET: The offset is set to @offset bytes. + * #GMIME_STREAM_SEEK_SET: The offset is set to @offset bytes. * - * GMIME_STREAM_SEEK_CUR: The offset is set to its current + * #GMIME_STREAM_SEEK_CUR: The offset is set to its current * location plus @offset bytes. * - * GMIME_STREAM_SEEK_END: The offset is set to the size of the + * #GMIME_STREAM_SEEK_END: The offset is set to the size of the * stream plus @offset bytes. * * Returns the resultant position on success or -1 on fail. @@ -307,7 +307,7 @@ g_mime_stream_unref (GMimeStream *stream) * @start: start boundary * @end: end boundary * - * Set the bounds on a stream. + * Sets the bounds on the stream @stream. **/ void g_mime_stream_set_bounds (GMimeStream *stream, off_t start, off_t end) @@ -331,7 +331,7 @@ g_mime_stream_set_bounds (GMimeStream *stream, off_t start, off_t end) * * Writes @string to @stream. * - * Returns the number of bytes written. + * Returns the number of bytes written or -1 on fail. **/ ssize_t g_mime_stream_write_string (GMimeStream *stream, const char *string) @@ -351,7 +351,7 @@ g_mime_stream_write_string (GMimeStream *stream, const char *string) * * Write formatted output to a stream. * - * Returns the number of bytes written. + * Returns the number of bytes written or -1 on fail. **/ ssize_t g_mime_stream_printf (GMimeStream *stream, const char *fmt, ...) @@ -384,7 +384,7 @@ g_mime_stream_printf (GMimeStream *stream, const char *fmt, ...) * * Attempts to write stream @src to stream @dest. * - * Returns the number of bytes written. + * Returns the number of bytes written or -1 on fail. **/ ssize_t g_mime_stream_write_to_stream (GMimeStream *src, GMimeStream *dest) |