[pkg-lighttpd] r584 - lighttpd/trunk/src

Arno Töll atoell-guest at alioth.debian.org
Wed Nov 21 13:44:15 UTC 2012


Author: atoell-guest
Date: 2012-11-21 13:44:15 +0000 (Wed, 21 Nov 2012)
New Revision: 584

Modified:
   lighttpd/trunk/src/request.c
Log:
Err. Pop patches before committing

Modified: lighttpd/trunk/src/request.c
===================================================================
--- lighttpd/trunk/src/request.c	2012-11-21 13:43:22 UTC (rev 583)
+++ lighttpd/trunk/src/request.c	2012-11-21 13:44:15 UTC (rev 584)
@@ -209,11 +209,9 @@
 #endif
 
 static int http_request_split_value(array *vals, buffer *b) {
+	char *s;
 	size_t i;
 	int state = 0;
-
-	const char *current;
-	const char *token_start = NULL, *token_end = NULL;
 	/*
 	 * parse
 	 *
@@ -224,52 +222,53 @@
 
 	if (b->used == 0) return 0;
 
-	current = b->ptr;
-	for (i =  0; i < b->used; ++i, ++current) {
+	s = b->ptr;
+
+	for (i =0; i < b->used - 1; ) {
+		char *start = NULL, *end = NULL;
 		data_string *ds;
 
 		switch (state) {
-		case 0: /* find start of a token */
-			switch (*current) {
-			case ' ':
-			case '\t': /* skip white space */
-			case ',': /* skip empty token */
-				break;
-			case '\0': /* end of string */
-				return 0;
-			default:
-				/* found real data, switch to state 1 to find the end of the token */
-				token_start = token_end = current;
-				state = 1;
-				break;
-			}
+		case 0: /* ws */
+
+			/* skip ws */
+			for (; (*s == ' ' || *s == '\t') && i < b->used - 1; i++, s++);
+
+
+			state = 1;
 			break;
-		case 1: /* find end of token and last non white space character */
-			switch (*current) {
-			case ' ':
-			case '\t':
-				/* space - don't update token_end */
-				break;
-			case ',':
-			case '\0': /* end of string also marks the end of a token */
-				if (NULL == (ds = (data_string *)array_get_unused_element(vals, TYPE_STRING))) {
-					ds = data_string_init();
-				}
+		case 1: /* value */
+			start = s;
 
-				buffer_copy_string_len(ds->value, token_start, token_end-token_start+1);
-				array_insert_unique(vals, (data_unset *)ds);
+			for (; *s != ',' && i < b->used - 1; i++, s++);
+			if (start == s) break; /* empty fields are skipped */
+			end = s - 1;
 
+			for (; end > start && (*end == ' ' || *end == '\t'); end--);
+			if (start == end) break; /* empty fields are skipped */
+
+			if (NULL == (ds = (data_string *)array_get_unused_element(vals, TYPE_STRING))) {
+				ds = data_string_init();
+			}
+
+			buffer_copy_string_len(ds->value, start, end-start+1);
+			array_insert_unique(vals, (data_unset *)ds);
+
+			if (*s == ',') {
 				state = 0;
-				break;
-			default:
-				/* no white space, update token_end to include current character */
-				token_end = current;
-				break;
+				i++;
+				s++;
+			} else {
+				/* end of string */
+
+				state = 2;
 			}
 			break;
+		default:
+			i++;
+			break;
 		}
 	}
-
 	return 0;
 }
 




More information about the pkg-lighttpd-maintainers mailing list