diff --git a/parser/libapparmor_re/aare_rules.cc b/parser/libapparmor_re/aare_rules.cc index f5be7418f..a869756f6 100644 --- a/parser/libapparmor_re/aare_rules.cc +++ b/parser/libapparmor_re/aare_rules.cc @@ -257,7 +257,7 @@ void *aare_rules::create_dfa(size_t *size, int *min_match_len, dfaflags_t flags) if (flags & DFA_DUMP_GRAPH) dfa.dump_dot_graph(cerr); - map eq; + map eq; if (flags & DFA_CONTROL_EQUIV) { eq = dfa.equivalence_classes(flags); dfa.apply_equivalence_classes(eq); diff --git a/parser/libapparmor_re/chfa.cc b/parser/libapparmor_re/chfa.cc index 773a1866d..c34c7d31a 100644 --- a/parser/libapparmor_re/chfa.cc +++ b/parser/libapparmor_re/chfa.cc @@ -49,7 +49,7 @@ void CHFA::init_free_list(vector > &free_list, /** * new Construct the transition table. */ -CHFA::CHFA(DFA &dfa, map &eq, dfaflags_t flags): eq(eq) +CHFA::CHFA(DFA &dfa, map &eq, dfaflags_t flags): eq(eq) { if (flags & DFA_DUMP_TRANS_PROGRESS) fprintf(stderr, "Compressing HFA:\r"); @@ -63,7 +63,7 @@ CHFA::CHFA(DFA &dfa, map &eq, dfaflags_t flags): eq(eq) max_eq = 255; else { max_eq = 0; - for (map::iterator i = eq.begin(); + for (map::iterator i = eq.begin(); i != eq.end(); i++) { if (i->second > max_eq) max_eq = i->second; @@ -291,7 +291,7 @@ void CHFA::dump(ostream &os) if (eq.size()) os << offs; else - os << (uchar) offs; + os << (transchar) offs; } os << "\n"; } @@ -379,7 +379,7 @@ void CHFA::flex_table(ostream &os, const char *name) vector equiv_vec; if (eq.size()) { equiv_vec.resize(256); - for (map::iterator i = eq.begin(); i != eq.end(); i++) { + for (map::iterator i = eq.begin(); i != eq.end(); i++) { equiv_vec[i->first.c] = i->second.c; } } diff --git a/parser/libapparmor_re/chfa.h b/parser/libapparmor_re/chfa.h index 88f6820dc..445987f19 100644 --- a/parser/libapparmor_re/chfa.h +++ b/parser/libapparmor_re/chfa.h @@ -36,7 +36,7 @@ class CHFA { typedef vector > DefaultBase; typedef vector > NextCheck; public: - CHFA(DFA &dfa, map &eq, dfaflags_t flags); + CHFA(DFA &dfa, map &eq, dfaflags_t flags); void dump(ostream & os); void flex_table(ostream &os, const char *name); void init_free_list(vector > &free_list, @@ -52,8 +52,8 @@ class CHFA { DefaultBase default_base; NextCheck next_check; map num; - map &eq; - uchar max_eq; + map &eq; + transchar max_eq; size_t first_free; unsigned int chfaflags; }; diff --git a/parser/libapparmor_re/expr-tree.cc b/parser/libapparmor_re/expr-tree.cc index 6eaf1e845..351f815dc 100644 --- a/parser/libapparmor_re/expr-tree.cc +++ b/parser/libapparmor_re/expr-tree.cc @@ -41,7 +41,7 @@ /* Use a single static EpsNode as it carries no node specific information */ EpsNode epsnode; -ostream &operator<<(ostream &os, uchar c) +ostream &operator<<(ostream &os, transchar c) { const char *search = "\a\033\f\n\r\t|*+[](). ", *replace = "aefnrt|*+[](). ", *s; diff --git a/parser/libapparmor_re/expr-tree.h b/parser/libapparmor_re/expr-tree.h index df527dd88..3638717cd 100644 --- a/parser/libapparmor_re/expr-tree.h +++ b/parser/libapparmor_re/expr-tree.h @@ -45,38 +45,38 @@ using namespace std; -class uchar { +class transchar { public: short c; - uchar(unsigned char a): c((unsigned short) a) {} - uchar(const uchar &a): c(a.c) {} - uchar(): c(0) {} + transchar(unsigned char a): c((unsigned short) a) {} + transchar(const transchar &a): c(a.c) {} + transchar(): c(0) {} - bool operator==(const uchar &rhs) const { + bool operator==(const transchar &rhs) const { return this->c == rhs.c; } bool operator==(const int &rhs) const { return this->c == rhs; } - bool operator!=(const uchar &rhs) const { + bool operator!=(const transchar &rhs) const { return this->c != rhs.c; } - bool operator>(const uchar &rhs) const { + bool operator>(const transchar &rhs) const { return this->c > rhs.c; } - bool operator<(const uchar &rhs) const { + bool operator<(const transchar &rhs) const { return this->c < rhs.c; } - bool operator<=(const uchar &rhs) const { + bool operator<=(const transchar &rhs) const { return this->c <= rhs.c; } - uchar &operator++() { // prefix + transchar &operator++() { // prefix (this->c)++; return *this; } - uchar operator++(int) { // postfix - uchar tmp(*this); + transchar operator++(int) { // postfix + transchar tmp(*this); (this->c)++; return tmp; } @@ -85,9 +85,9 @@ public: class Chars { public: - set chars; + set chars; - typedef set::iterator iterator; + typedef set::iterator iterator; iterator begin() { return chars.begin(); } iterator end() { return chars.end(); } @@ -101,23 +101,23 @@ public: { return chars.size(); } - iterator find(const uchar &key) + iterator find(const transchar &key) { return chars.find(key); } - pair insert(uchar c) + pair insert(transchar c) { return chars.insert(c); } pair insert(char c) { - uchar tmp(c); + transchar tmp(c); return chars.insert(tmp); } }; -ostream &operator<<(ostream &os, uchar c); +ostream &operator<<(ostream &os, transchar c); /* Compute the union of two sets. */ template set operator+(const set &a, const set &b) @@ -151,12 +151,12 @@ ostream &operator<<(ostream &os, const NodeSet &state); * enumerating all the explicit tranitions for default matches. */ typedef struct Cases { - typedef map::iterator iterator; + typedef map::iterator iterator; iterator begin() { return cases.begin(); } iterator end() { return cases.end(); } Cases(): otherwise(0) { } - map cases; + map cases; NodeSet *otherwise; } Cases; @@ -334,7 +334,7 @@ public: /* Match one specific character (/c/). */ class CharNode: public CNode { public: - CharNode(uchar c): c(c) { } + CharNode(transchar c): c(c) { } void follow(Cases &cases) { NodeSet **x = &cases.cases[c]; @@ -370,7 +370,7 @@ public: bool contains_null() { return c == 0; } - uchar c; + transchar c; }; /* Match a set of characters (/[abc]/). */ diff --git a/parser/libapparmor_re/hfa.cc b/parser/libapparmor_re/hfa.cc index 82d6eea8d..fbda75736 100644 --- a/parser/libapparmor_re/hfa.cc +++ b/parser/libapparmor_re/hfa.cc @@ -1160,10 +1160,10 @@ void DFA::dump_dot_graph(ostream & os) * Compute character equivalence classes in the DFA to save space in the * transition table. */ -map DFA::equivalence_classes(dfaflags_t flags) +map DFA::equivalence_classes(dfaflags_t flags) { - map classes; - uchar next_class = 1; + map classes; + transchar next_class = 1; for (Partition::iterator i = states.begin(); i != states.end(); i++) { /* Group edges to the same next state together */ @@ -1174,28 +1174,28 @@ map DFA::equivalence_classes(dfaflags_t flags) for (map::iterator j = node_sets.begin(); j != node_sets.end(); j++) { /* Group edges to the same next state together by class */ - map node_classes; + map node_classes; bool class_used = false; for (Chars::iterator k = j->second.begin(); k != j->second.end(); k++) { - pair::iterator, bool> x = classes.insert(make_pair(*k, next_class)); + pair::iterator, bool> x = classes.insert(make_pair(*k, next_class)); if (x.second) class_used = true; - pair::iterator, bool> y = node_classes.insert(make_pair(x.first->second, Chars())); + pair::iterator, bool> y = node_classes.insert(make_pair(x.first->second, Chars())); y.first->second.insert(*k); } if (class_used) { next_class++; class_used = false; } - for (map::iterator k = node_classes.begin(); + for (map::iterator k = node_classes.begin(); k != node_classes.end(); k++) { /** * If any other characters are in the same class, move * the characters in this class into their own new * class */ - map::iterator l; + map::iterator l; for (l = classes.begin(); l != classes.end(); l++) { if (l->second == k->first && k->second.find(l->first) == k->second.end()) { @@ -1224,16 +1224,16 @@ map DFA::equivalence_classes(dfaflags_t flags) /** * Text-dump the equivalence classes (for debugging). */ -void dump_equivalence_classes(ostream &os, map &eq) +void dump_equivalence_classes(ostream &os, map &eq) { - map rev; + map rev; - for (map::iterator i = eq.begin(); i != eq.end(); i++) { + for (map::iterator i = eq.begin(); i != eq.end(); i++) { Chars &chars = rev.insert(make_pair(i->second, Chars())).first->second; chars.insert(i->first); } os << "(eq):" << "\n"; - for (map::iterator i = rev.begin(); i != rev.end(); i++) { + for (map::iterator i = rev.begin(); i != rev.end(); i++) { os << i->first.c << ':'; Chars &chars = i->second; for (Chars::iterator j = chars.begin(); j != chars.end(); j++) { @@ -1247,14 +1247,14 @@ void dump_equivalence_classes(ostream &os, map &eq) * Replace characters with classes (which are also represented as * characters) in the DFA transition table. */ -void DFA::apply_equivalence_classes(map &eq) +void DFA::apply_equivalence_classes(map &eq) { /** * Note: We only transform the transition table; the nodes continue to * contain the original characters. */ for (Partition::iterator i = states.begin(); i != states.end(); i++) { - map tmp; + map tmp; tmp.swap((*i)->trans); for (StateTrans::iterator j = tmp.begin(); j != tmp.end(); j++) (*i)->trans.insert(make_pair(eq[j->first], j->second)); diff --git a/parser/libapparmor_re/hfa.h b/parser/libapparmor_re/hfa.h index 0a9820b34..9aa310f03 100644 --- a/parser/libapparmor_re/hfa.h +++ b/parser/libapparmor_re/hfa.h @@ -37,7 +37,7 @@ class State; -typedef map StateTrans; +typedef map StateTrans; typedef list Partition; #include "../immunix.h" @@ -212,7 +212,7 @@ public: } }; - State *next(uchar c) { + State *next(transchar c) { State *state = this; do { StateTrans::iterator i = state->trans.find(c); @@ -326,8 +326,8 @@ public: void dump_dot_graph(ostream &os); void dump_uniq_perms(const char *s); - map equivalence_classes(dfaflags_t flags); - void apply_equivalence_classes(map &eq); + map equivalence_classes(dfaflags_t flags); + void apply_equivalence_classes(map &eq); unsigned int diffcount; Node *root; @@ -335,6 +335,6 @@ public: Partition states; }; -void dump_equivalence_classes(ostream &os, map &eq); +void dump_equivalence_classes(ostream &os, map &eq); #endif /* __LIBAA_RE_HFA_H */ diff --git a/parser/libapparmor_re/parse.y b/parser/libapparmor_re/parse.y index 3ec07e12c..843a5090c 100644 --- a/parser/libapparmor_re/parse.y +++ b/parser/libapparmor_re/parse.y @@ -38,17 +38,17 @@ void regex_error(Node **, const char *, const char *); #define YYLEX_PARAM &text int regex_lex(YYSTYPE *, const char **); -static inline Chars *insert_char(Chars* cset, uchar a) +static inline Chars *insert_char(Chars* cset, transchar a) { cset->insert(a); return cset; } -static inline Chars* insert_char_range(Chars* cset, uchar a, uchar b) +static inline Chars* insert_char_range(Chars* cset, transchar a, transchar b) { if (a > b) swap(a, b); - for (uchar i = a; i <= b; i++) + for (transchar i = a; i <= b; i++) cset->insert(i); return cset; }