aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-08-09 12:16:04 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2025-08-09 12:16:04 +0530
commit1acd74f76716c078015700b04c5e1c7b1b4f7556 (patch)
treeef18042a3631ecda0cf11f6affd184e50895f931
parent66c403c79e64dbe96fc080ff74e87db2102f93f3 (diff)
lexer,engine: use strlen(content) instead of length
I can't remember why I added length instead of using strlen(content). If this breaks anything it would be a pain to debug. In my little testing though, it seems to be working fine.
-rw-r--r--include/lexer.h2
-rw-r--r--src/engine/contentfor.c7
-rw-r--r--src/lexer.c2
3 files changed, 3 insertions, 8 deletions
diff --git a/include/lexer.h b/include/lexer.h
index ae64759..f7a851a 100644
--- a/include/lexer.h
+++ b/include/lexer.h
@@ -46,11 +46,9 @@ typedef struct {
void *operands;
} directive_t;
-/* TODO: strlen(content) instead of length? */
typedef struct {
char *key;
char *content;
- size_t length;
} contentfor_operand_t;
typedef struct {
diff --git a/src/engine/contentfor.c b/src/engine/contentfor.c
index a30c3c8..76aae79 100644
--- a/src/engine/contentfor.c
+++ b/src/engine/contentfor.c
@@ -31,9 +31,8 @@ handle_contentfor(char **buffer,
list_t *content_headers)
{
contentfor_operand_t *operand = directive->operands;
- contentfor_operand_t new_operand = { .content = strdup(operand->content),
- .key = strdup(operand->key),
- .length = operand->length };
+ contentfor_operand_t new_operand
+ = { .content = strdup(operand->content), .key = strdup(operand->key) };
list_add(content_headers, &new_operand);
#ifdef DEBUG
@@ -48,7 +47,7 @@ handle_contentfor(char **buffer,
"%.*s%s",
match->offset,
temp_buffer,
- temp_buffer + operand->length);
+ temp_buffer + strlen(operand->content));
free(temp_buffer);
}
diff --git a/src/lexer.c b/src/lexer.c
index 8947687..be5f8e6 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -191,8 +191,6 @@ lexer_handle_contentfor(directive_t *directive,
}
operands->content = strndup(buffer, new_match->offset);
- operands->length
- = match->offset + match->length + new_match->offset + new_match->length;
free(new_match);
directive->operands = operands;