Update of /cvsroot/javanetsim/IceScan/icesockets
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1785/icesockets
Modified Files:
iceregex.h
Log Message:
Index: iceregex.h
===================================================================
RCS file: /cvsroot/javanetsim/IceScan/icesockets/iceregex.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** iceregex.h 30 Nov 2006 15:25:48 -0000 1.3
--- iceregex.h 13 Dec 2006 02:27:18 -0000 1.4
***************
*** 60,65 ****
ovector_ = new int[3*(capture_count_+1)];
}
!
bool match(icestring const& s, std::vector<icestring> &v){
int rc = pcre_exec (
pcre_, /* the compiled pattern */
--- 60,125 ----
ovector_ = new int[3*(capture_count_+1)];
}
!
bool match(icestring const& s, std::vector<icestring> &v){
+ subject.assign(s);
+ int res = find(s, v, 0);
+ if(res) findPoint = ovector_[0]+1;
+ else findPoint = 0;
+ return res;
+ }
+
+ bool match(icestring const& s){
+ std::vector<icestring> v;
+ return match(s, v);
+ }
+
+ bool match(const char s[]){
+ icestring is(s);
+ return match(is);
+ }
+
+ bool findNext(){
+ std::vector<icestring> v;
+ if(findPoint >= subject.length()) return false;
+ int res = find(subject, v, findPoint);
+ if(res) findPoint = ovector_[0]+1;
+ return res;
+ }
+
+ void findReset(){
+ findPoint = 0;
+ }
+
+ int groups(){
+ return pcre_result_;
+ }
+
+ bool group(int i, char *str, int strsize){
+ int rc = pcre_copy_substring(
+ subject.c_str(), // Subject that has been successfully matched
+ ovector_, // Offset vector that pcre_exec() used
+ pcre_result_, // Value returned by pcre_exec()
+ i, // Number of the required substring
+ str, // Buffer to receive the string
+ strsize // Size of buffer
+ );
+ if(rc<0){
+ icestring aaa;
+ switch(rc){
+ case PCRE_ERROR_NOMEMORY: aaa.assign("PCRE_ERROR_NOMEMORY"); break;
+ case PCRE_ERROR_NOSUBSTRING: aaa.assign("PCRE_ERROR_NOSUBSTRING"); break;
+ default:
+ char tmp[10];
+ sprintf(tmp, "%6d", rc);
+ aaa.assign(tmp);
+ }
+ std::cout << "IceRegex error: " << aaa << std::endl;
+ exit(-1);
+ return false;
+ }
+ return true;
+ }
+ private:
+ bool find(icestring const& s, std::vector<icestring> &v, int start){
int rc = pcre_exec (
pcre_, /* the compiled pattern */
***************
*** 67,75 ****
s.c_str(), /* the string to match */
s.length(), /* the length of the string */
! 0, /* start at offset 0 in the subject */
0, /* default options */
ovector_, /* output vector for substring information */
3*(capture_count_+1)); /* number of elements in the output vector */
!
if (rc < 0) {
switch (rc) {
--- 127,136 ----
s.c_str(), /* the string to match */
s.length(), /* the length of the string */
! start, /* start at offset 0 in the subject */
0, /* default options */
ovector_, /* output vector for substring information */
3*(capture_count_+1)); /* number of elements in the output vector */
!
! pcre_result_ = rc;
if (rc < 0) {
switch (rc) {
***************
*** 91,110 ****
}
- bool match(icestring const& s){
- std::vector<icestring> v;
- return match(s, v);
- }
-
- bool match(const char s[]){
- icestring is(s);
- return match(is);
- }
-
private:
pcre* pcre_;
unsigned long int capture_count_;
icestring pattern;
int* ovector_; //UGLY
};
--- 152,164 ----
}
private:
pcre* pcre_;
unsigned long int capture_count_;
icestring pattern;
+ icestring subject;
int* ovector_; //UGLY
+ int pcre_result_;
+ int findPoint;
};
|