+2009-04-05 Bruno Haible <bruno@clisp.org>
+
+ New module 'unistr/u8-cmp2'.
+ * lib/unistr.h (u8_cmp2, u16_cmp2, u32_cmp2): New declarations.
+ * lib/unistr/u8-cmp2.c: New file.
+ * lib/unistr/u-cmp2.h: New file.
+ * modules/unistr/u8-cmp2: New file.
+
2009-04-05 Bruno Haible <bruno@clisp.org>
* lib/unictype.h (uc_property_is_valid): New macro.
extern int
u32_cmp (const uint32_t *s1, const uint32_t *s2, size_t n);
+/* Compare S1 and S2. */
+/* Similar to memcmp2(). */
+extern int
+ u8_cmp2 (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2);
+extern int
+ u16_cmp2 (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2);
+extern int
+ u32_cmp2 (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2);
+
/* Search the string at S for UC. */
/* Similar to memchr(). */
extern uint8_t *
--- /dev/null
+/* Compare pieces of UTF-8/UTF-16/UTF-32 strings.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2009.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+FUNC (const UNIT *s1, size_t n1, const UNIT *s2, size_t n2)
+{
+ int cmp = U_CMP (s1, s2, MIN (n1, n2));
+
+ if (cmp == 0)
+ {
+ if (n1 < n2)
+ cmp = -1;
+ else if (n1 > n2)
+ cmp = 1;
+ }
+
+ return cmp;
+}
--- /dev/null
+/* Compare pieces of UTF-8 strings.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2009.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistr.h"
+
+#include "minmax.h"
+
+#define FUNC u8_cmp2
+#define UNIT uint8_t
+#define U_CMP u8_cmp
+#include "u-cmp2.h"
--- /dev/null
+Description:
+Compare pieces of UTF-8 strings with possibly different lengths.
+
+Files:
+lib/unistr/u8-cmp2.c
+lib/unistr/u-cmp2.h
+
+Depends-on:
+unistr/base
+unistr/u8-cmp
+minmax
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unistr/u8-cmp2.c
+
+Include:
+"unistr.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+