diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2014-01-07 14:47:05 +0200 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2014-01-07 14:47:05 +0200 |
| commit | 522b066870988b60b67efcc118cc1a33c9e35547 (patch) | |
| tree | ef6149a972f09cec0b904a50fcfacf21b8072c69 | |
| parent | 0fd92fe3ad425d87c3647a3b51fbd2204e1fb1d2 (diff) | |
| download | tiny-rex-522b066870988b60b67efcc118cc1a33c9e35547.tar.gz tiny-rex-522b066870988b60b67efcc118cc1a33c9e35547.zip | |
strip spaces
| -rw-r--r-- | TRexpp.h | 24 | ||||
| -rw-r--r-- | trex.c | 38 | ||||
| -rw-r--r-- | trex.h | 10 |
3 files changed, 36 insertions, 36 deletions
@@ -5,11 +5,11 @@ Copyright (C) 2003-2004 Alberto Demichelis - This software is provided 'as-is', without any express - or implied warranty. In no event will the authors be held + This software is provided 'as-is', without any express + or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. - Permission is granted to anyone to use this software for + Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: @@ -38,28 +38,28 @@ public: TRexpp() { _exp = (TRex *)0; } ~TRexpp() { CleanUp(); } // compiles a regular expression - void Compile(const TRexChar *pattern) { + void Compile(const TRexChar *pattern) { const TRexChar *error; CleanUp(); if(!(_exp = trex_compile(pattern,&error))) throw TRexParseException(error); } // return true if the given text match the expression - bool Match(const TRexChar* text) { - return _exp?(trex_match(_exp,text) != 0):false; + bool Match(const TRexChar* text) { + return _exp?(trex_match(_exp,text) != 0):false; } // Searches for the first match of the expression in a zero terminated string - bool Search(const TRexChar* text, const TRexChar** out_begin, const TRexChar** out_end) { - return _exp?(trex_search(_exp,text,out_begin,out_end) != 0):false; + bool Search(const TRexChar* text, const TRexChar** out_begin, const TRexChar** out_end) { + return _exp?(trex_search(_exp,text,out_begin,out_end) != 0):false; } // Searches for the first match of the expression in a string sarting at text_begin and ending at text_end - bool SearchRange(const TRexChar* text_begin,const TRexChar* text_end,const TRexChar** out_begin, const TRexChar** out_end) { - return _exp?(trex_searchrange(_exp,text_begin,text_end,out_begin,out_end) != 0):false; + bool SearchRange(const TRexChar* text_begin,const TRexChar* text_end,const TRexChar** out_begin, const TRexChar** out_end) { + return _exp?(trex_searchrange(_exp,text_begin,text_end,out_begin,out_end) != 0):false; } bool GetSubExp(int n, const TRexChar** out_begin, int *out_len) { TRexMatch match; - TRexBool res = _exp?(trex_getsubexp(_exp,n,&match)):TRex_False; + TRexBool res = _exp?(trex_getsubexp(_exp,n,&match)):TRex_False; if(res) { *out_begin = match.begin; *out_len = match.len; @@ -72,4 +72,4 @@ private: void CleanUp() { if(_exp) trex_free(_exp); _exp = (TRex *)0; } TRex *_exp; }; -#endif //_TREXPP_H_
\ No newline at end of file +#endif //_TREXPP_H_ @@ -105,7 +105,7 @@ static void trex_error(TRex *exp,const TRexChar *error) } static void trex_expect(TRex *exp, int n){ - if((*exp->_p) != n) + if((*exp->_p) != n) trex_error(exp, _SC("expected paren")); exp->_p++; } @@ -144,31 +144,31 @@ static int trex_charnode(TRex *exp,TRexBool isclass) case 'r': exp->_p++; return trex_newnode(exp,'\r'); case 'f': exp->_p++; return trex_newnode(exp,'\f'); case 'v': exp->_p++; return trex_newnode(exp,'\v'); - case 'a': case 'A': case 'w': case 'W': case 's': case 'S': - case 'd': case 'D': case 'x': case 'X': case 'c': case 'C': - case 'p': case 'P': case 'l': case 'u': + case 'a': case 'A': case 'w': case 'W': case 's': case 'S': + case 'd': case 'D': case 'x': case 'X': case 'c': case 'C': + case 'p': case 'P': case 'l': case 'u': { - t = *exp->_p; exp->_p++; + t = *exp->_p; exp->_p++; return trex_charclass(exp,t); } - case 'b': + case 'b': case 'B': if(!isclass) { int node = trex_newnode(exp,OP_WB); exp->_nodes[node].left = *exp->_p; - exp->_p++; + exp->_p++; return node; } //else default - default: - t = *exp->_p; exp->_p++; + default: + t = *exp->_p; exp->_p++; return trex_newnode(exp,t); } } else if(!scisprint(*exp->_p)) { - + trex_error(exp,_SC("letter expected")); } - t = *exp->_p; exp->_p++; + t = *exp->_p; exp->_p++; return trex_newnode(exp,t); } static int trex_class(TRex *exp) @@ -179,11 +179,11 @@ static int trex_class(TRex *exp) ret = trex_newnode(exp,OP_NCLASS); exp->_p++; }else ret = trex_newnode(exp,OP_CLASS); - + if(*exp->_p == ']') trex_error(exp,_SC("empty class")); chain = ret; while(*exp->_p != ']' && exp->_p != exp->_eol) { - if(*exp->_p == '-' && first != -1){ + if(*exp->_p == '-' && first != -1){ int r,t; if(*exp->_p++ == ']') trex_error(exp,_SC("unfinished range")); r = trex_newnode(exp,OP_RANGE); @@ -297,7 +297,7 @@ static int trex_element(TRex *exp) trex_error(exp,_SC(", or } expected")); } /*******************************/ - isgreedy = TRex_True; + isgreedy = TRex_True; break; } @@ -384,7 +384,7 @@ static TRexBool trex_matchclass(TRex* exp,TRexNode *node,TRexChar c) static const TRexChar *trex_matchnode(TRex* exp,TRexNode *node,const TRexChar *str,TRexNode *next) { - + TRexNodeType type = node->type; switch(type) { case OP_GREEDY: { @@ -428,7 +428,7 @@ static const TRexChar *trex_matchnode(TRex* exp,TRexNode *node,const TRexChar *s } } } - + if(s >= exp->_eol) break; } @@ -467,7 +467,7 @@ static const TRexChar *trex_matchnode(TRex* exp,TRexNode *node,const TRexChar *s exp->_matches[capture].begin = cur; exp->_currsubexp++; } - + do { TRexNode *subnext = NULL; if(n->next != -1) { @@ -484,10 +484,10 @@ static const TRexChar *trex_matchnode(TRex* exp,TRexNode *node,const TRexChar *s } } while((n->next != -1) && (n = &exp->_nodes[n->next])); - if(capture != -1) + if(capture != -1) exp->_matches[capture].len = cur - exp->_matches[capture].begin; return cur; - } + } case OP_WB: if(str == exp->_bol && !isspace(*str) || (str == exp->_eol && !isspace(*(str-1))) @@ -5,11 +5,11 @@ Copyright (C) 2003-2006 Alberto Demichelis - This software is provided 'as-is', without any express - or implied warranty. In no event will the authors be held + This software is provided 'as-is', without any express + or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. - Permission is granted to anyone to use this software for + Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: @@ -30,13 +30,13 @@ #ifdef _UNICODE #define TRexChar unsigned short #define MAX_CHAR 0xFFFF -#define _TREXC(c) L##c +#define _TREXC(c) L##c #define trex_strlen wcslen #define trex_printf wprintf #else #define TRexChar char #define MAX_CHAR 0xFF -#define _TREXC(c) (c) +#define _TREXC(c) (c) #define trex_strlen strlen #define trex_printf printf #endif |
