This rewords the comments to be a bit more clear in what is happening.
---
 src/hlua.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/hlua.c b/src/hlua.c
index 1c87daae3..2d29d08f0 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -4692,8 +4692,11 @@ static int hlua_http_new(lua_State *L, struct hlua_txn 
*txn)
        return 1;
 }
 
-/* This function creates ans returns an array of HTTP headers.
- * This function does not fails. It is used as wrapper with the
+/* This function creates and returns a table indexed by HTTP header
+ * names. The values are arrays containing one entry each time the
+ * header was encountered.
+ *
+ * This function does not fail. It is used as wrapper with the
  * 2 following functions.
  */
 __LJMP static int hlua_http_get_headers(lua_State *L, struct hlua_txn *htxn, 
struct http_msg *msg)
@@ -4726,28 +4729,28 @@ __LJMP static int hlua_http_get_headers(lua_State *L, 
struct hlua_txn *htxn, str
                /* Check for existing entry:
                 * assume that the table is on the top of the stack, and
                 * push the key in the stack, the function lua_gettable()
-                * perform the lookup.
+                * performs the lookup.
                 */
                lua_pushlstring(L, n.ptr, n.len);
                lua_gettable(L, -2);
 
                switch (lua_type(L, -1)) {
                        case LUA_TNIL:
-                               /* Table not found, create it. */
+                               /* Header not yet encountered, create array. */
                                lua_pop(L, 1); /* remove the nil value. */
                                lua_pushlstring(L, n.ptr, n.len);  /* push the 
header name as key. */
-                               lua_newtable(L); /* create and push empty 
table. */
+                               lua_newtable(L); /* create and push empty 
array. */
                                lua_pushlstring(L, v.ptr, v.len); /* push 
header value. */
-                               lua_rawseti(L, -2, 0); /* index header value 
(pop it). */
-                               lua_rawset(L, -3); /* index new table with 
header name (pop the values). */
+                               lua_rawseti(L, -2, 0); /* add header value to 
the newly created array */
+                               lua_rawset(L, -3); /* add the array to the 
table indexed by header name. */
                                break;
 
                        case LUA_TTABLE:
-                               /* Entry found: push the value in the table. */
+                               /* Header encountered, add the value to the 
array. */
                                len = lua_rawlen(L, -1);
                                lua_pushlstring(L, v.ptr, v.len); /* push 
header value. */
                                lua_rawseti(L, -2, len+1); /* index header 
value (pop it). */
-                               lua_pop(L, 1); /* remove the table (it is 
stored in the main table). */
+                               lua_pop(L, 1); /* remove the array (it is 
stored in the main table). */
                                break;
 
                        default:
-- 
2.23.0


Reply via email to