htex

simple incorrect html parser
git clone git://git.relim.de/htex.git
Log | Files | Refs | README

commit ddc4977563c877502114bcf5163a12dfa5c3a99e
parent bc49f38e4f5f5e58d8170782f205a7f8e9435eb6
Author: Robin <kroekerrobin@gmail.com>
Date:   Wed,  3 Apr 2024 11:16:48 +0200

Put else statements on previous line

Diffstat:
Mhtex.c | 9+++------
Mhtml.c | 9+++------
2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/htex.c b/htex.c @@ -79,8 +79,7 @@ struct find_opts *parseFilterOpts(const char *pattern) opt->key[0] = 'i'; opt->key[1] = 'd'; opt->key[2] = 0; - } - else if (isClassValue) { + } else if (isClassValue) { free(opt->key); opt->key = NULL; free(opt->attr); @@ -93,8 +92,7 @@ struct find_opts *parseFilterOpts(const char *pattern) opt->key[3] = 's'; opt->key[4] = 's'; opt->key[5] = 0; - } - else { + } else { free(opt->tag); opt->tag = attrOrTag; if (av > 0) { @@ -183,8 +181,7 @@ int main(int argc, char *argv[]) if (argc == optind+1) { searchPattern = argv[argc-1]; text = readFile(stdin); - } - else if (argc == optind+2) { + } else if (argc == optind+2) { searchPattern = argv[argc-2]; char *filepath = argv[argc-1]; FILE *fp = fopen(filepath, "r"); diff --git a/html.c b/html.c @@ -200,8 +200,7 @@ size_t parseDoctype(const char *text) for (off = 0; off<len; off += ret) { if ((ret = grapheme_decode_utf8(text+off, len-off, &cp)) > len-off) { fprintf(stderr, "parseDoctype.grapheme_decode_utf8 failed.\n"); - } - else { + } else { switch (state) { case DSTATE_TEXT: if (cp == LESS_THAN_SIGN) { @@ -222,8 +221,7 @@ size_t parseDoctype(const char *text) case DSTATE_DTYPE_OR_COMMENT: if (cp == HYPHEN_MINUS) { goto CLEANUP; - } - else { + } else { doctype = stringCat(doctype, cpToChars(cp, ret)); state = DSTATE_DTYPE; break; @@ -236,8 +234,7 @@ size_t parseDoctype(const char *text) grapheme_to_lowercase_utf8(doctype, dlen, lowerDoctype, dlen); if (strcmp(lowerDoctype, "doctype") == 0) { state = DSTATE_TEXT; - } - else { + } else { offset = -1; goto CLEANUP; }