]> git.lyx.org Git - lyx.git/blobdiff - src/support/LRegex.C
Fix small typos
[lyx.git] / src / support / LRegex.C
index 0db78a0a8e8ae86c4ecbdf812bfe6331fefb52b8..c6c1e938ce28db8bf25093aac9a23facfb6d3f7f 100644 (file)
@@ -1,11 +1,17 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include <config.h>
 
 #include <sys/types.h>
+
+#ifdef HAVE_REGEX_H
 #include <regex.h>
+#else
+#include "lyxregex.h"
+#endif
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "LRegex.h"
 
 using std::make_pair;
@@ -13,7 +19,7 @@ using std::make_pair;
 ///
 struct LRegex::Impl {
        ///
-       re_pattern_buffer * preg;
+       regex_t * preg;
        
        ///
        int error_code;
@@ -23,7 +29,7 @@ struct LRegex::Impl {
        
        ///
        Impl(string const & regex) 
-               : preg(new re_pattern_buffer), error_code(0)
+               : preg(new regex_t), error_code(0)
        {
                error_code = regcomp(preg, regex.c_str(), REG_EXTENDED);
        }
@@ -49,24 +55,24 @@ struct LRegex::Impl {
        }
        
        ///
-       LRegex::MatchPair first_match(string const & str) const
+       LRegex::MatchPair const first_match(string const & str) const
        {
                regmatch_t tmp;
                regexec(preg, str.c_str(), 1, &tmp, 0);
-               unsigned int first = tmp.rm_so != -1 ?
+               unsigned int const first = tmp.rm_so != -1 ?
                        static_cast<unsigned int>(tmp.rm_so) : string::npos;
-               unsigned int second = tmp.rm_eo != -1 ?
+               unsigned int const second = tmp.rm_eo != -1 ?
                        static_cast<unsigned int>(tmp.rm_eo) : string::npos;
                return make_pair(first, second - first);
        }
        
        ///
-       string getError() const
+       string const getError() const
        {
                size_t nr = regerror(error_code, preg, 0, 0);
                char * tmp = new char[nr];
                regerror(error_code, preg, tmp, nr);
-               string ret(tmp);
+               string const ret(tmp);
                delete [] tmp;
                return ret;
        }
@@ -82,7 +88,8 @@ struct LRegex::Impl {
                // func much faster, but client code will be simpler,
                // because then it will only be needed to scan through
                // all the entries in matches.
-               size_t subs = (preg->re_nsub != 0 ? (preg->re_nsub + 1) : 1);
+               size_t const subs =
+                       (preg->re_nsub != 0 ? (preg->re_nsub + 1) : 1);
                regmatch_t * mat = new regmatch_t[subs];
                unsigned int first = 0;
                unsigned int second = 0;
@@ -128,13 +135,13 @@ bool LRegex::exact_match(string const & str) const
 }
 
 
-LRegex::MatchPair LRegex::first_match(string const & str) const
+LRegex::MatchPair const LRegex::first_match(string const & str) const
 {
        return impl->first_match(str);
 }
 
 
-string LRegex::getError() const
+string const LRegex::getError() const
 {
        return impl->getError();
 }