This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[v3] Minor tweaks to src/localename.cc


Hi,

tested x86-linux, committed to mainline.

Paolo.

/////////////
2004-09-24  Paolo Carlini  <pcarlini@suse.de>

	* src/localename.cc (locale::locale(const char*)): Minor tweaks:
	rename a variable, move an assignment.
	(locale::_Impl::_Impl(const char*, size_t)): Likewise, minor tweak. 
diff -urN libstdc++-v3-orig/src/localename.cc libstdc++-v3/src/localename.cc
--- libstdc++-v3-orig/src/localename.cc	2004-06-28 13:18:03.000000000 +0200
+++ libstdc++-v3/src/localename.cc	2004-09-24 16:47:02.000000000 +0200
@@ -59,19 +59,19 @@
 	    else
 	      {
 		// LANG may set a default different from "C".
-		string __res;
-		char* __env = std::getenv("LANG");
+		string __lang;
+		__env = std::getenv("LANG");
 		if (!__env || std::strcmp(__env, "") == 0 
 		    || std::strcmp(__env, "C") == 0 
 		    || std::strcmp(__env, "POSIX") == 0)
-		  __res = "C";
+		  __lang = "C";
 		else 
-		  __res = __env;
+		  __lang = __env;
 		
 		// Scan the categories looking for the first one
 		// different from LANG.
 		size_t __i = 0;
-		if (__res == "C")
+		if (__lang == "C")
 		  for (; __i < _S_categories_size; ++__i)
 		    {
 		      __env = std::getenv(_S_categories[__i]);
@@ -85,7 +85,7 @@
 		    {
 		      __env = std::getenv(_S_categories[__i]);
 		      if (__env && std::strcmp(__env, "") != 0
-			  && __res != __env)
+			  && __lang != __env)
 			break;
 		    }
 	
@@ -99,33 +99,29 @@
 		      {
 			__str += _S_categories[__j];
 			__str += '=';
-			__str += __res;
+			__str += __lang;
 			__str += ';';
 		      }
 		    __str += _S_categories[__i];
 		    __str += '=';
 		    __str += __env;
 		    __str += ';';
-		    __i++;
+		    ++__i;
 		    for (; __i < _S_categories_size; ++__i)
 		      {
 			__env = std::getenv(_S_categories[__i]);
+			__str += _S_categories[__i];
 			if (!__env || std::strcmp(__env, "") == 0)
 			  {
-			    __str += _S_categories[__i];
 			    __str += '=';
-			    __str += __res;
+			    __str += __lang;
 			    __str += ';';
 			  }
 			else if (std::strcmp(__env, "C") == 0
 				 || std::strcmp(__env, "POSIX") == 0)
-			  {
-			    __str += _S_categories[__i];
-			    __str += "=C;";
-			  }
+			  __str += "=C;";
 			else
 			  {
-			    __str += _S_categories[__i];
 			    __str += '=';
 			    __str += __env;
 			    __str += ';';
@@ -136,10 +132,10 @@
 		  }
 		// ... otherwise either an additional instance of
 		// the "C" locale or LANG.
-		else if (__res == "C")
+		else if (__lang == "C")
 		  (_M_impl = _S_classic)->_M_add_reference();
 		else
-		  _M_impl = new _Impl(__res.c_str(), 1);
+		  _M_impl = new _Impl(__lang.c_str(), 1);
 	      }
 	  }
       }
@@ -179,9 +175,9 @@
 
   // Construct named _Impl.
   locale::_Impl::
-  _Impl(const char* __s, size_t __refs) 
+  _Impl(const char* __s, size_t __refs)
   : _M_refcount(__refs), _M_facets(0), _M_facets_size(_GLIBCXX_NUM_FACETS),
-  _M_caches(0), _M_names(0)
+    _M_caches(0), _M_names(0)
   {
     // Initialize the underlying locale model, which also checks to
     // see if the given name is valid.
@@ -202,7 +198,7 @@
 
 	// Name the categories.
 	const size_t __len = std::strlen(__s);
-	if (!std::strchr(__s, ';'))
+	if (!std::memchr(__s, ';', __len))
 	  {
 	    _M_names[0] = new char[__len + 1];
 	    std::memcpy(_M_names[0], __s, __len + 1);	    

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