From 813249477782bf195a498267077f99dc07169b8c Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Wed, 13 Feb 2008 13:24:35 +0100
Subject: [PATCH] Incorporated changes in dovecot-1.1

---
 src/lib-sieve/ext-encoded-character.c        |  4 ++--
 src/lib-sieve/plugins/body/ext-body-common.c |  8 +++----
 src/lib-sieve/sieve-address-parts.c          |  4 ++--
 src/lib-sieve/sieve-ast.c                    | 12 ++++++----
 src/lib-sieve/sieve-binary.c                 | 20 ++++++++--------
 src/lib-sieve/sieve-commands.c               |  9 +++++---
 src/lib-sieve/sieve-error.c                  |  4 ++--
 src/lib-sieve/sieve-error.h                  | 18 +++++++++++----
 src/lib-sieve/sieve-generator.c              |  4 ++--
 src/lib-sieve/sieve-interpreter.c            | 12 +++++-----
 src/lib-sieve/sieve-lexer.c                  | 18 +++++++++------
 src/lib-sieve/sieve-parser.c                 | 24 ++++++++++++--------
 src/lib-sieve/sieve-validator.c              |  4 ++--
 src/lib-sieve/sieve.c                        |  4 ++--
 src/plugins/lda-sieve/lda-sieve-plugin.c     |  6 ++---
 15 files changed, 86 insertions(+), 65 deletions(-)

diff --git a/src/lib-sieve/ext-encoded-character.c b/src/lib-sieve/ext-encoded-character.c
index 23608ea46..dd5f11543 100644
--- a/src/lib-sieve/ext-encoded-character.c
+++ b/src/lib-sieve/ext-encoded-character.c
@@ -164,7 +164,7 @@ bool arg_encoded_string_validate
 	const char *strval = (const char *) str_data(str);
 	const char *strend = strval + str_len(str);
 
-	T_FRAME(		
+	T_BEGIN {		
 		tmpstr = t_str_new(32);	
 			
 		p = strval;
@@ -234,7 +234,7 @@ bool arg_encoded_string_validate
 				p++;	
 			}
 		}
-	);
+	} T_END;
 	
 	if ( newstr != NULL ) {
 		if ( strstart != strend )
diff --git a/src/lib-sieve/plugins/body/ext-body-common.c b/src/lib-sieve/plugins/body/ext-body-common.c
index 9c8bac6cc..14e1e1ac0 100644
--- a/src/lib-sieve/plugins/body/ext-body-common.c
+++ b/src/lib-sieve/plugins/body/ext-body-common.c
@@ -200,10 +200,10 @@ static bool ext_body_parts_add_missing
 				continue;
 			}
 		
-			T_FRAME(
+			T_BEGIN {
 				body_part->content_type =
 					p_strdup(ctx->pool, _parse_content_type(block.hdr));
-			);
+			} T_END;
 			continue;
 		}
 
@@ -263,11 +263,11 @@ bool ext_body_get_content
 	bool result = TRUE;
 	struct ext_body_message_context *ctx = ext_body_get_context(renv->msgctx);
 
-	T_FRAME(
+	T_BEGIN {
 		if ( !ext_body_parts_add_missing
 			(renv->msgdata, ctx, content_types, decode_to_plain != 0) )
 			result = FALSE;
-	);
+	} T_END;
 	
 	if ( !result ) return FALSE;
 
diff --git a/src/lib-sieve/sieve-address-parts.c b/src/lib-sieve/sieve-address-parts.c
index fc6f4d3f0..26e72f7b7 100644
--- a/src/lib-sieve/sieve-address-parts.c
+++ b/src/lib-sieve/sieve-address-parts.c
@@ -350,7 +350,7 @@ bool sieve_address_match
 	bool matched = FALSE;
 	const struct message_address *addr;
 
