This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] libstdc++/31518


Hi,

apparently, this is the way people likes best to resolve this enhancement request. In fact, we have already something similar in pool_allocator (GLIBCXX_FORCE_NEW): what can I say, makes perfect sense, after all. I had some minor doubts, for example about the name of the environment variable (I'm not uglifying it, consistently with the above allocator case, it's safe, doesn't appear in any header), I'll wait until tomorrow for better proposals...

Paolo.

/////////////
2007-07-03  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/31518
	* include/debug/formatter.h (_Error_formatter::_M_get_max_length): New.
	(_Error_formatter::_Error_formatter): Use it.
	* src/debug.cc: Define.
	(_Error_formatter::_M_error): Tweak.
	* configure.ac: Adjust version to 6:10:0.
	* config/abi/pre/gnu.ver: Export _Error_formatter::_M_get_max_length
	at GLIBCXX_3.4.10.
	* testsuite/util/testsuite_abi.cc: Add GLIBCXX_3.4.10.
	* docs/html/debug.html: Document.
	* configure: Regenerate.
Index: src/debug.cc
===================================================================
--- src/debug.cc	(revision 126095)
+++ src/debug.cc	(working copy)
@@ -36,6 +36,7 @@
 #include <cstring>
 #include <cctype>
 #include <cstdio>
+#include <cstdlib>
 
 using namespace std;
 
@@ -496,7 +497,8 @@
 	_M_column += strlen(__buf);
       }
     
-    _M_wordwrap = true;
+    if (_M_max_length)
+      _M_wordwrap = true;
     _M_print_word("error: ");
     
     // Print the error message
@@ -671,6 +673,19 @@
       }
   }
 
+  void
+  _Error_formatter::_M_get_max_length() const
+  {
+    const char* __nptr = std::getenv("GLIBCXX_DEBUG_MESSAGE_LENGTH");
+    if (__nptr)
+      {
+	char* __endptr;
+	const unsigned long __ret = std::strtoul(__nptr, &__endptr, 0);
+	if (*__nptr != '\0' && *__endptr == '\0')
+	  _M_max_length = __ret;
+      }
+  }
+
   // Instantiations.
   template
     void
Index: docs/html/debug.html
===================================================================
--- docs/html/debug.html	(revision 126095)
+++ docs/html/debug.html	(working copy)
@@ -136,6 +136,11 @@
   instantiation of a container is passed between the two translation
   units.</p>
 
+<p>By default, error messages are formatted to fit on lines of about
+  78 characters.  The environment variable
+  <code>GLIBCXX_DEBUG_MESSAGE_LENGTH</code> can be used to request a
+  different length.</p>
+
 <p>For information about the design of the libstdc++ debug mode,
   please see the <a href="debug_mode.html">libstdc++ debug mode design
   document</a>.</p>
Index: configure.ac
===================================================================
--- configure.ac	(revision 126095)
+++ configure.ac	(working copy)
@@ -12,7 +12,7 @@
 ### am handles this now?  ORIGINAL_LD_FOR_MULTILIBS=$LD
 
 # For libtool versioning info, format is CURRENT:REVISION:AGE
-libtool_VERSION=6:9:0
+libtool_VERSION=6:10:0
 AC_SUBST(libtool_VERSION)
 
 # Find the rest of the source tree framework.
Index: include/debug/formatter.h
===================================================================
--- include/debug/formatter.h	(revision 126095)
+++ include/debug/formatter.h	(working copy)
@@ -1,6 +1,6 @@
 // Debug-mode error formatting implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -359,7 +359,7 @@
     _Error_formatter(const char* __file, size_t __line)
     : _M_file(__file), _M_line(__line), _M_num_parameters(0), _M_text(0),
       _M_max_length(78), _M_column(1), _M_first_line(true), _M_wordwrap(false)
-    { }
+    { _M_get_max_length(); }
 
     template<typename _Tp>
       void
@@ -371,6 +371,9 @@
     void
     _M_print_string(const char* __string) const;
 
+    void
+    _M_get_max_length() const;
+
     enum { __max_parameters = 9 };
 
     const char*         _M_file;
Index: testsuite/util/testsuite_abi.cc
===================================================================
--- testsuite/util/testsuite_abi.cc	(revision 126095)
+++ testsuite/util/testsuite_abi.cc	(working copy)
@@ -189,6 +189,7 @@
       known_versions.push_back("GLIBCXX_3.4.7");
       known_versions.push_back("GLIBCXX_3.4.8");
       known_versions.push_back("GLIBCXX_3.4.9");
+      known_versions.push_back("GLIBCXX_3.4.10");
       known_versions.push_back("GLIBCXX_LDBL_3.4");
       known_versions.push_back("GLIBCXX_LDBL_3.4.7");
       known_versions.push_back("CXXABI_1.3");
Index: config/abi/pre/gnu.ver
===================================================================
--- config/abi/pre/gnu.ver	(revision 126095)
+++ config/abi/pre/gnu.ver	(working copy)
@@ -122,8 +122,8 @@
       std::__num_base::_S_atoms_out;
       std::__moneypunct_cache*;
       std::__numpunct_cache*;
-      std::__timepunct_cache*;
-      __gnu_debug::_Error_formatter*
+      std::__timepunct_cache*
+#     __gnu_debug::_Error_formatter*
     };
 
     # Names not in an 'extern' block are mangled names.
@@ -138,6 +138,13 @@
     _ZNK11__gnu_debug19_Safe_iterator_base11_M_singularEv;
     _ZNK11__gnu_debug19_Safe_iterator_base14_M_can_compareERKS0_;
 
+    # __gnu_debug::_Error_formatter
+    _ZNK11__gnu_debug16_Error_formatter10_M_message*;
+    _ZNK11__gnu_debug16_Error_formatter10_Parameter*;
+    _ZNK11__gnu_debug16_Error_formatter13_M_print_word*;
+    _ZNK11__gnu_debug16_Error_formatter15_M_print_string*;
+    _ZNK11__gnu_debug16_Error_formatter8_M_error*;
+    
     # std::string
     _ZNSsC*;
     _ZNSsD*;
@@ -708,6 +715,12 @@
 
 } GLIBCXX_3.4.8;
 
+GLIBCXX_3.4.10 {
+
+    _ZNK11__gnu_debug16_Error_formatter17_M_get_max_lengthEv;
+
+} GLIBCXX_3.4.9;
+
 # Symbols in the support library (libsupc++) have their own tag.
 CXXABI_1.3 {
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]