commit 304b24c1b32ce012b4950234191a319a0deca81d
parent c9dd4d28a0e39c87c8678f59638637d486366e1a
Author: Robin <kroekerrobin@gmail.com>
Date: Sun, 13 Aug 2023 21:38:24 +0200
Rename variable
Diffstat:
| M | htex.c | | | 8 | ++++---- |
| M | html.c | | | 47 | +++++------------------------------------------ |
| M | html.h | | | 2 | +- |
3 files changed, 10 insertions(+), 47 deletions(-)
diff --git a/htex.c b/htex.c
@@ -8,9 +8,9 @@
#include "lib.c"
#include "html.c"
-struct filter_opts *parseFilterOpts(const char *pattern)
+struct find_opts *parseFilterOpts(const char *pattern)
{
- struct filter_opts *opt = malloc(sizeof(struct filter_opts));
+ struct find_opts *opt = malloc(sizeof(struct find_opts));
opt->out = OUT_OUTER_HTML;
opt->tag = malloc(sizeof(char));
opt->tag[0] = 0;
@@ -120,7 +120,7 @@ struct filter_opts *parseFilterOpts(const char *pattern)
return opt;
}
-void freeOpts(struct filter_opts *opt)
+void freeOpts(struct find_opts *opt)
{
free(opt->tag);
free(opt->attr);
@@ -194,7 +194,7 @@ int main(int argc, char *argv[])
return 0;
}
}
- struct filter_opts *options = parseFilterOpts(searchPattern);
+ struct find_opts *options = parseFilterOpts(searchPattern);
options->isExcept = isExcept;
if (isInnerHtml)
options->out = OUT_INNER_HTML;
diff --git a/html.c b/html.c
@@ -587,7 +587,7 @@ void freeTagList(struct tag_list *t)
free(t);
}
-void findTag(struct tag *tag, struct filter_opts *opt, struct tag_list *foundTags)
+void findTag(struct tag *tag, struct find_opts *opt, struct tag_list *foundTags)
{
bool matchesTag = false;
bool matchesAttrKey = false;
@@ -675,31 +675,15 @@ void printHtml(struct tag *t, int indent)
void printTag(char *text, struct tag *t, enum output_type out, struct tag_list *foundTags)
{
- // bool doPrint = true;
switch (out)
{
case OUT_INNER_HTML:
- /* for (int i=t->_innerHtmlBeginOffset; i<t->_innerHtmlEndOffset; i++)
- {
- doPrint = true;
- for (int k=0; k<foundTags->len; k++)
- {
- if (
- foundTags->tags[k]->_innerHtmlBeginOffset < i &&
- foundTags->tags[k]->_innerHtmlEndOffset > i
- )
- doPrint = false;
- }
- if (doPrint)
- putchar(text[i]);
- } */
break;
case OUT_OUTER_HTML:
break;
case OUT_INNER_TEXT:
break;
}
- putchar('\n');
/* unsigned int p = *(unsigned int *)t;
unsigned int cp;
bool isMatch = false;
@@ -735,21 +719,13 @@ void printResult
(
char *text,
struct tag *rootTag,
- struct filter_opts *opts,
+ struct find_opts *opts,
struct tag_list *foundTags
)
{
if (opts->isExcept)
{
- /* printf("len: %ld\n", foundTags->len);
- char *trimmedText = NULL;
- for (int i=0; i<foundTags->len; i++)
- {
- trimmedText = trim(getOuterHtml(text, foundTags->tags[i]));
- printf("%s\n", trimmedText);
- free(trimmedText);
- } */
- printTag(text, rootTag, opts->out, foundTags);
+ // printTag(text, rootTag, opts->out, foundTags);
}
else
{
@@ -780,20 +756,7 @@ void printResult
}
}
-void printEverything(struct tag *t, enum output_type out)
-{
- switch (out)
- {
- case OUT_INNER_HTML:
- break;
- case OUT_OUTER_HTML:
- break;
- case OUT_INNER_TEXT:
- break;
- }
-}
-
-bool existFindPattern(struct filter_opts *opts)
+bool existFindPattern(struct find_opts *opts)
{
if (strlen(opts->tag) > 0)
return true;
@@ -804,7 +767,7 @@ bool existFindPattern(struct filter_opts *opts)
return false;
}
-void filterHtml(char *text, struct filter_opts *opts)
+void filterHtml(char *text, struct find_opts *opts)
{
struct tag_list *tagList = initTagList();
struct tag_list *foundTags = initTagList();
diff --git a/html.h b/html.h
@@ -27,7 +27,7 @@ enum output_type
OUT_INNER_TEXT
};
-struct filter_opts
+struct find_opts
{
char *tag;
char *attr;