-	T_FRAME(
+	T_BEGIN {
 		addr = message_address_parse
 			(pool_datastack_create(), (const unsigned char *) data, 
 				strlen(data), 256, FALSE);
@@ -370,7 +370,7 @@ bool sieve_address_match
 
 			addr = addr->next;
 		}
-	);
+	} T_END;
 	
 	return matched;
 }
diff --git a/src/lib-sieve/sieve-ast.c b/src/lib-sieve/sieve-ast.c
index c3bef9fb7..0b02aacd1 100644
--- a/src/lib-sieve/sieve-ast.c
+++ b/src/lib-sieve/sieve-ast.c
@@ -96,9 +96,11 @@ void sieve_ast_error
 { 
 	struct sieve_script *script = node->ast->script;
 	
-	T_FRAME(vfunc(ehandler, 
-		t_strdup_printf("%s:%d", sieve_script_name(script),
-			sieve_ast_node_line(node)), fmt, args)); 
+	T_BEGIN {
+		vfunc(ehandler, 
+			t_strdup_printf("%s:%d", sieve_script_name(script),
+				sieve_ast_node_line(node)), fmt, args);
+	} T_END; 
 }
  
 
@@ -641,13 +643,13 @@ void sieve_ast_unparse(struct sieve_ast *ast) {
 
 	printf("Unparsing Abstract Syntax Tree:\n");
 
-	T_FRAME(	
+	T_BEGIN {	
 		command = sieve_ast_command_first(sieve_ast_root(ast));
 		while ( command != NULL ) {	
 			sieve_ast_unparse_command(command, 0);
 			command = sieve_ast_command_next(command);
 		}		
-	);
+	} T_END;
 }
 
 
diff --git a/src/lib-sieve/sieve-binary.c b/src/lib-sieve/sieve-binary.c
index 2c174d1f7..d981897b0 100644
--- a/src/lib-sieve/sieve-binary.c
+++ b/src/lib-sieve/sieve-binary.c
@@ -956,7 +956,7 @@ static bool _sieve_binary_load_extensions(struct sieve_binary *sbin)
 		return FALSE;
 	
 	for ( i = 0; result && i < count; i++ ) {
-		T_FRAME(
+		T_BEGIN {
 			string_t *extension;
 			int ext_id;
 			
@@ -978,7 +978,7 @@ static bool _sieve_binary_load_extensions(struct sieve_binary *sbin)
 				}
 			}	else
 				result = FALSE;
-		);
+		} T_END;
 	}		
 		
 	return result;
@@ -994,7 +994,7 @@ static bool _sieve_binary_open(struct sieve_binary *sbin)
 	
 	/* Verify header */
 	
-	T_FRAME(
+	T_BEGIN {
 		header = LOAD_HEADER(sbin, &offset, const struct sieve_binary_header);
 		if ( header == NULL ) {
 			i_error("sieve: opened binary %s is not even large enough "
@@ -1016,7 +1016,7 @@ static bool _sieve_binary_open(struct sieve_binary *sbin)
 		} else {
 			blk_count = header->blocks;
 		}
-	);
+	} T_END;
 	
 	if ( !result ) return FALSE;
 	
@@ -1025,20 +1025,20 @@ static bool _sieve_binary_open(struct sieve_binary *sbin)
 	printf("BLOCKS: %d\n", blk_count);
 	
 	for ( i = 0; i < blk_count && result; i++ ) {	
-		T_FRAME(
+		T_BEGIN {
 			if ( !_load_block_index_record(sbin, &offset, i) ) {
 				i_error("sieve: block index record %d of opened binary %s is corrupt", 
 					i, sbin->path);
 				result = FALSE;
 			}
-		);
+		} T_END;
 	}
 	
 	if ( !result ) return FALSE;
 	
 	/* Load extensions used by this binary */
 	
-	T_FRAME(
+	T_BEGIN {
 		extensions =_load_block(sbin, &offset, 0);
 		if ( extensions == NULL ) {
 			result = FALSE;
@@ -1047,7 +1047,7 @@ static bool _sieve_binary_open(struct sieve_binary *sbin)
 				sbin->path);
 			result = FALSE;
 		}
-	);
+	} T_END;
 		
 	return result;
 }
