dovecot-2.2-pigeonhole: lib-sieve: Cleaned up error handling for...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Fri Mar 6 20:14:43 UTC 2015


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/465ec119b394
changeset: 1996:465ec119b394
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Fri Mar 06 21:14:01 2015 +0100
description:
lib-sieve: Cleaned up error handling for the lexical scanner.

diffstat:

 src/lib-sieve/sieve-lexer.c |  23 +++++++++++------------
 src/lib-sieve/sieve-lexer.h |   2 +-
 2 files changed, 12 insertions(+), 13 deletions(-)

diffs (70 lines):

diff -r c13471f102be -r 465ec119b394 src/lib-sieve/sieve-lexer.c
--- a/src/lib-sieve/sieve-lexer.c	Fri Mar 06 20:02:15 2015 +0100
+++ b/src/lib-sieve/sieve-lexer.c	Fri Mar 06 21:14:01 2015 +0100
@@ -285,13 +285,13 @@
 	while ( sieve_lexer_curchar(scanner) != '\n' ) {
 		switch( sieve_lexer_curchar(scanner) ) {
 		case -1:
-			if ( scanner->input->eof ) {
-				sieve_lexer_warning(lexer,
-					"no newline (CRLF) at end of hash comment at end of file");
-				lexer->token_type = STT_WHITESPACE;
-			} else {
+			if ( !scanner->input->eof ) {
 				lexer->token_type = STT_ERROR;
+				return FALSE;
 			}
+			sieve_lexer_warning(lexer,
+				"no newline (CRLF) at end of hash comment at end of file");
+			lexer->token_type = STT_WHITESPACE;
 			return TRUE;
 		case '\0':
 			sieve_lexer_error
@@ -532,10 +532,11 @@
 
 	/* EOF */
 	case -1:
-		if ( scanner->input->eof )
-		  lexer->token_type = STT_EOF;
-		else
+		if ( !scanner->input->eof ) {
 			lexer->token_type = STT_ERROR;
+			return FALSE;
+		}
+		lexer->token_type = STT_EOF;
 		return TRUE;
 
 	default:
@@ -816,7 +817,7 @@
 	}
 }
 
-bool sieve_lexer_skip_token(const struct sieve_lexer *lexer)
+void sieve_lexer_skip_token(const struct sieve_lexer *lexer)
 {
 	/* Scan token while skipping whitespace */
 	do {
@@ -830,10 +831,8 @@
 					"error reading script during lexical analysis: %s",
 					i_stream_get_error(scanner->input));
 			}
-			return FALSE;
+			return;
 		}
 	} while ( lexer->token_type == STT_WHITESPACE );
-
-	return TRUE;
 }
 
diff -r c13471f102be -r 465ec119b394 src/lib-sieve/sieve-lexer.h
--- a/src/lib-sieve/sieve-lexer.h	Fri Mar 06 20:02:15 2015 +0100
+++ b/src/lib-sieve/sieve-lexer.h	Fri Mar 06 21:14:01 2015 +0100
@@ -67,7 +67,7 @@
  * Scanning
  */
 
-bool sieve_lexer_skip_token(const struct sieve_lexer *lexer);
+void sieve_lexer_skip_token(const struct sieve_lexer *lexer);
 
 /*
  * Token access


More information about the dovecot-cvs mailing list