utils: cleanup whitespace
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** Copyright (C) 2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
** Copyright (C) 2020-2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public License
|
||||
@ -43,8 +43,6 @@ using StringVec = std::vector<std::string>;
|
||||
std::string utf8_flatten (const char *str);
|
||||
inline std::string utf8_flatten (const std::string& s) { return utf8_flatten(s.c_str()); }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Replace all control characters with spaces, and remove leading and trailing space.
|
||||
*
|
||||
@ -55,6 +53,19 @@ inline std::string utf8_flatten (const std::string& s) { return utf8_flatten(s.c
|
||||
std::string utf8_clean (const std::string& dirty);
|
||||
|
||||
|
||||
/**
|
||||
* Remove ctrl characters, replacing them with ' '; subsequent
|
||||
* ctrl characters are replaced by a single ' '
|
||||
*
|
||||
* @param str a string
|
||||
*
|
||||
* @return the string without control characters
|
||||
*/
|
||||
std::string remove_ctrl (const std::string& str);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Split a string in parts
|
||||
*
|
||||
@ -64,7 +75,7 @@ std::string utf8_clean (const std::string& dirty);
|
||||
* @return the parts.
|
||||
*/
|
||||
std::vector<std::string> split (const std::string& str,
|
||||
const std::string& sepa);
|
||||
const std::string& sepa);
|
||||
|
||||
/**
|
||||
* Quote & escape a string for " and \
|
||||
@ -241,69 +252,69 @@ private:
|
||||
*/
|
||||
|
||||
#define MU_XAPIAN_CATCH_BLOCK \
|
||||
catch (const Xapian::Error &xerr) { \
|
||||
g_critical ("%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
} catch (const std::runtime_error& re) { \
|
||||
g_critical ("%s: error: %s", __func__, re.what()); \
|
||||
} catch (...) { \
|
||||
g_critical ("%s: caught exception", __func__); \
|
||||
catch (const Xapian::Error &xerr) { \
|
||||
g_critical ("%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
} catch (const std::runtime_error& re) { \
|
||||
g_critical ("%s: error: %s", __func__, re.what()); \
|
||||
} catch (...) { \
|
||||
g_critical ("%s: caught exception", __func__); \
|
||||
}
|
||||
|
||||
#define MU_XAPIAN_CATCH_BLOCK_G_ERROR(GE,E) \
|
||||
catch (const Xapian::DatabaseLockError &xerr) { \
|
||||
mu_util_g_set_error ((GE), \
|
||||
MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK, \
|
||||
"%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
} catch (const Xapian::DatabaseError &xerr) { \
|
||||
mu_util_g_set_error ((GE),MU_ERROR_XAPIAN, \
|
||||
"%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
} catch (const Xapian::Error &xerr) { \
|
||||
mu_util_g_set_error ((GE),(E), \
|
||||
"%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
} catch (const std::runtime_error& ex) { \
|
||||
mu_util_g_set_error ((GE),(MU_ERROR_INTERNAL), \
|
||||
"%s: error: %s", __func__, ex.what()); \
|
||||
\
|
||||
} catch (...) { \
|
||||
mu_util_g_set_error ((GE),(MU_ERROR_INTERNAL), \
|
||||
"%s: caught exception", __func__); \
|
||||
}
|
||||
catch (const Xapian::DatabaseLockError &xerr) { \
|
||||
mu_util_g_set_error ((GE), \
|
||||
MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK, \
|
||||
"%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
} catch (const Xapian::DatabaseError &xerr) { \
|
||||
mu_util_g_set_error ((GE),MU_ERROR_XAPIAN, \
|
||||
"%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
} catch (const Xapian::Error &xerr) { \
|
||||
mu_util_g_set_error ((GE),(E), \
|
||||
"%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
} catch (const std::runtime_error& ex) { \
|
||||
mu_util_g_set_error ((GE),(MU_ERROR_INTERNAL), \
|
||||
"%s: error: %s", __func__, ex.what()); \
|
||||
\
|
||||
} catch (...) { \
|
||||
mu_util_g_set_error ((GE),(MU_ERROR_INTERNAL), \
|
||||
"%s: caught exception", __func__); \
|
||||
}
|
||||
|
||||
|
||||
#define MU_XAPIAN_CATCH_BLOCK_RETURN(R) \
|
||||
catch (const Xapian::Error &xerr) { \
|
||||
g_critical ("%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
return (R); \
|
||||
} catch (const std::runtime_error& ex) { \
|
||||
g_critical("%s: error: %s", __func__, ex.what()); \
|
||||
return (R); \
|
||||
} catch (...) { \
|
||||
g_critical ("%s: caught exception", __func__); \
|
||||
return (R); \
|
||||
}
|
||||
catch (const Xapian::Error &xerr) { \
|
||||
g_critical ("%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
return (R); \
|
||||
} catch (const std::runtime_error& ex) { \
|
||||
g_critical("%s: error: %s", __func__, ex.what()); \
|
||||
return (R); \
|
||||
} catch (...) { \
|
||||
g_critical ("%s: caught exception", __func__); \
|
||||
return (R); \
|
||||
}
|
||||
|
||||
#define MU_XAPIAN_CATCH_BLOCK_G_ERROR_RETURN(GE,E,R) \
|
||||
catch (const Xapian::Error &xerr) { \
|
||||
mu_util_g_set_error ((GE),(E), \
|
||||
"%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
return (R); \
|
||||
} catch (const std::runtime_error& ex) { \
|
||||
mu_util_g_set_error ((GE),(MU_ERROR_INTERNAL), \
|
||||
"%s: error: %s", __func__, ex.what()); \
|
||||
return (R); \
|
||||
} catch (...) { \
|
||||
if ((GE)&&!(*(GE))) \
|
||||
mu_util_g_set_error ((GE), \
|
||||
(MU_ERROR_INTERNAL), \
|
||||
"%s: caught exception", __func__); \
|
||||
return (R); \
|
||||
}
|
||||
catch (const Xapian::Error &xerr) { \
|
||||
mu_util_g_set_error ((GE),(E), \
|
||||
"%s: xapian error '%s'", \
|
||||
__func__, xerr.get_msg().c_str()); \
|
||||
return (R); \
|
||||
} catch (const std::runtime_error& ex) { \
|
||||
mu_util_g_set_error ((GE),(MU_ERROR_INTERNAL), \
|
||||
"%s: error: %s", __func__, ex.what()); \
|
||||
return (R); \
|
||||
} catch (...) { \
|
||||
if ((GE)&&!(*(GE))) \
|
||||
mu_util_g_set_error ((GE), \
|
||||
(MU_ERROR_INTERNAL), \
|
||||
"%s: caught exception", __func__); \
|
||||
return (R); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user