@@ -1071,13 +1071,13 @@ static bool _sieve_binary_load(struct sieve_binary *sbin)
 	/* Load the other blocks */
 	
 	for ( i = 1; result && i < blk_count; i++ ) {	
-		T_FRAME(
+		T_BEGIN {
 			if ( _load_block(sbin, &offset, i) == NULL ) {
 				i_error("sieve: block %d of loaded binary %s is corrupt", 
 					i, sbin->path);
 				result = FALSE;
 			}
-		);
+		} T_END;
 	}
 				
 	return result;
diff --git a/src/lib-sieve/sieve-commands.c b/src/lib-sieve/sieve-commands.c
index 6d1a98d8b..29c77c338 100644
--- a/src/lib-sieve/sieve-commands.c
+++ b/src/lib-sieve/sieve-commands.c
@@ -112,9 +112,12 @@ static bool arg_string_list_generate
 		if ( sieve_ast_strlist_count(arg) == 1 ) 
 			return ( sieve_generate_argument
 				(generator, sieve_ast_strlist_first(arg), context) );
-		else
-			T_FRAME( result=emit_string_list_operand(generator, arg, context) );
-		
+		else {
+			T_BEGIN { 
+				result=emit_string_list_operand(generator, arg, context);
+			} T_END;
+		}
+
 		return result;
 	}
 	
diff --git a/src/lib-sieve/sieve-error.c b/src/lib-sieve/sieve-error.c
index 971f07196..616213097 100644
--- a/src/lib-sieve/sieve-error.c
+++ b/src/lib-sieve/sieve-error.c
@@ -256,14 +256,14 @@ static void sieve_logfile_vprintf
 	
 	if ( ehandler->stream == NULL ) return;
 	
-	T_FRAME(
+	T_BEGIN {
 		outbuf = t_str_new(256);
 		str_printfa(outbuf, "%s: %s: ", location, prefix);	
 		str_vprintfa(outbuf, fmt, args);
 		str_append(outbuf, ".\n");
 	
 		o_stream_send(ehandler->stream, str_data(outbuf), str_len(outbuf));
-	);
+	} T_END;
 }
 
 inline static void sieve_logfile_printf
diff --git a/src/lib-sieve/sieve-error.h b/src/lib-sieve/sieve-error.h
index 787ed7c67..12d462873 100644
--- a/src/lib-sieve/sieve-error.h
+++ b/src/lib-sieve/sieve-error.h
@@ -48,7 +48,9 @@ inline static void sieve_error
 	va_list args;
 	va_start(args, fmt);
 	
-	T_FRAME(sieve_verror(ehandler, location, fmt, args));
+	T_BEGIN {
+		sieve_verror(ehandler, location, fmt, args);
+	} T_END;
 	
 	va_end(args);
 }
@@ -60,8 +62,10 @@ inline static void sieve_warning
 	va_list args;
 	va_start(args, fmt);
 	
-	T_FRAME(sieve_vwarning(ehandler, location, fmt, args));
-	
+	T_BEGIN {
+		sieve_vwarning(ehandler, location, fmt, args);
+	} T_END;
+
 	va_end(args);
 }
 
@@ -72,7 +76,9 @@ inline static void sieve_info
 	va_list args;
 	va_start(args, fmt);
 	
-	T_FRAME(sieve_vinfo(ehandler, location, fmt, args));
+	T_BEGIN {
+		sieve_vinfo(ehandler, location, fmt, args);
+	} T_END;
 	
 	va_end(args);
 }
@@ -84,7 +90,9 @@ inline static void sieve_critical
 	va_list args;
 	va_start(args, fmt);
 	
-	T_FRAME(sieve_vcritical(ehandler, location, fmt, args));
+	T_BEGIN { 
+		sieve_vcritical(ehandler, location, fmt, args);
+	} T_END;
 	
 	va_end(args);
 }
