xserver: Branch 'server-1.5-branch' - 5 commits

Alan Coopersmith alanc at kemper.freedesktop.org
Wed Aug 6 18:01:42 PDT 2008


 configure.ac            |    2 +
 dix/Makefile.am         |    3 +
 dix/strcasecmp.c        |   74 +++++++++++++++++++++++++++++++-----------------
 dix/strcasestr.c        |   64 +++++++++++++++++++++++++++++++++++++++++
 include/dix-config.h.in |   12 +++++--
 include/dix.h           |   12 +++++++
 6 files changed, 136 insertions(+), 31 deletions(-)

New commits:
commit b61ee18b72d8b2c2d21ca68dc8566a09a76683fb
Author: Alan Coopersmith <alan.coopersmith at sun.com>
Date:   Thu Jul 17 18:16:59 2008 -0700

    Make xstrcasestr prototype return value match the implementation
    (cherry picked from 3b687ffe1649449b3d182f5e7690274c6c96916a commit)

diff --git a/include/dix.h b/include/dix.h
index ea83e11..64035fe 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -566,7 +566,7 @@ extern int xstrncasecmp(const char *s1, const char *s2, size_t n);
 
 #if NEED_STRCASESTR
 #define strcasestr xstrcasestr
-extern int xstrcasestr(const char *s, const char *find);
+extern char *xstrcasestr(const char *s, const char *find);
 #endif
 
 /*
commit b5932f176c1abffbe75d03b706a2f04a7ef1e5a0
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jul 16 02:59:51 2008 +0300

    DIX: Add strcasestr from FreeBSD
    
    Add strcasestr for use on systems which don't have it.
    (cherry picked from ad87c72edcc0d1f56658e0c4e73af335c8d5a516 commit)

diff --git a/configure.ac b/configure.ac
index 4bf86b3..6b3b1ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1018,6 +1018,8 @@ AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
                                         [Do not have 'strcasecmp'.]))
 AC_CHECK_FUNC(strncasecmp, [], AC_DEFINE([NEED_STRNCASECMP], 1,
                                         [Do not have 'strncasecmp'.]))
+AC_CHECK_FUNC(strcasestr, [], AC_DEFINE([NEED_STRCASESTR], 1,
+                                       [Do not have 'strcasestr'.]))
 
 if test "x$NULL_ROOT_CURSOR" = xyes; then
         AC_DEFINE(NULL_ROOT_CURSOR, 1, [Use an empty root cursor])
diff --git a/dix/Makefile.am b/dix/Makefile.am
index e44b510..eb5e779 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -40,7 +40,8 @@ libdix_la_SOURCES = 	\
 	swapreq.c	\
 	tables.c	\
 	window.c	\
-	strcasecmp.c
+	strcasecmp.c	\
+	strcasestr.c
 
 libxpstubs_la_SOURCES =	\
 	xpstubs.c
diff --git a/dix/strcasestr.c b/dix/strcasestr.c
new file mode 100644
index 0000000..b3d4549
--- /dev/null
+++ b/dix/strcasestr.c
@@ -0,0 +1,64 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *      The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <ctype.h>
+#include <string.h>
+#include "dix.h"
+
+/*
+ * Find the first occurrence of find in s, ignore case.
+ */
+#ifdef NEED_STRCASESTR
+char *
+xstrcasestr(const char *s, const char *find)
+{
+        char c, sc;
+        size_t len;
+
+        if ((c = *find++) != 0) {
+                c = tolower((unsigned char)c);
+                len = strlen(find);
+                do {
+                        do {
+                                if ((sc = *s++) == 0)
+                                        return (NULL);
+                        } while ((char)tolower((unsigned char)sc) != c);
+                } while (strncasecmp(s, find, len) != 0);
+                s--;
+        }
+        return ((char *)s);
+}
+#endif
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 55cebb6..b038c0e 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -521,4 +521,7 @@
 /* Need the strncasecmp function. */
 #undef NEED_STRNCASECMP
 
+/* Need the strcasestr function. */
+#undef NEED_STRCASESTR
+
 #endif /* _DIX_CONFIG_H_ */
diff --git a/include/dix.h b/include/dix.h
index a321757..ea83e11 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -564,6 +564,11 @@ extern int xstrcasecmp(const char *s1, const char *s2);
 extern int xstrncasecmp(const char *s1, const char *s2, size_t n);
 #endif
 
