]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - locale/newlocale.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / locale / newlocale.c
index b3d4b464b1fc5874778d348b4446740c4cc7549e..3deecc42df13ac5c0153c38ea7ca665cc4a52db0 100644 (file)
@@ -1,6 +1,5 @@
 /* Return a reference to locale information record.
-   Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright (C) 1996-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <argz.h>
-#include <bits/libc-lock.h>
+#include <libc-lock.h>
 #include <errno.h>
 #include <locale.h>
 #include <stdlib.h>
@@ -30,7 +28,7 @@
 
 
 /* Lock for protecting global data.  */
-__libc_lock_define (extern , __libc_setlocale_lock attribute_hidden)
+__libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden)
 
 
 /* Use this when we come along an error.  */
@@ -133,7 +131,8 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
          for (cnt = 0; cnt < __LC_LAST; ++cnt)
            if (cnt != LC_ALL
                && (size_t) (cp - np) == _nl_category_name_sizes[cnt]
-               && memcmp (np, _nl_category_names[cnt], cp - np) == 0)
+               && memcmp (np, (_nl_category_names.str
+                               + _nl_category_name_idxs[cnt]), cp - np) == 0)
              break;
 
          if (cnt == __LC_LAST)
@@ -161,7 +160,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
     }
 
   /* Protect global data.  */
-  __libc_lock_lock (__libc_setlocale_lock);
+  __libc_rwlock_wrlock (__libc_setlocale_lock);
 
   /* Now process all categories we are interested in.  */
   names_len = 0;
@@ -182,7 +181,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
                  _nl_remove_locale (cnt, result.__locales[cnt]);
 
               /* Critical section left.  */
-              __libc_lock_unlock (__libc_setlocale_lock);
+              __libc_rwlock_unlock (__libc_setlocale_lock);
              return NULL;
            }
 
@@ -262,7 +261,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
     }
 
   /* Critical section left.  */
-  __libc_lock_unlock (__libc_setlocale_lock);
+  __libc_rwlock_unlock (__libc_setlocale_lock);
 
   /* Update the special members.  */
  update: