diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-10 20:23:29 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-10 20:23:29 +0000 |
commit | ea4406b4779306f4d0c65f0619cd8241bbdcef7b (patch) | |
tree | a63d24ddd768559eb993d9bb847acbc3750ef261 /src/regexps.cpp | |
download | tdeio-apt-ea4406b4779306f4d0c65f0619cd8241bbdcef7b.tar.gz tdeio-apt-ea4406b4779306f4d0c65f0619cd8241bbdcef7b.zip |
Added abandoned version of kio-apt
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kio-apt@1088432 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/regexps.cpp')
-rw-r--r-- | src/regexps.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/regexps.cpp b/src/regexps.cpp new file mode 100644 index 0000000..d49121d --- /dev/null +++ b/src/regexps.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2003 by Sylvain Joyeux * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include "regexps.h" +#include "debug.h" + +#include <kdebug.h> + +bool match_dversion(QString version) +{ + static QRegExp rx_revision(rxs_revision); + QString allowed_vchars = ".+\\w"; + + kdDebug(DEBUG_ZONE) << version << endl; + if (version[1] == ':') + { + allowed_vchars += ":"; + if (! version[0].isDigit()) return false; + kdDebug(DEBUG_ZONE) << "Matched epoch" << endl; + version = version.right( version.length() - 2 ); + } + + kdDebug(DEBUG_ZONE) << version << endl; + int rev_pos = version.findRev('-'); + if (rev_pos > -1) + { + allowed_vchars += "-"; + QString revision = version.right( version.length() - rev_pos - 1); + if (! rx_revision.exactMatch(revision)) + return false; + + kdDebug(DEBUG_ZONE) << "Matched revision" << endl; + version.truncate( version.length() - rev_pos - 1 ); + } + + QRegExp rx_version("\\d[" + allowed_vchars + "]*"); + return rx_version.exactMatch(version); +} |