summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-06-15 10:46:15 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2018-06-18 12:27:01 +0000
commitf4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43 (patch)
tree7c6044fd3a17a2665841959dac9b3b2110b27924 /src/util
parentRun clang-tidy’s modernize-use-override pass. (diff)
downloadinkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.tar.gz
inkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.zip
Run clang-tidy’s modernize-use-nullptr pass.
This replaces all NULL or 0 with nullptr when assigned to or returned as a pointer.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/ege-appear-time-tracker.cpp2
-rw-r--r--src/util/expression-evaluator.cpp30
-rw-r--r--src/util/expression-evaluator.h2
-rw-r--r--src/util/forward-pointer-iterator.h2
-rw-r--r--src/util/list.h4
-rw-r--r--src/util/share.cpp4
-rw-r--r--src/util/share.h2
-rw-r--r--src/util/units.cpp2
-rw-r--r--src/util/ziptool.cpp4
9 files changed, 26 insertions, 26 deletions
diff --git a/src/util/ege-appear-time-tracker.cpp b/src/util/ege-appear-time-tracker.cpp
index 456d702ab..ec24bbd32 100644
--- a/src/util/ege-appear-time-tracker.cpp
+++ b/src/util/ege-appear-time-tracker.cpp
@@ -81,7 +81,7 @@ AppearTimeTracker::~AppearTimeTracker()
{
if ( _timer ) {
g_timer_destroy(_timer);
- _timer = 0;
+ _timer = nullptr;
}
unhookHandler( _mapId, _topMost );
diff --git a/src/util/expression-evaluator.cpp b/src/util/expression-evaluator.cpp
index 0a2dd6d50..47c54a995 100644
--- a/src/util/expression-evaluator.cpp
+++ b/src/util/expression-evaluator.cpp
@@ -51,7 +51,7 @@ EvaluatorToken::EvaluatorToken()
}
ExpressionEvaluator::ExpressionEvaluator(const char *string, Unit const *unit) :
- string(g_locale_to_utf8(string,-1,0,0,0)),
+ string(g_locale_to_utf8(string,-1,nullptr,nullptr,nullptr)),
unit(unit)
{
current_token.type = TOKEN_END;
@@ -76,24 +76,24 @@ ExpressionEvaluator::ExpressionEvaluator(const char *string, Unit const *unit) :
**/
EvaluatorQuantity ExpressionEvaluator::evaluate()
{
- if (!g_utf8_validate(string, -1, NULL)) {
- throw EvaluatorException("Invalid UTF8 string", NULL);
+ if (!g_utf8_validate(string, -1, nullptr)) {
+ throw EvaluatorException("Invalid UTF8 string", nullptr);
}
EvaluatorQuantity result = EvaluatorQuantity();
EvaluatorQuantity default_unit_factor;
// Empty expression evaluates to 0
- if (acceptToken(TOKEN_END, NULL)) {
+ if (acceptToken(TOKEN_END, nullptr)) {
return result;
}
result = evaluateExpression();
// There should be nothing left to parse by now
- isExpected(TOKEN_END, 0);
+ isExpected(TOKEN_END, nullptr);
- resolveUnit(NULL, &default_unit_factor, unit);
+ resolveUnit(nullptr, &default_unit_factor, unit);
// Entire expression is dimensionless, apply default unit if applicable
if ( result.dimension == 0 && default_unit_factor.dimension != 0 ) {
@@ -112,7 +112,7 @@ EvaluatorQuantity ExpressionEvaluator::evaluateExpression()
// Continue evaluating terms, chained with + or -.
for (subtract = FALSE;
- acceptToken('+', NULL) || (subtract = acceptToken('-', NULL));
+ acceptToken('+', nullptr) || (subtract = acceptToken('-', nullptr));
subtract = FALSE)
{
EvaluatorQuantity new_term = evaluateTerm();
@@ -121,7 +121,7 @@ EvaluatorQuantity ExpressionEvaluator::evaluateExpression()
if ( new_term.dimension != evaluated_terms.dimension ) {
EvaluatorQuantity default_unit_factor;
- resolveUnit(NULL, &default_unit_factor, unit);
+ resolveUnit(nullptr, &default_unit_factor, unit);
if ( new_term.dimension == 0
&& evaluated_terms.dimension == default_unit_factor.dimension )
@@ -150,7 +150,7 @@ EvaluatorQuantity ExpressionEvaluator::evaluateTerm()
EvaluatorQuantity evaluated_exp_terms = evaluateExpTerm();
for ( division = false;
- acceptToken('*', NULL) || (division = acceptToken('/', NULL));
+ acceptToken('*', nullptr) || (division = acceptToken('/', nullptr));
division = false )
{
EvaluatorQuantity new_exp_term = evaluateExpTerm();
@@ -171,7 +171,7 @@ EvaluatorQuantity ExpressionEvaluator::evaluateExpTerm()
{
EvaluatorQuantity evaluated_signed_factors = evaluateSignedFactor();
- while(acceptToken('^', NULL)) {
+ while(acceptToken('^', nullptr)) {
EvaluatorQuantity new_signed_factor = evaluateSignedFactor();
if (new_signed_factor.dimension == 0) {
@@ -191,8 +191,8 @@ EvaluatorQuantity ExpressionEvaluator::evaluateSignedFactor()
EvaluatorQuantity result;
bool negate = FALSE;
- if (!acceptToken('+', NULL)) {
- negate = acceptToken ('-', NULL);
+ if (!acceptToken('+', nullptr)) {
+ negate = acceptToken ('-', nullptr);
}
result = evaluateFactor();
@@ -214,9 +214,9 @@ EvaluatorQuantity ExpressionEvaluator::evaluateFactor()
}
else if (acceptToken(TOKEN_NUM, &consumed_token)) {
evaluated_factor.value = consumed_token.value.fl;
- } else if (acceptToken('(', NULL)) {
+ } else if (acceptToken('(', nullptr)) {
evaluated_factor = evaluateExpression();
- isExpected(')', 0);
+ isExpected(')', nullptr);
} else {
throwError("Expected number or '('");
}
@@ -279,7 +279,7 @@ void ExpressionEvaluator::parseNextToken()
acceptTokenCount(1, s[0]);
} else {
// Attempt to parse a numeric value
- char *endptr = NULL;
+ char *endptr = nullptr;
gdouble value = g_strtod(s, &endptr);
if ( endptr && endptr != s ) {
diff --git a/src/util/expression-evaluator.h b/src/util/expression-evaluator.h
index c912f248b..bb29d7f26 100644
--- a/src/util/expression-evaluator.h
+++ b/src/util/expression-evaluator.h
@@ -133,7 +133,7 @@ public:
class ExpressionEvaluator
{
public:
- ExpressionEvaluator(const char *string, Unit const *unit = NULL);
+ ExpressionEvaluator(const char *string, Unit const *unit = nullptr);
EvaluatorQuantity evaluate();
diff --git a/src/util/forward-pointer-iterator.h b/src/util/forward-pointer-iterator.h
index 4d1cfa413..4f8e88637 100644
--- a/src/util/forward-pointer-iterator.h
+++ b/src/util/forward-pointer-iterator.h
@@ -61,7 +61,7 @@ public:
return old;
}
- operator bool() const { return _p != NULL; }
+ operator bool() const { return _p != nullptr; }
private:
pointer _p;
diff --git a/src/util/list.h b/src/util/list.h
index 563b6091c..ea2fa871e 100644
--- a/src/util/list.h
+++ b/src/util/list.h
@@ -60,7 +60,7 @@ public:
typedef typename Traits::Reference<value_type>::RValue const_reference;
typedef typename Traits::Reference<value_type>::Pointer pointer;
- List() : _cell(NULL) {}
+ List() : _cell(nullptr) {}
explicit List(const_reference value, List const &next=List())
: _cell(new ListCell<T>(value, next._cell)) {}
@@ -157,7 +157,7 @@ public:
typedef typename Traits::Reference<value_type>::RValue const_reference;
typedef typename Traits::Reference<value_type>::Pointer pointer;
- List() : _cell(NULL) {}
+ List() : _cell(nullptr) {}
List(const_reference value, List const &next=List())
: _cell(new ListCell<T &>(value, next._cell)) {}
diff --git a/src/util/share.cpp b/src/util/share.cpp
index d5d93fc75..a9c648d6c 100644
--- a/src/util/share.cpp
+++ b/src/util/share.cpp
@@ -17,12 +17,12 @@ namespace Inkscape {
namespace Util {
ptr_shared share_string(char const *string) {
- g_return_val_if_fail(string != NULL, share_unsafe(NULL));
+ g_return_val_if_fail(string != nullptr, share_unsafe(nullptr));
return share_string(string, std::strlen(string));
}
ptr_shared share_string(char const *string, std::size_t length) {
- g_return_val_if_fail(string != NULL, share_unsafe(NULL));
+ g_return_val_if_fail(string != nullptr, share_unsafe(nullptr));
char *new_string=new (GC::ATOMIC) char[length+1];
std::memcpy(new_string, string, length);
new_string[length] = 0;
diff --git a/src/util/share.h b/src/util/share.h
index 6e98c5258..a2672afa4 100644
--- a/src/util/share.h
+++ b/src/util/share.h
@@ -23,7 +23,7 @@ namespace Util {
class ptr_shared {
public:
- ptr_shared() : _string(NULL) {}
+ ptr_shared() : _string(nullptr) {}
ptr_shared(ptr_shared const &other) : _string(other._string) {}
operator char const *() const { return _string; }
diff --git a/src/util/units.cpp b/src/util/units.cpp
index cd7b66ba8..7854abf77 100644
--- a/src/util/units.cpp
+++ b/src/util/units.cpp
@@ -462,7 +462,7 @@ void UnitParser::on_text(Ctx &ctx, Glib::ustring const &text)
unit.abbr = text;
} else if (element == "factor") {
// TODO make sure we use the right conversion
- unit.factor = g_ascii_strtod(text.c_str(), NULL);
+ unit.factor = g_ascii_strtod(text.c_str(), nullptr);
} else if (element == "description") {
unit.description = text;
}
diff --git a/src/util/ziptool.cpp b/src/util/ziptool.cpp
index b8253627c..e5ece00e4 100644
--- a/src/util/ziptool.cpp
+++ b/src/util/ziptool.cpp
@@ -1588,7 +1588,7 @@ bool GzipFile::write()
putByte( 8); //compression method
putByte(0x08); //flags. say we have a crc and file name
- unsigned long ltime = (unsigned long) time(NULL);
+ unsigned long ltime = (unsigned long) time(nullptr);
putLong(ltime);
//xfl
@@ -2235,7 +2235,7 @@ ZipEntry *ZipFile::addFile(const std::string &fileName,
if (!ze->readFile(fileName, comment))
{
delete ze;
- return NULL;
+ return nullptr;
}
entries.push_back(ze);
return ze;