From 0e2da7f1d447169f2ee5302c73b56788e923c418 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Mon, 25 Jul 2011 23:17:37 -0400 Subject: [PATCH] Code Cleanup - When compiling the 2.0.0 branch of Taskwarrior with GCC 4.6.1, the compiler generates a number of warnings. This patch eliminates these warnings. Signed-off-by: Paul Beckingham --- src/A3.cpp | 16 ---------------- src/Arguments.cpp | 17 ++--------------- src/Nibbler.cpp | 2 -- src/helpers.cpp | 3 ++- src/utf8.cpp | 24 +++++++++++++----------- 5 files changed, 17 insertions(+), 45 deletions(-) diff --git a/src/A3.cpp b/src/A3.cpp index 5a008ec0d..acf74569a 100644 --- a/src/A3.cpp +++ b/src/A3.cpp @@ -625,7 +625,6 @@ const A3 A3::tokenize (const A3& input) const // For identifying sequence versus non-sequence. bool found_sequence = false; bool found_something_after_sequence = false; - bool found_non_sequence = false; std::string s; int i; @@ -637,7 +636,6 @@ const A3 A3::tokenize (const A3& input) const n.getQuoted ('\'', s, true)) { output.push_back (Arg (s, "string")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -645,7 +643,6 @@ const A3 A3::tokenize (const A3& input) const else if (is_subst (n, s)) { output.push_back (Arg (s, "subst")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -653,7 +650,6 @@ const A3 A3::tokenize (const A3& input) const else if (is_pattern (n, s)) { output.push_back (Arg (s, "pattern")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -661,7 +657,6 @@ const A3 A3::tokenize (const A3& input) const else if (is_tag (n, s)) { output.push_back (Arg (s, "tag")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -669,7 +664,6 @@ const A3 A3::tokenize (const A3& input) const else if (n.getOneOf (operators, s)) { output.push_back (Arg (s, "op")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -677,7 +671,6 @@ const A3 A3::tokenize (const A3& input) const else if (is_attr (n, s)) { output.push_back (Arg (s, "attr")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -685,7 +678,6 @@ const A3 A3::tokenize (const A3& input) const else if (is_attmod (n, s)) { output.push_back (Arg (s, "attmod")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -693,7 +685,6 @@ const A3 A3::tokenize (const A3& input) const else if (is_dom (n, s)) { output.push_back (Arg (s, "dom")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -701,7 +692,6 @@ const A3 A3::tokenize (const A3& input) const else if (n.getDateISO (t)) { output.push_back (Arg (Date (t).toISO (), "date")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -709,7 +699,6 @@ const A3 A3::tokenize (const A3& input) const else if (n.getDate (date_format, t)) { output.push_back (Arg (Date (t).toString (date_format), "date")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -717,7 +706,6 @@ const A3 A3::tokenize (const A3& input) const else if (is_duration (n, s)) { output.push_back (Arg (s, "duration")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -752,7 +740,6 @@ const A3 A3::tokenize (const A3& input) const else if (n.getNumber (d)) { output.push_back (Arg (format (d), "num")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -760,7 +747,6 @@ const A3 A3::tokenize (const A3& input) const else if (n.getInt (i)) { output.push_back (Arg (format (i), "int")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -773,7 +759,6 @@ const A3 A3::tokenize (const A3& input) const else output.push_back (Arg (s, "word")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } @@ -784,7 +769,6 @@ const A3 A3::tokenize (const A3& input) const n.getUntilEOS (s); output.push_back (Arg (s, "word")); - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; } diff --git a/src/Arguments.cpp b/src/Arguments.cpp index 286748d1f..de981cdb6 100644 --- a/src/Arguments.cpp +++ b/src/Arguments.cpp @@ -284,10 +284,9 @@ void Arguments::categorize () bool found_command = false; bool found_sequence = false; bool found_something_after_sequence = false; - bool found_non_sequence = false; // Track where the command is, if possible. - int command_pos = -1; +// int command_pos = -1; // int distance_from_command = 0; // Configurable support. @@ -312,7 +311,6 @@ void Arguments::categorize () if (arg->_first == "--") { terminated = true; - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; @@ -333,7 +331,6 @@ void Arguments::categorize () arg->_first = "calendar"; arg->_third = "command"; found_command = true; - found_non_sequence = true; } } @@ -342,11 +339,10 @@ void Arguments::categorize () is_command (keywords, arg->_first)) { found_command = true; - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; - command_pos = counter; +// command_pos = counter; arg->_third = "command"; } @@ -398,7 +394,6 @@ void Arguments::categorize () // [+-]tag else if (is_tag (arg->_first)) { - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; @@ -411,7 +406,6 @@ void Arguments::categorize () // .: else if (is_attmod (arg->_first)) { - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; @@ -424,7 +418,6 @@ void Arguments::categorize () // : else if (is_attr (arg->_first)) { - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; @@ -437,7 +430,6 @@ void Arguments::categorize () // ///[g] else if (is_subst (arg->_first)) { - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; @@ -450,7 +442,6 @@ void Arguments::categorize () // /pattern/ else if (enable_patterns && is_pattern (arg->_first)) { - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; @@ -463,7 +454,6 @@ void Arguments::categorize () // else if (is_operator (arg->_first)) { - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; @@ -476,7 +466,6 @@ void Arguments::categorize () // else if (enable_expressions && is_expression (arg->_first)) { - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; @@ -490,7 +479,6 @@ void Arguments::categorize () // If the type is not known, it is treated as a generic word. else { - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; @@ -504,7 +492,6 @@ void Arguments::categorize () // All post-termination arguments are simply words. else { - found_non_sequence = true; if (found_sequence) found_something_after_sequence = true; diff --git a/src/Nibbler.cpp b/src/Nibbler.cpp index 1e7f6b46f..7cb1de0cb 100644 --- a/src/Nibbler.cpp +++ b/src/Nibbler.cpp @@ -238,7 +238,6 @@ bool Nibbler::getQuoted ( bool inquote = false; bool inescape = false; char current = 0; - char previous = 0; result = ""; if (mCursor >= mLength || @@ -249,7 +248,6 @@ bool Nibbler::getQuoted ( for (std::string::size_type i = mCursor; i < mLength; ++i) { - previous = current; current = mInput[i]; if (current == '\\' && !inescape) diff --git a/src/helpers.cpp b/src/helpers.cpp index 8c0d281c1..324cea64f 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -133,10 +133,11 @@ std::string onProjectChange (Task& task, bool scope /* = true */) int count_done = 0; std::vector all; + std::vector none; context.tdb.load (all); countTasks (all, project, context.tdb.getAllModified (), count_pending, count_done); - countTasks (context.tdb.getAllModified (), project, (std::vector ) NULL, count_pending, count_done); + countTasks (context.tdb.getAllModified (), project, none, count_pending, count_done); // count_done count_pending percentage // ---------- ------------- ---------- diff --git a/src/utf8.cpp b/src/utf8.cpp index b711150e2..26382b726 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -80,31 +80,33 @@ unsigned int utf8_next_char (const std::string& input, std::string::size_type& i // How many bytes in the sequence? int length = utf8_sequence (input[i]); + i += length; + // 0xxxxxxx -> 0xxxxxxx if (length == 1) - return input[i++]; + return input[i - 1]; // 110yyyyy 10xxxxxx -> 00000yyy yyxxxxxx if (length == 2) - return ((input[i++] & 0x1F) << 6) + - (input[i++] & 0x3F); + return ((input[i - 2] & 0x1F) << 6) + + (input[i - 1] & 0x3F); // 1110zzzz 10yyyyyy 10xxxxxx -> zzzzyyyy yyxxxxxx if (length == 3) - return ((input[i++] & 0xF) << 12) + - ((input[i++] & 0x3F) << 6) + - (input[i++] & 0x3F); + return ((input[i - 3] & 0xF) << 12) + + ((input[i - 2] & 0x3F) << 6) + + (input[i - 1] & 0x3F); // 11110www 10zzzzzz 10yyyyyy 10xxxxxx -> 000wwwzz zzzzyyyy yyxxxxxx if (length == 4) - return ((input[i++] & 0x7) << 18) + - ((input[i++] & 0x3F) << 12) + - ((input[i++] & 0x3F) << 6) + - (input[i++] & 0x3F); + return ((input[i - 4] & 0x7) << 18) + + ((input[i - 3] & 0x3F) << 12) + + ((input[i - 2] & 0x3F) << 6) + + (input[i - 1] & 0x3F); // Default: pretend as though it's a single character. // TODO Or should this throw? - return input[i++]; + return input[i - 1]; } ////////////////////////////////////////////////////////////////////////////////