]> git.tdb.fi Git - libs/core.git/blobdiff - source/regex.cpp
core/error.h renamed to except.h
[libs/core.git] / source / regex.cpp
index 839435ef3bf62fd9c95134efd005e97d307dc011..d3fd0b7ebc4e58b733947387a6e4f349e83bd7ce 100644 (file)
@@ -1,12 +1,16 @@
+/* $Id$
+
+This file is part of libmspstrings
+Copyright © 2007 Mikko Rasa
+Distributed under the LGPL
+*/
 #include <stack>
-#include <msp/core/error.h>
+#include <msp/core/except.h>
 #include "formatter.h"
 #include "regex.h"
 
 using namespace std;
 
-#include <iostream>
-
 namespace {
 
 /**
@@ -303,14 +307,14 @@ Regex::Code Regex::parse_brackets(const string &str, string::const_iterator &ite
        }
 
        string::const_iterator end=iter;
-       for(; (end!=str.end() && *end!=']'); ++end);
+       for(; (end!=str.end() && (end==iter || *end!=']')); ++end);
        if(end==str.end())
                throw InvalidParameterValue("Unmatched '['");
 
        uint8_t mask[32]={0};
        unsigned type=0;
        bool range=false;
-       unsigned char first, last;
+       unsigned char first=0, last=0;
        for(string::const_iterator i=iter; i!=end; ++i)
        {
                unsigned char c=*i;
@@ -496,7 +500,7 @@ bool Regex::group_compare(const RegMatch::Group &g1, const RegMatch::Group &g2)
 {
        if(!g1.match)
                return false;
-       
+
        // Any match is better than no match
        if(!g2.match)
                return true;