From 57106c86a9cb426c3a16f8368cd0b558f565f704 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 2 Jan 2014 00:26:10 -0500 Subject: [PATCH] UTF8 - Merged libexpr changes. --- src/utf8.cpp | 7 +++++-- src/utf8.h | 4 ++-- test/utf8.t.cpp | 9 +++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/utf8.cpp b/src/utf8.cpp index 51ff4d20b..126ebdd05 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -1,7 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// -// taskwarrior - a command line task list manager. // -// Copyright 2006-2013, Paul Beckingham, Federico Hernandez. +// Copyright 2013 - 2014, Paul Beckingham, Federico Hernandez. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -25,6 +24,7 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include #include #include @@ -78,6 +78,9 @@ unsigned int utf8_codepoint (const std::string& input) // - returns the next character unsigned int utf8_next_char (const std::string& input, std::string::size_type& i) { + if (input[i] == '\0') + return 0; + // How many bytes in the sequence? int length = utf8_sequence (input[i]); diff --git a/src/utf8.h b/src/utf8.h index 8e50871a6..530292021 100644 --- a/src/utf8.h +++ b/src/utf8.h @@ -1,7 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// -// taskwarrior - a command line task list manager. // -// Copyright 2006-2013, Paul Beckingham, Federico Hernandez. +// Copyright 2013 - 2014, Paul Beckingham, Federico Hernandez. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -40,6 +39,7 @@ unsigned int utf8_width (const std::string& str); unsigned int utf8_text_width (const std::string&); const std::string utf8_substr (const std::string&, unsigned int, unsigned int length = 0); +int mk_wcwidth (wchar_t); #endif //////////////////////////////////////////////////////////////////////////////// diff --git a/test/utf8.t.cpp b/test/utf8.t.cpp index be7cf4e9d..f75f3b041 100644 --- a/test/utf8.t.cpp +++ b/test/utf8.t.cpp @@ -1,7 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// -// taskwarrior - a command line task list manager. // -// Copyright 2006-2013, Paul Beckingham, Federico Hernandez. +// Copyright 2006 - 2014, Paul Beckingham, Federico Hernandez. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -25,7 +24,9 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include +#include #include #include @@ -34,6 +35,10 @@ int main (int argc, char** argv) { UnitTest t (17); + // Ensure environment has no influence. + unsetenv ("TASKDATA"); + unsetenv ("TASKRC"); + std::string ascii_text = "This is a test"; std::string utf8_text = "más sábado miércoles"; std::string utf8_wide_text = "改变各种颜色";