[dovecot-cvs] dovecot/src/lib var-expand.c,1.2,1.3

cras at dovecot.org cras at dovecot.org
Mon Jul 26 19:39:21 EEST 2004


Update of /home/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv20601/src/lib

Modified Files:
	var-expand.c 
Log Message:
Added support for %offset.width format in variables.



Index: var-expand.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/var-expand.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- var-expand.c	24 May 2004 22:33:50 -0000	1.2
+++ var-expand.c	26 Jul 2004 16:39:18 -0000	1.3
@@ -23,7 +23,7 @@
         const struct var_expand_modifier *m;
         const struct var_expand_table *t;
 	const char *var;
-	unsigned int width;
+	unsigned int offset, width;
 	const char *(*modifier)(const char *);
 
 	for (; *str != '\0'; str++) {
@@ -31,12 +31,26 @@
 			str_append_c(dest, *str);
 		else {
 			str++;
+
+			/* [<offset>.]<width>[<modifier>]<variable> */
 			width = 0;
 			while (*str >= '0' && *str <= '9') {
 				width = width*10 + (*str - '0');
 				str++;
 			}
 
+			if (*str != '.')
+				offset = 0;
+			else {
+				offset = width;
+				width = 0;
+				str++;
+				while (*str >= '0' && *str <= '9') {
+					width = width*10 + (*str - '0');
+					str++;
+				}
+			}
+
 			modifier = NULL;
 			for (m = modifiers; m->key != '\0'; m++) {
 				if (m->key == *str) {
@@ -64,6 +78,8 @@
 			}
 
 			if (var != NULL) {
+				for (; *var != '\0' && offset > 0; offset--)
+					var++;
 				if (modifier != NULL)
 					var = modifier(var);
 				if (width == 0)



More information about the dovecot-cvs mailing list