[glom] Fix a time parsing regression.



commit 48d99051bf4473c923ccb7d13f3d6a924df1f902
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Aug 26 17:59:53 2009 +0200

    Fix a time parsing regression.
    
    * glom/libglom/libglom_config.h.in: Moved HAVE_STRPTIME here from
    config.h (which should maybe not be generated by autoheader),
    to the test_parsing_time regression.
    * glom/libglom/data_structure/iso_codes.cc: Include libglom_config.h
    instead of config.h, after moving ISO_CODES_PREFIX there.

 ChangeLog                                      |   10 ++++++++++
 glom/libglom/data_structure/glomconversions.cc |    3 ++-
 glom/libglom/data_structure/iso_codes.cc       |    4 ++--
 glom/libglom/libglom_config.h.in               |   15 +++++++++++++++
 regression_tests/test_parsing_time.cc          |   16 ++++++++++++++--
 regression_tests/test_signal_reemit.cc         |    2 +-
 6 files changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 74e6707..846af47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2009-08-26  Murray Cumming  <murrayc murrayc com>
 
+	Fix a time parsing regression.
+
+	* glom/libglom/libglom_config.h.in: Moved HAVE_STRPTIME here from 
+	config.h (which should maybe not be generated by autoheader),
+	to the test_parsing_time regression.
+	* glom/libglom/data_structure/iso_codes.cc: Include libglom_config.h 
+	instead of config.h, after moving ISO_CODES_PREFIX there.
+
+2009-08-26  Murray Cumming  <murrayc murrayc com>
+
 	Tests: Correct the return values.
 
 	* regression_tests/test_parsing_time.cc:
diff --git a/glom/libglom/data_structure/glomconversions.cc b/glom/libglom/data_structure/glomconversions.cc
index e041415..ae70df7 100644
--- a/glom/libglom/data_structure/glomconversions.cc
+++ b/glom/libglom/data_structure/glomconversions.cc
@@ -764,7 +764,7 @@ tm Conversions::parse_time(const Glib::ustring& text, bool& success)
 
 tm Conversions::parse_time(const Glib::ustring& text, const std::locale& locale, bool& success)
 {
-  //std::cout << "parse_time(): text=" << text << std::endl;
+  std::cout << "parse_time(): text=" << text << std::endl;
   //The sequence of statements here seems to be very fragile. If you move things then it stops working.
 
   //return parse_tm(text, locale, 'X' /* time */);
@@ -809,6 +809,7 @@ tm Conversions::parse_time(const Glib::ustring& text, const std::locale& locale,
   
 #ifdef HAVE_STRPTIME
   //Fall back to strptime():
+  //This fallback will be used in most cases. TODO: Remove the useless? time_get<> code then?
   //It seems to be well known that time_get<> can parse much less than what time_put<> can generate:
   // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2070.html
   //
diff --git a/glom/libglom/data_structure/iso_codes.cc b/glom/libglom/data_structure/iso_codes.cc
index 99511c9..5e649c2 100644
--- a/glom/libglom/data_structure/iso_codes.cc
+++ b/glom/libglom/data_structure/iso_codes.cc
@@ -18,9 +18,9 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include <config.h> //For ISO_CODES_PREFIX.
+#include <libglom/libglom_config.h> //For ISO_CODES_PREFIX.
 
-#include "iso_codes.h"
+#include <libglom/data_structure/iso_codes.h>
 #include <libxml++/libxml++.h>
 #include <libglom/document/document.h>
 #include <libglom/utils.h>
diff --git a/glom/libglom/libglom_config.h.in b/glom/libglom/libglom_config.h.in
index 7a8d07c..28be5dd 100644
--- a/glom/libglom/libglom_config.h.in
+++ b/glom/libglom/libglom_config.h.in
@@ -5,4 +5,19 @@
 /* "definition of GLOM_DTD_INSTALL_DIR" */
 #undef GLOM_DTD_INSTALL_DIR
 
+/* Define to 1 if you have the `dcgettext' function. */
+#undef HAVE_DCGETTEXT
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define if the GNU gettext() function is already present or preinstalled. */
+#undef HAVE_GETTEXT
+
+/* Define to 1 if you have the `strptime' function. */
+#undef HAVE_STRPTIME
+
+/* Define to the installation prefix of the iso-codes module. */
+#undef ISO_CODES_PREFIX
+
 #endif /* GLOM_LIBGLOM_CONFIG_H */
diff --git a/regression_tests/test_parsing_time.cc b/regression_tests/test_parsing_time.cc
index 19cd743..ce4b307 100644
--- a/regression_tests/test_parsing_time.cc
+++ b/regression_tests/test_parsing_time.cc
@@ -8,6 +8,18 @@ int main()
   std::cout << "time_text_input=" << time_text_input << std::endl;
 
   bool success = false;
+
+  //We try parse_time() though parse_value() calls it anyway, 
+  //to give us a clue if parse_value would fail.
+  struct tm value_as_tm = 
+    Glom::Conversions::parse_time(time_text_input, success);
+  if(!success)
+  {
+    std::cerr << "Failed: parse_time() failed." << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  success = false;
   const Gnome::Gda::Value value = 
     Glom::Conversions::parse_value(Glom::Field::TYPE_TIME, time_text_input, success);
 
@@ -22,13 +34,13 @@ int main()
 
   if(parsed_time.hour != 13)
   {
-    std::cerr << "Failed: The parsed hour was " <<  parsed_time.hour << "instead of 13" << std::endl;
+    std::cerr << "Failed: The parsed hour was " <<  parsed_time.hour << " instead of 13" << std::endl;
     return -1; //Failed.
   }
 
   if(parsed_time.minute != 0)
   {
-    std::cerr << "Failed: The parsed minute was " <<  parsed_time.minute << "instead of 0" << std::endl;
+    std::cerr << "Failed: The parsed minute was " <<  parsed_time.minute << " instead of 0" << std::endl;
     return EXIT_FAILURE;
   }
 
diff --git a/regression_tests/test_signal_reemit.cc b/regression_tests/test_signal_reemit.cc
index 25ee5b2..fa10b6f 100644
--- a/regression_tests/test_signal_reemit.cc
+++ b/regression_tests/test_signal_reemit.cc
@@ -1,6 +1,6 @@
 #include <glom/signal_reemitter.h>
 #include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
 
 bool success_reemit_void = false;
 bool success_reemit_int = false;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]