diff --git a/src/lib-sieve/sieve-generator.c b/src/lib-sieve/sieve-generator.c
index 082b5ca63..edc87c55f 100644
--- a/src/lib-sieve/sieve-generator.c
+++ b/src/lib-sieve/sieve-generator.c
@@ -337,13 +337,13 @@ bool sieve_generate_block
 	bool result = TRUE;
 	struct sieve_ast_node *command;
 
-	T_FRAME(	
+	T_BEGIN {	
 		command = sieve_ast_command_first(block);
 		while ( result && command != NULL ) {	
 			result = sieve_generate_command(generator, command);	
 			command = sieve_ast_command_next(command);
 		}		
-	);
+	} T_END;
 	
 	return result;
 }
diff --git a/src/lib-sieve/sieve-interpreter.c b/src/lib-sieve/sieve-interpreter.c
index b07e23fbc..f268e95e4 100644
--- a/src/lib-sieve/sieve-interpreter.c
+++ b/src/lib-sieve/sieve-interpreter.c
@@ -206,9 +206,9 @@ void sieve_runtime_error
 	va_list args;
 	
 	va_start(args, fmt);
-	T_FRAME(
+	T_BEGIN {
 		sieve_verror(runenv->interp->ehandler, _get_location(runenv), fmt, args); 
-	);
+	} T_END;
 	va_end(args);
 }
 
@@ -218,9 +218,9 @@ void sieve_runtime_warning
 	va_list args;
 	
 	va_start(args, fmt);
-	T_FRAME(
+	T_BEGIN {
 		sieve_vwarning(runenv->interp->ehandler, _get_location(runenv), fmt, args);
-	); 
+	} T_END; 
 	va_end(args);
 }
 
@@ -230,9 +230,9 @@ void sieve_runtime_log
 	va_list args;
 	
 	va_start(args, fmt);
-	T_FRAME(
+	T_BEGIN {
 		sieve_vinfo(runenv->interp->ehandler, _get_location(runenv), fmt, args); 
-	);
+	} T_END;
 	va_end(args);
 }
 
diff --git a/src/lib-sieve/sieve-lexer.c b/src/lib-sieve/sieve-lexer.c
index 287d787ad..0e692bc28 100644
--- a/src/lib-sieve/sieve-lexer.c
+++ b/src/lib-sieve/sieve-lexer.c
@@ -51,10 +51,12 @@ inline static void sieve_lexer_error
 	va_list args;
 	va_start(args, fmt);
 
-	T_FRAME(sieve_verror(lexer->ehandler, 
-		t_strdup_printf("%s:%d", sieve_script_name(lexer->script), 
-			lexer->current_line),
-		fmt, args));
+	T_BEGIN {
+		sieve_verror(lexer->ehandler, 
+			t_strdup_printf("%s:%d", sieve_script_name(lexer->script), 
+				lexer->current_line),
+			fmt, args);
+	} T_END;
 		
 	va_end(args);
 }
@@ -65,10 +67,12 @@ inline static void sieve_lexer_warning
 	va_list args;
 	va_start(args, fmt);
 
-	T_FRAME(sieve_vwarning(lexer->ehandler, 
-		t_strdup_printf("%s:%d", sieve_script_name(lexer->script), 
+	T_BEGIN { 
+		sieve_vwarning(lexer->ehandler, 
+			t_strdup_printf("%s:%d", sieve_script_name(lexer->script), 
 			lexer->current_line),
-		fmt, args));
+			fmt, args);
+	} T_END;
 		
 	va_end(args);
 }
diff --git a/src/lib-sieve/sieve-parser.c b/src/lib-sieve/sieve-parser.c
index 48565392a..cb52f0be7 100644
--- a/src/lib-sieve/sieve-parser.c
+++ b/src/lib-sieve/sieve-parser.c
@@ -39,11 +39,13 @@ inline static void sieve_parser_error
 	/* Don't report a parse error if the lexer complained already */ 
 	if ( sieve_lexer_current_token(parser->lexer) != STT_ERROR )  
 	{
-		T_FRAME(sieve_verror(parser->ehandler, 
-			t_strdup_printf("%s:%d", 
-			sieve_script_name(parser->script),
-			sieve_lexer_current_line(parser->lexer)),
-			fmt, args)); 
+		T_BEGIN {
+			sieve_verror(parser->ehandler, 
+				t_strdup_printf("%s:%d", 
+				sieve_script_name(parser->script),
+				sieve_lexer_current_line(parser->lexer)),
+				fmt, args);
+		} T_END; 
 	}
 	
 	va_end(args);
@@ -55,11 +57,13 @@ inline static void sieve_parser_warning
 	va_list args;
 	va_start(args, fmt);
 
-	T_FRAME(sieve_vwarning(parser->ehandler, 
-		t_strdup_printf("%s:%d", 
-		sieve_script_name(parser->script),
-		sieve_lexer_current_line(parser->lexer)),
-		fmt, args));
+	T_BEGIN	{
+		sieve_vwarning(parser->ehandler, 
+			t_strdup_printf("%s:%d", 
+			sieve_script_name(parser->script),
+			sieve_lexer_current_line(parser->lexer)),
+			fmt, args);
+	} T_END;
 		
 	va_end(args);
 } 
diff --git a/src/lib-sieve/sieve-validator.c b/src/lib-sieve/sieve-validator.c
index 80735e93a..45a7ab7a8 100644
--- a/src/lib-sieve/sieve-validator.c
+++ b/src/lib-sieve/sieve-validator.c
@@ -878,13 +878,13 @@ static bool sieve_validate_block(struct sieve_validator *validator, struct sieve
 	bool result = TRUE;
 	struct sieve_ast_node *command;
 
-	T_FRAME(	
+	T_BEGIN {	
 		command = sieve_ast_command_first(block);
 		while ( command != NULL ) {	
 			result = sieve_validate_command(validator, command) && result;	
 			command = sieve_ast_command_next(command);
 		}		
-	);
+	} T_END;
 	
 	return result;
 }
diff --git a/src/lib-sieve/sieve.c b/src/lib-sieve/sieve.c
index c0d269268..3062207fd 100644
--- a/src/lib-sieve/sieve.c
+++ b/src/lib-sieve/sieve.c
@@ -145,7 +145,7 @@ struct sieve_binary *sieve_open
 	if ( script == NULL )
 		return NULL;
 
-	T_FRAME(
+	T_BEGIN {
 		binpath = sieve_script_binpath(script);	
 		sbin = sieve_binary_open(binpath, script);
 	
@@ -165,7 +165,7 @@ struct sieve_binary *sieve_open
 			if ( sbin != NULL )
 				(void) sieve_binary_save(sbin, binpath);	
 		}
-	);
+	} T_END;
 	
 	sieve_script_unref(&script);
 
diff --git a/src/plugins/lda-sieve/lda-sieve-plugin.c b/src/plugins/lda-sieve/lda-sieve-plugin.c
index b79714b45..2e11ec30d 100644
--- a/src/plugins/lda-sieve/lda-sieve-plugin.c
+++ b/src/plugins/lda-sieve/lda-sieve-plugin.c
@@ -151,10 +151,10 @@ static int lda_sieve_deliver_mail
 	if (getenv("DEBUG") != NULL)
 		i_info("sieve: Using sieve path: %s", script_path);
 
-	T_FRAME(
+	T_BEGIN { 
 		ret = lda_sieve_run(namespaces, mail, script_path, destaddr, 
-			getenv("USER"), mailbox)
-	);
+			getenv("USER"), mailbox);
+	} T_END;
 
 	return ( ret >= 0 ? 1 : -1 ); 
 }
-- 
GitLab