make sets work

This commit is contained in:
anon 2023-11-15 16:13:44 +01:00
parent b9ab4ab13c
commit bd44d470a8
2 changed files with 18 additions and 3 deletions

View File

@ -1,5 +1,6 @@
const static int EXIT_EARLY_SUCCESS = 400;
enum {
UNKNOWN_OPTION = 1,
IO_ERROR = 2,
UNKNOWN_OPTION = 1,
IO_ERROR = 2,
UNKNOWN_SET = 3,
};

View File

@ -5,6 +5,7 @@
#include <libgen.h>
#include <vector>
#include <string>
#include <map>
#include "cli.h"
#include "globals.h"
@ -25,6 +26,10 @@ char * output = NULL;
char * input = NULL;
const char * const csml_extension = ".csml";
const std::map<const char * const, std::vector<std::string>> sets = {
{"$html", {"style", "script"}},
};
enum class input_type_t {
CSML,
XML,
@ -116,7 +121,16 @@ signed main(int argc, char * * argv) {
char * data = strtok(argv[n], delimiter);
int i = 0;
do {
ignore_list.emplace_back(data);
if (data[0] == '$') {
const auto &&set = sets.find("$html");
[[ likely ]] if (set != sets.end()) {
ignore_list.insert(ignore_list.begin(), set->second.begin(), set->second.end());
} else {
exit(UNKNOWN_SET);
}
} else [[ likely ]] {
ignore_list.emplace_back(data);
}
++i;
} while((data = strtok(NULL, delimiter), data));
} else if (!strcmp(argv[n], "-o")) {