diff lib/wcslen-impl.h @ 14281:cae17a11c789

New module 'wcslen'. * modules/wcslen: New file. * lib/wchar.in.h (wcslen): New declaration. * lib/wcslen.c: New file. * lib/wcslen-impl.h: New file, from libutf8 with modifications. * m4/wcslen.m4: New file. * m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcslen is declared. (gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSLEN, HAVE_WCSLEN. * modules/wchar (Makefile.am): Substitute GNULIB_WCSLEN, HAVE_WCSLEN. * tests/test-wchar-c++.cc: Test the declaration of wcslen. * doc/posix-functions/wcslen.texi: Mention the new module.
author Bruno Haible <bruno@clisp.org>
date Sat, 05 Feb 2011 13:36:58 +0100 (2011-02-05)
parents
children 8250f2777afc
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/lib/wcslen-impl.h
@@ -0,0 +1,26 @@
+/* Determine the length of a wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+size_t
+wcslen (const wchar_t *s)
+{
+  const wchar_t *ptr;
+
+  for (ptr = s; *ptr != (wchar_t)'\0'; ptr++)
+    ;
+  return ptr - s;
+}