diff --git a/src/T.cpp b/src/T.cpp index 61acd52f4..f490d8681 100644 --- a/src/T.cpp +++ b/src/T.cpp @@ -328,6 +328,11 @@ const std::string T::composeCSV () line += value; line += ","; + value = mAttributes["recur"]; + if (value != "") + line += value; + line += ","; + value = mAttributes["end"]; if (value != "") line += value; @@ -353,7 +358,11 @@ const std::string T::composeCSV () line += "'" + value + "'"; line += ","; - line += "'" + mDescription + "'\n"; + // Convert single quotes to double quotes, because single quotes are used to + // delimit the values that need it. + std::string clean = mDescription; + std::replace (clean.begin (), clean.end (), '\'', '"'); + line += "'" + clean + "'\n"; return line; } diff --git a/src/command.cpp b/src/command.cpp index 16740bf59..72724f668 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -578,7 +578,7 @@ std::string handleDone (TDB& tdb, T& task, Config& conf) //////////////////////////////////////////////////////////////////////////////// std::string handleExport (TDB& tdb, T& task, Config& conf) { - std::stringstream out; + std::stringstream output; // Use the description as a file name, then clobber the description so the // file name isn't used for filtering. @@ -597,6 +597,7 @@ std::string handleExport (TDB& tdb, T& task, Config& conf) << "'entry'," << "'start'," << "'due'," + << "'recur'," << "'end'," << "'project'," << "'priority'," @@ -605,14 +606,22 @@ std::string handleExport (TDB& tdb, T& task, Config& conf) << "'description'" << "\n"; + int count = 0; std::vector all; - tdb.allT (all); + tdb.allPendingT (all); filter (all, task); foreach (t, all) { - out << t->composeCSV ().c_str (); + if (t->getStatus () != T::recurring && + t->getStatus () != T::deleted) + { + out << t->composeCSV ().c_str (); + ++count; + } } out.close (); + + output << count << " tasks exported to '" << file << "'" << std::endl; } else throw std::string ("Could not write to export file."); @@ -620,7 +629,7 @@ std::string handleExport (TDB& tdb, T& task, Config& conf) else throw std::string ("You must specify a file to write to."); - return out.str (); + return output.str (); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/util.cpp b/src/util.cpp index 7f1e6b911..a114c9a0b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -187,6 +187,7 @@ static char randomHexDigit () { static char digits[] = "0123456789abcdef"; #ifdef HAVE_RANDOM + // random is better than rand. return digits[random () % 16]; #else return digits[rand () % 16];