Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-15809: Replace boost::regex with std::regex #59

Merged
merged 2 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/demangle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ int main()
<< lsst::utils::demangleType(typeid(im).name())
<< std::endl;
}

1 change: 0 additions & 1 deletion include/lsst/utils/Backtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ class Backtrace final {
} // namespace lsst

#endif

6 changes: 3 additions & 3 deletions include/lsst/utils/Cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Cache {
*
* If the key is in the cache, it will be promoted to the
* most recently used value.
*
*
* @throws lsst::pex::exceptions::NotFoundError If key is not in the
* cache.
*
Expand Down Expand Up @@ -142,7 +142,7 @@ class Cache {
*
* @exceptsafe Strong exception safety: exceptions will return the
* system to previous state.
*/
*/
std::vector<Key> keys() const;

/** Does the cache contain the key?
Expand Down Expand Up @@ -172,7 +172,7 @@ class Cache {
*
* @exceptsafe Basic exception safety: exceptions will leave the
* system in a valid but unpredictable state.
*/
*/
void flush();

#ifdef LSST_CACHE_DEBUG
Expand Down
16 changes: 8 additions & 8 deletions include/lsst/utils/Demangle.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// -*- lsst-c++ -*-

/*
/*
* LSST Data Management System
* Copyright 2008, 2009, 2010 LSST Corporation.
*
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* 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 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

#if !defined(LSST_UTILS_DEMANGLE_H)
#define LSST_UTILS_DEMANGLE_H 1

Expand All @@ -31,6 +31,6 @@ namespace lsst {
namespace utils {

std::string demangleType(std::string const _typeName);

}} // namespace lsst::utils
#endif
15 changes: 7 additions & 8 deletions include/lsst/utils/Utils.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// -*- lsst-c++ -*-

/*
/*
* LSST Data Management System
* Copyright 2008, 2009, 2010 LSST Corporation.
*
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* 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 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

//! @file
//! @defgroup utils LSST general-purpose utilities
//! @brief Generic LSST software support
Expand Down Expand Up @@ -49,4 +49,3 @@ std::string getPackageDir(std::string const& packageName);
}} // namespace lsst::utils

#endif

2 changes: 1 addition & 1 deletion include/lsst/utils/hashCombine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ std::size_t hashCombine(std::size_t seed, const T& value, Rest... rest) {

}} // namespace lsst::utils

#endif
#endif
1 change: 0 additions & 1 deletion include/lsst/utils/python.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,3 @@ inline std::pair<std::size_t, std::size_t> cppIndex(std::ptrdiff_t size_i, std::
}}} // namespace lsst::utils::python

#endif

11 changes: 5 additions & 6 deletions src/Backtrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <cxxabi.h>
#include <execinfo.h>

#include "boost/regex.hpp"
#include <regex>

#include "lsst/utils/Backtrace.h"

Expand Down Expand Up @@ -62,18 +62,18 @@ char *demangleAndPrint(char *input, char *buffer, size_t *bufferSize) noexcept {
int status = 1;

try {
boost::cmatch matches;
boost::regex rgx(
std::cmatch matches;
std::regex rgx(
"(.*[\\s|\\(])" // before
"(_\\w+)" // mangled name
"(.*\\+.*)" // after
);

if (boost::regex_match(input, matches, rgx)) {
if (std::regex_match(input, matches, rgx)) {
buffer = abi::__cxa_demangle(matches.str(2).c_str(), buffer, bufferSize, &status);
fprintf(stderr, "%s%s%s\n", matches.str(1).c_str(), buffer, matches.str(3).c_str());
}
} catch(const boost::bad_expression &e) {
} catch(const std::regex_error &e) {
fprintf(stderr, "[demangleAndPrint] %s\n", e.what());
status = 1;
} catch(const std::runtime_error &e) {
Expand Down Expand Up @@ -180,4 +180,3 @@ Backtrace::Backtrace() noexcept : enabled(false) {}
} // namespace lsst

#endif

24 changes: 12 additions & 12 deletions src/Demangle.cc
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
* LSST Data Management System
* Copyright 2008, 2009, 2010 LSST Corporation.
*
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* 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 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

#include "lsst/utils/Demangle.h"

#include <iostream>
Expand Down Expand Up @@ -48,7 +48,7 @@ class Symbol {
~Symbol() {}

static void reset() { n_next = 0; } // reset counter

void print() const {
std::cout << '\t' << n << " " << key << '\n';
}
Expand Down Expand Up @@ -124,10 +124,10 @@ std::string demangleType(std::string const _typeName) {
typedef SymbolTable::index<n>::type::iterator nIterator;
typedef SymbolTable::index<key>::type::iterator keyIterator;
Symbol::reset();

// Here's my symbol table and its indices
SymbolTable st;

SymbolTable::index<n>::type &nIndex = st.get<n>();
SymbolTable::index<key>::type &keyIndex = st.get<key>();
//
Expand All @@ -139,7 +139,7 @@ std::string demangleType(std::string const _typeName) {
if (*ptr == 'r' || *ptr == 'V' || *ptr == 'K') {
ptr++; // (restrict/volatile/const)
}

if (*ptr == 'P') ptr++; // We passed "this" which is (type *)

std::string currentSymbol = ""; // Current symbol
Expand Down Expand Up @@ -171,7 +171,7 @@ std::string demangleType(std::string const _typeName) {
typeName += ',';
}
}

break;
case 'I':
typeStack.push(*ptr++);
Expand Down Expand Up @@ -259,7 +259,7 @@ std::string demangleType(std::string const _typeName) {
currentSymbol += "::";
typeName += "::";
}

currentSymbol += name;
typeName += name;

Expand Down
23 changes: 11 additions & 12 deletions src/Utils.cc
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
/*
/*
* LSST Data Management System
* Copyright 2008, 2009, 2010 LSST Corporation.
*
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* 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 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

#include "lsst/utils/Utils.h"

#include <iostream>
#include <sstream>
#include <string>
#include "boost/regex.hpp"
#include "lsst/pex/exceptions.h"

namespace lsst {
namespace utils {

std::string getPackageDir(std::string const& packageName) {
std::string envVar = packageName; // package's environment variable

transform(envVar.begin(), envVar.end(), envVar.begin(), (int (*)(int)) toupper);
envVar += "_DIR";

char const *dir = getenv(envVar.c_str());
if (!dir) {
throw LSST_EXCEPT(lsst::pex::exceptions::NotFoundError, "Package " + packageName + " not found");
}

return dir;
}

}} // namespace lsst::utils
2 changes: 1 addition & 1 deletion ups/utils.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lsst.sconsUtils

dependencies = {
"required": ["boost", "python", "boost_regex", "pex_exceptions", "numpy"],
"required": ["boost", "python", "pex_exceptions", "numpy"],
"buildRequired": ["boost_test", "python", "pybind11"],
}

Expand Down