saait

Simple static page generator
git clone https://git.sinitax.com/codemadness/saait
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit 534f2fd002afd451006265e7630ea1f052bd1db6
parent 2e53b2efbf0ccdd42bd2f5fa5c432823970c90e8
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri, 25 Nov 2016 16:44:32 +0100

no static keysize

Diffstat:
Msaait.c | 21++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/saait.c b/saait.c @@ -469,8 +469,7 @@ void writepage(FILE *fp, const char *filename, struct config *c, char *s) { struct variable *var, *v; - /* TODO: revert static key size */ - char key[64], escape, *e, *value; + char *key, escape, *e, *value; size_t keylen, line = 0; int op; @@ -502,33 +501,29 @@ writepage(FILE *fp, const char *filename, struct config *c, char *s) } /* variable case */ + for (; *s && isspace(*s); s++) + ; + key = s; for (keylen = 0; *s; s++) { if (*s == '}' || *s == '@') break; - if (!keylen && isspace(*s)) - continue; - if (keylen + 1 >= sizeof(key)) { - fprintf(stderr, "key too long: %s\n", key); - exit(1); - } - key[keylen++] = *s; - key[keylen] = '\0'; + keylen++; } /* trim right whitespace */ for (; keylen && isspace(key[keylen - 1]); ) - key[keylen--] = '\0'; + keylen--; /* page config variables */ v = NULL; for (var = c ? c->vars: NULL; var && !v; var = var->next) { - if (!strcmp(var->key, key)) { + if (keylen == strlen(var->key) && !strncmp(var->key, key, keylen)) { v = var; break; } } /* global config variables */ for (var = global ? global->vars : NULL; var && !v; var = var->next) { - if (!strcmp(var->key, key)) { + if (keylen == strlen(var->key) && !strncmp(var->key, key, keylen)) { v = var; break; }