New module strchrnul.
authorBruno Haible <bruno@clisp.org>
Tue, 10 Jun 2003 12:13:31 +0000 (12:13 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 10 Jun 2003 12:13:31 +0000 (12:13 +0000)
ChangeLog
lib/ChangeLog
lib/strchrnul.c [new file with mode: 0644]
lib/strchrnul.h [new file with mode: 0644]
m4/ChangeLog
m4/strchrnul.m4 [new file with mode: 0644]
modules/strchrnul [new file with mode: 0644]

index 5ce99b262827ac2d3f6858c16aac3c674efcfc07..afe2d8126d58203f5312935f979d4cbfa0f170cd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-2003-06=10  Simon Josefsson <jas@extundo.com>
+2003-06-10  Simon Josefsson  <jas@extundo.com>
+
+       * modules/strchrnul: New file.
+
+2003-06-10  Simon Josefsson  <jas@extundo.com>
 
        * modules/argp: New file.
 
index 685049a9655e86d28fc1da6cfbeffb026bcc7ade..92ee7d93a6e9786468288b39aac9f44230e6ab07 100644 (file)
@@ -1,3 +1,8 @@
+2003-06-10  Simon Josefsson  <jas@extundo.com>
+
+       * strchrnul.h: New file.
+       * strchrnul.c: New file.
+
 2003-06=10  Simon Josefsson <jas@extundo.com>
 
        * argp.h: New file, from glibc.
diff --git a/lib/strchrnul.c b/lib/strchrnul.c
new file mode 100644 (file)
index 0000000..694e24a
--- /dev/null
@@ -0,0 +1,31 @@
+/* Searching in a string.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+
+   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 2, 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, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* Specification.  */
+#include "strchrnul.h"
+
+/* Find the first occurrence of C in S or the final NUL byte.  */
+char *
+strchrnul (s, c_in)
+     const char *s;
+     int c_in;
+{
+  while (*s && (*s != c_in))
+    s++;
+
+  return (char*) s;
+}
diff --git a/lib/strchrnul.h b/lib/strchrnul.h
new file mode 100644 (file)
index 0000000..f7589e9
--- /dev/null
@@ -0,0 +1,28 @@
+/* Searching in a string.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+
+   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 2, 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, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#if HAVE_STRCHRNUL
+
+/* Get strchrnul() declaration.  */
+#include <string.h>
+
+#else
+
+/* Find the first occurrence of C in S or the final NUL byte.  */
+extern char *strchrnul (const char *s, int c_in);
+
+#endif
index 1b46f78c92668efdb91b91b7a40a9e015328491e..e31bef867807f434371070c7bd3ad17a5bbc9d31 100644 (file)
@@ -1,3 +1,7 @@
+2003-06-10  Simon Josefsson  <jas@extundo.com>
+
+       * strchrnul.m4: New file.
+
 2003-06-07  Bruno Haible  <bruno@clisp.org>
 
        * fnmatch.m4 (_AC_LIBOBJ_FNMATCH, gl_FUNC_FNMATCH_POSIX,
diff --git a/m4/strchrnul.m4 b/m4/strchrnul.m4
new file mode 100644 (file)
index 0000000..565e338
--- /dev/null
@@ -0,0 +1,23 @@
+# strchrnul.m4 serial 1
+dnl Copyright (C) 2003 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+AC_DEFUN([gl_FUNC_STRCHRNUL],
+[
+  dnl Persuade glibc <string.h> to declare strchrnul().
+  AC_REQUIRE([AC_GNU_SOURCE])
+
+  AC_REPLACE_FUNCS(strchrnul)
+  if test $ac_cv_func_strchrnul = no; then
+    gl_PREREQ_STRCHRNUL
+  fi
+])
+
+# Prerequisites of lib/strchrnul.c.
+AC_DEFUN([gl_PREREQ_STRCHRNUL], [
+  AC_CHECK_HEADERS_ONCE(string.h)
+])
diff --git a/modules/strchrnul b/modules/strchrnul
new file mode 100644 (file)
index 0000000..b174523
--- /dev/null
@@ -0,0 +1,20 @@
+Description:
+strchrnul(): Find the first occurrence of C in S or the final NUL byte.
+
+Files:
+lib/strchrnul.h
+lib/strchrnul.c
+m4/strchrnul.m4
+
+Depends-on:
+
+configure.ac:
+gl_FUNC_STRCHRNUL
+
+Makefile.am:
+
+Include:
+"strchrnul.h"
+
+Maintainer:
+FSF