+#if NEED_STRCASESTR
+#define strcasestr xstrcasestr
+extern int xstrcasestr(const char *s, const char *find);
+#endif
+
 /*
  * These are deprecated compatibility functions and will be removed soon!
  * Please use the noted replacements instead.
commit ce10b41f1b3f8c9be705823b0c0f0379f2bcb516
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jul 16 02:03:36 2008 +0300

    dix: Actually build str(n)casecmp if we don't have it
    
    Remember to add stuff to dix-config.h when you add new AC_DEFINES,
    people ...
    (cherry picked from 69b57dc651e12a0d9a5a4295b185c62d5c0df63f commit)

diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 9468ad0..55cebb6 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -199,9 +199,6 @@
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
-/* Define to 1 if you have the `strcasestr' function. */
-#undef HAVE_STRCASESTR
-
 /* Define to 1 if you have the `strchr' function. */
 #undef HAVE_STRCHR
 
@@ -518,4 +515,10 @@
 /* Define to 64-bit byteswap macro */
 #undef bswap_64
 
+/* Need the strcasecmp function. */
+#undef NEED_STRCASECMP
+
+/* Need the strncasecmp function. */
+#undef NEED_STRNCASECMP
+
 #endif /* _DIX_CONFIG_H_ */
commit 8a319335fa960be04f85a119ed557e62101021ec
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jul 16 01:57:00 2008 +0300

    strcasecmp: Actually use the right license
    
    Forgot to update the license when I committed the FreeBSD version, so it
    still had an old SGI license.  Sorry.  Sorry.
    (cherry picked from dcf6293030126509d7d6c61d131222037d5ed7db commit)

diff --git a/dix/strcasecmp.c b/dix/strcasecmp.c
index 8f7c5c4..ca1051d 100644
--- a/dix/strcasecmp.c
+++ b/dix/strcasecmp.c
@@ -1,28 +1,31 @@
-/************************************************************
- Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
- ********************************************************/
+/*
+ * Copyright (c) 1987, 1993
+ *      The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
commit 5a5030af9b8c7a801f07c82feaf3d2eaf4784db3
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jun 11 15:09:46 2008 +0300

    DIX: Add strncasecmp from FreeBSD, make strcasecmp args const
    
    Add strncasecmp (as we're now using it) in case someone doesn't have it,
    and also change strncasecmp args to be const, in accordance with
    everything else.
    (cherry picked from 11f9e3520249a603b95e64503ee759998ff17feb commit)

diff --git a/dix/strcasecmp.c b/dix/strcasecmp.c
index 58f0961..8f7c5c4 100644
--- a/dix/strcasecmp.c
+++ b/dix/strcasecmp.c
@@ -33,7 +33,7 @@
 
 #ifdef NEED_STRCASECMP
 int
-xstrcasecmp(char *str1,char *str2)
+xstrcasecmp(const char *str1, const char *str2)
 {
     const u_char *us1 = (const u_char *)str1, *us2 = (const u_char *)str2;
 
@@ -46,3 +46,22 @@ xstrcasecmp(char *str1,char *str2)
     return (tolower(*us1) - tolower(*us2));
 }
 #endif
+
+#ifdef NEED_STRNCASECMP
+int
+xstrncasecmp(const char *s1, const char *s2, size_t n)
+{
+    if (n != 0) {
+        const u_char *us1 = (const u_char *)s1, *us2 = (const u_char *)s2;
+
+        do {
+            if (tolower(*us1) != tolower(*us2++))
+                return (tolower(*us1) - tolower(*--us2));
+            if (*us1++ == '\0')
+                break;
+        } while (--n != 0);
+    }
+
+    return 0;
+}
+#endif
diff --git a/include/dix.h b/include/dix.h
index 0790f58..a321757 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -556,7 +556,12 @@ typedef struct {
 /* strcasecmp.c */
 #if NEED_STRCASECMP
 #define strcasecmp xstrcasecmp
-extern int xstrcasecmp(char *s1, char *s2);
+extern int xstrcasecmp(const char *s1, const char *s2);
+#endif
+
+#if NEED_STRNCASECMP
+#define strncasecmp xstrncasecmp
+extern int xstrncasecmp(const char *s1, const char *s2, size_t n);
 #endif
 
 /*


More information about the xorg-commit mailing list