diff options
| author | _ov4 <ov4@ov4.org> | 2026-09-21 04:50:06 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-09-21 04:50:06 +0000 |
| commit | 1c630655b2beb0f4b84fb7e1bc034ba62520be37 (patch) | |
| tree | e90e70c425813df29c8bbd5c1e84ef22f4e4a176 /src/lang_analysis/parseline.cc | |
| parent | 9f5936bf64deb625a27259d778937e281ca19cea (diff) | |
fix name typo, and remove outdated parse
Diffstat (limited to 'src/lang_analysis/parseline.cc')
| -rw-r--r-- | src/lang_analysis/parseline.cc | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/lang_analysis/parseline.cc b/src/lang_analysis/parseline.cc new file mode 100644 index 0000000..d71cf6f --- /dev/null +++ b/src/lang_analysis/parseline.cc @@ -0,0 +1,80 @@ +#include "lang_analysis/parseline.h" + +#include <vector> + +#include "lang_analysis/enum_type.h" +#include "util/string.h" + +using namespace std; + +namespace ov4 +{ + +char **parseline(const std::string &s) +{ + guard_type guard = GUARD_OFF; + vector<string> v; + size_t len = s.size(); + string prev_str = ""; + char c; + + for (size_t i = 0; i < len; i++) + { + + c = s[i]; + if (c == ' ' && guard == GUARD_OFF) continue; + + if (c == '\'' || c == '\"') + { + + // turn on GUARD + if (guard == GUARD_OFF) + { + guard = (c == '\'') ? GUARD_STRONG : GUARD_WEAK; + if (i+1 == len) + { + v.push_back(prev_str); + prev_str = ""; + } + continue; + } + // turn off + else if (guard == GUARD_STRONG && c == '\'') + { + guard = GUARD_OFF; + if (i+1 == len) + { + v.push_back(prev_str); + prev_str = ""; + } + continue; + } + // turn off + else if (guard == GUARD_WEAK && c == '\"') + { + guard = GUARD_OFF; + if (i+1 == len) + { + v.push_back(prev_str); + prev_str = ""; + } + continue; + } + // if this (single/double) quotation mark is guarded + // it should be saved + } + + prev_str += c; + + if ((i+1 >= len) || (s[i+1] == ' ' && guard == GUARD_OFF)) + { + v.push_back(prev_str); + prev_str = ""; + continue; + } + } + + return string2argv_alloc(v); +} + +} |
