| Attached Files | 0001-updated-Android-build-to-use-gcc-sysroot-technique-f.patch [^] (3,545 bytes) 2012-05-05 05:21 [Show Content] [Hide Content]From 04f34cd98b3833bbba6fbe5f7ee8296f4d2a28bd Mon Sep 17 00:00:00 2001
From: Hans-Christoph Steiner <hans@eds.org>
Date: Wed, 1 Feb 2012 15:00:14 -0500
Subject: [PATCH 01/10] updated Android build to use "gcc --sysroot" technique, first available in NDKr4
---
make/Makefile.android | 62 +++++++++++++++++++-----------------------------
1 files changed, 25 insertions(+), 37 deletions(-)
diff --git a/make/Makefile.android b/make/Makefile.android
index 0b57a84..fabef9c 100644
--- a/make/Makefile.android
+++ b/make/Makefile.android
@@ -37,15 +37,15 @@ MANDIR =
SRCS += $(wildcard src/linux/*.c src/unix/*.c)
HDRS += $(wildcard src/linux/*.h src/unix/*.h)
-CPPFLAGS += -Dlinux -DLINUX_NETLINK_ROUTING
-CPPFLAGS += -Dandroid
+CPPFLAGS += -Dlinux -DLINUX_NETLINK_ROUTING
-# bionic libc: missing declaration
-CPPFLAGS += -DINET_ADDRSTRLEN=16
+CPPFLAGS += -DOLSRD_GLOBAL_CONF_FILE=\"$(CFGFILE)\"
# bionic libc: missing declarations
+CPPFLAGS += -DINET_ADDRSTRLEN=16
CPPFLAGS += -D'IPTOS_PREC(tos)=((tos)&0xe0)'
CPPFLAGS += -D'IPTOS_TOS(tos)=((tos)&0x1e)'
-CPPFLAGS += -DOLSRD_GLOBAL_CONF_FILE=\"$(CFGFILE)\"
+# Android NDK is missing linux/if_tunnel.h, we have it here:
+CPPFLAGS += -I$(TOPDIR)/android
# Compilation flags from build/toolchains/arm-eabi-4.2.1/setup.mk
CPPFLAGS += \
@@ -70,51 +70,39 @@ CPPFLAGS += \
-fno-strict-aliasing
endif
-PLUGIN_SONAME ?= $(PLUGIN_NAME)
-PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so.$(PLUGIN_VER)
-INSTALL_LIB = install -D -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); \
- /sbin/ldconfig -n $(LIBDIR)
-UNINSTALL_LIB = rm -f $(LIBDIR)/$(PLUGIN_FULLNAME); \
- /sbin/ldconfig -n $(LIBDIR)
-
ifdef OLSRD_PLUGIN
GENERATE_PIC = true
endif
+LDFLAGS += -llog
+
ifdef GENERATE_PIC
CFLAGS += -fPIC
LDFLAGS += -fPIC
endif
-NDK = /opt/android-ndk-r4b
-NDK_ARCH = $(NDK)/build/platforms/android-3/arch-arm
+PLUGIN_SONAME ?= $(PLUGIN_NAME)
+PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so.$(PLUGIN_VER)
+INSTALL_LIB = install -D -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); \
+ /sbin/ldconfig -n $(LIBDIR)
+UNINSTALL_LIB = rm -f $(LIBDIR)/$(PLUGIN_FULLNAME); \
+ /sbin/ldconfig -n $(LIBDIR)
+
+HOST = arm-linux-androideabi
+NDK_BASE = /opt/android-ndk
+CURRENT_SYSTEM := $(shell uname -s | tr A-Z a-z)
+NDK_TOOLCHAIN_BASE = $(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(CURRENT_SYSTEM)-x86
+# we need regex.h, which wasn't added until android-8
+NDK_PLATFORM_VERSION = 8
+NDK_SYSROOT = $(NDK_BASE)/platforms/android-$(NDK_PLATFORM_VERSION)/arch-arm
+CROSS_COMPILE = $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-
-ifneq ($(shell uname -m),armv6l)
-# You are not compiling with Debian direct on the phone
-CURRENT_SYSTEM = $(shell uname -s | tr A-Z a-z)
-CROSS_COMPILE = $(NDK)/build/prebuilt/$(CURRENT_SYSTEM)-x86/arm-eabi-4.2.1/bin/arm-eabi-
-CC = $(CROSS_COMPILE)gcc
+CC = $(CROSS_COMPILE)gcc --sysroot="$(NDK_SYSROOT)"
+LD = $(CROSS_COMPILE)ld
+AR = $(CROSS_COMPILE)ar
ifeq ($(DEBUG),0)
STRIP = $(CROSS_COMPILE)strip
endif
-endif
-
-CFLAGS += -I$(NDK_ARCH)/usr/include
-CFLAGS += -I$(TOPDIR)/android
-
-LDFLAGS += -nostartfiles -nodefaultlibs -nostdlib -Bdynamic
-LDFLAGS += -Wl,--dynamic-linker -Wl,/system/bin/linker
-LDFLAGS += -L$(NDK_ARCH)/usr/lib
-LDFLAGS += -Wl,-rpath-link -Wl,$(NDK_ARCH)/usr/lib
-LDFLAGS += -llog
-ifndef OLSRD_PLUGIN
-LDFLAGS += $(NDK_ARCH)/usr/lib/crtbegin_dynamic.o
-endif
-
-LIBS += -Wl,-lc -Wl,-lm -Wl,-lgcc
-ifndef OLSRD_PLUGIN
-LIBS += $(NDK_ARCH)/usr/lib/crtend_android.o
-endif
# Local Variables:
# mode: makefile
--
1.7.4.1
0004-updated-regex-for-Android-directly-from-Android-s-so.patch [^] (64,062 bytes) 2012-05-05 05:22 [Show Content] [Hide Content]From 57c3db80ca9fd14b98e0121cd5253d10538d76f7 Mon Sep 17 00:00:00 2001
From: Hans-Christoph Steiner <hans@eds.org>
Date: Wed, 4 Apr 2012 19:03:15 -0400
Subject: [PATCH 04/10] updated regex for Android directly from Android's sources, which are also OpenBSD-derived
---
android/regex/NOTICE | 382 +++++++++++++++++++++++
android/regex/cclass.h | 2 +-
android/regex/cname.h | 2 +-
android/regex/engine.c | 7 +-
android/regex/re_format.7 | 756 ---------------------------------------------
android/regex/regcomp.c | 20 +-
android/regex/regerror.c | 8 +-
android/regex/regex.3 | 667 ---------------------------------------
android/regex/regexec.c | 2 +-
android/regex/regfree.c | 1 -
android/regex/utils.h | 2 +-
11 files changed, 404 insertions(+), 1445 deletions(-)
create mode 100644 android/regex/NOTICE
delete mode 100644 android/regex/re_format.7
delete mode 100644 android/regex/regex.3
diff --git a/android/regex/NOTICE b/android/regex/NOTICE
new file mode 100644
index 0000000..d9e6818
--- /dev/null
+++ b/android/regex/NOTICE
@@ -0,0 +1,382 @@
+
+Copyright (c) 2005-2010, The Android Open Source Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * 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.
+ * Neither the name of The Android Open Source Project 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 COPYRIGHT HOLDERS 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
+COPYRIGHT OWNER 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.
+
+
+Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+Copyright (c) 1995,1996,1999 by Internet Software Consortium.
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ANY SPECIAL, DIRECT, 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.
+
+
+Portions Copyright (c) 1995 by International Business Machines, Inc.
+
+International Business Machines, Inc. (hereinafter called IBM) grants
+permission under its copyrights to use, copy, modify, and distribute this
+Software with or without fee, provided that the above copyright notice and
+all paragraphs of this notice appear in all copies, and that the name of IBM
+not be used in connection with the marketing of any product incorporating
+the Software or modifications thereof, without specific, written prior
+permission.
+
+To the extent it has a right to do so, IBM grants an immunity from suit
+under its patents, if any, for the use, sale or manufacture of products to
+the extent that such products are used for performing Domain Name System
+dynamic updates in TCP/IP networks by means of the Software. No immunity is
+granted for any product per se or for any other function of any product.
+
+THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc.
+All rights reserved.
+
+This code is derived from software contributed to The NetBSD Foundation
+by Luke Mewburn; and by Jason R. Thorpe.
+This code is derived from software contributed to The NetBSD Foundation
+by Christos Zoulas.
+
+Copyright (c) 1993 Christopher G. Demetriou
+Copyright (c) 1983, 1985, 1993 The Regents of the University of California. All rights reserved.
+Copyright (c) 2000 Ben Harris.
+Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+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.
+3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
+
+Copyright (c) 2003 Networks Associates Technology, Inc.
+All rights reserved.
+
+Portions of this software were developed for the FreeBSD Project by
+Jacques A. Vidrine, Safeport Network Services, and Network
+Associates Laboratories, the Security Research Division of Network
+Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
+("CBOSS"), as part of the DARPA CHATS research program.
+
+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.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+
+Portions Copyright (c) 1993 by Digital Equipment Corporation.
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies, and that
+the name of Digital Equipment Corporation not be used in advertising or
+publicity pertaining to distribution of the document or software without
+specific, written prior permission.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, 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) 1997 Mark Brinicombe
+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.
+3. All advertising materials mentioning features or use of this software
+ must display the following acknowledgement:
+ This product includes software developed by Mark Brinicombe
+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 AUTHOR 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 AUTHOR 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.
+
+
+Copyright (c) 1993 Martin Birgmeier
+All rights reserved.
+
+You may redistribute unmodified or modified versions of this source
+code provided that the above copyright notice and this and the
+following conditions are retained.
+
+This software is provided ``as is'', and comes with no warranties
+of any kind. I shall in no event be liable for anything that happens
+to anyone/anything when using this software.
+
+
+Arc4 random number generator for OpenBSD.
+Copyright 1996 David Mazieres <dm@lcs.mit.edu>.
+
+Modification and redistribution in source and binary forms is
+permitted provided that due credit is given to the author and the
+OpenBSD project by leaving this copyright notice intact.
+
+
+Copyright (c) 1999 Kungliga Tekniska Högskolan
+(Royal Institute of Technology, Stockholm, Sweden).
+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.
+
+3. Neither the name of KTH 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 KTH AND ITS 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 KTH OR ITS 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. */
+
+
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+====================================================
+
+
+Copyright (c) 1997, 2005 Todd C. Miller <Todd.Miller@courtesan.com>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, 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) 1989, 1993
+ The Regents of the University of California. All rights reserved.
+(c) UNIX System Laboratories, Inc.
+All or some portions of this file are derived from material licensed
+to the University of California by American Telephone and Telegraph
+Co. or Unix System Laboratories, Inc. and are reproduced herein with
+the permission of UNIX System Laboratories, Inc.
+
+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.
+3. 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.
+
+
+Copyright (c) 1995, 1996 Carnegie-Mellon University.
+All rights reserved.
+
+Author: Chris G. Demetriou
+
+Permission to use, copy, modify and distribute this software and
+its documentation is hereby granted, provided that both the copyright
+notice and this permission notice appear in all copies of the
+software, derivative works or modified versions, and any portions
+thereof, and that both notices appear in supporting documentation.
+
+CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+
+Carnegie Mellon requests users of this software to return to
+
+ Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ School of Computer Science
+ Carnegie Mellon University
+ Pittsburgh PA 15213-3890
+
+any improvements or extensions that they make and grant Carnegie the
+rights to redistribute these changes.
+
+
+Copyright (c) 1995, 1996 Carnegie-Mellon University.
+All rights reserved.
+
+Author: Chris G. Demetriou
+
+Permission to use, copy, modify and distribute this software and
+its documentation is hereby granted, provided that both the copyright
+notice and this permission notice appear in all copies of the
+software, derivative works or modified versions, and any portions
+thereof, and that both notices appear in supporting documentation.
+
+CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+
+Carnegie Mellon requests users of this software to return to
+
+ Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ School of Computer Science
+ Carnegie Mellon University
+ Pittsburgh PA 15213-3890
+
+any improvements or extensions that they make and grant Carnegie the
+rights to redistribute these changes.
+
+
+Copyright (c) 2003 Networks Associates Technology, Inc.
+All rights reserved.
+
+Portions of this software were developed for the FreeBSD Project by
+Jacques A. Vidrine, Safeport Network Services, and Network
+Associates Laboratories, the Security Research Division of Network
+Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
+("CBOSS"), as part of the DARPA CHATS research program.
+
+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.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+
+
diff --git a/android/regex/cclass.h b/android/regex/cclass.h
index 9f144a6..d105491 100644
--- a/android/regex/cclass.h
+++ b/android/regex/cclass.h
@@ -36,7 +36,7 @@
*/
/* character-class table */
-static struct cclass {
+static const struct cclass {
char *name;
char *chars;
char *multis;
diff --git a/android/regex/cname.h b/android/regex/cname.h
index 9cce44e..b674b68 100644
--- a/android/regex/cname.h
+++ b/android/regex/cname.h
@@ -36,7 +36,7 @@
*/
/* character-name table */
-static struct cname {
+static const struct cname {
char *name;
char code;
} cnames[] = {
diff --git a/android/regex/engine.c b/android/regex/engine.c
index 024c4ea..eae6ff2 100644
--- a/android/regex/engine.c
+++ b/android/regex/engine.c
@@ -209,7 +209,7 @@ matcher(struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[],
STATETEARDOWN(m);
return(REG_ESPACE);
}
- for (i = 1; i <= m->g->nsub; i++)
+ for (i = 1; i <= (int)m->g->nsub; i++)
m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1;
if (!g->backrefs && !(m->eflags®_BACKR)) {
NOTE("dissecting");
@@ -267,8 +267,8 @@ matcher(struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[],
}
if (nmatch > 1) {
assert(m->pmatch != NULL);
- for (i = 1; i < nmatch; i++)
- if (i <= m->g->nsub)
+ for (i = 1; i < (ssize_t)nmatch; i++)
+ if (i <= (int)m->g->nsub)
pmatch[i] = m->pmatch[i];
else {
pmatch[i].rm_so = -1;
@@ -662,6 +662,7 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst,
/* "can't happen" */
assert(nope);
/* NOTREACHED */
+ return 0;
}
/*
diff --git a/android/regex/re_format.7 b/android/regex/re_format.7
deleted file mode 100644
index 0c09287..0000000
--- a/android/regex/re_format.7
+++ /dev/null
@@ -1,756 +0,0 @@
-.\" $OpenBSD: re_format.7,v 1.14 2007/05/31 19:19:30 jmc Exp $
-.\"
-.\" Copyright (c) 1997, Phillip F Knaack. All rights reserved.
-.\"
-.\" Copyright (c) 1992, 1993, 1994 Henry Spencer.
-.\" Copyright (c) 1992, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Henry Spencer.
-.\"
-.\" 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.
-.\" 3. 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.
-.\"
-.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94
-.\"
-.Dd $Mdocdate: May 31 2007 $
-.Dt RE_FORMAT 7
-.Os
-.Sh NAME
-.Nm re_format
-.Nd POSIX regular expressions
-.Sh DESCRIPTION
-Regular expressions (REs),
-as defined in
-.St -p1003.1-2004 ,
-come in two forms:
-basic regular expressions
-(BREs)
-and extended regular expressions
-(EREs).
-Both forms of regular expressions are supported
-by the interfaces described in
-.Xr regex 3 .
-Applications dealing with regular expressions
-may use one or the other form
-(or indeed both).
-For example,
-.Xr ed 1
-uses BREs,
-whilst
-.Xr egrep 1
-talks EREs.
-Consult the manual page for the specific application to find out which
-it uses.
-.Pp
-POSIX leaves some aspects of RE syntax and semantics open;
-.Sq **
-marks decisions on these aspects that
-may not be fully portable to other POSIX implementations.
-.Pp
-This manual page first describes regular expressions in general,
-specifically extended regular expressions,
-and then discusses differences between them and basic regular expressions.
-.Sh EXTENDED REGULAR EXPRESSIONS
-An ERE is one** or more non-empty**
-.Em branches ,
-separated by
-.Sq \*(Ba .
-It matches anything that matches one of the branches.
-.Pp
-A branch is one** or more
-.Em pieces ,
-concatenated.
-It matches a match for the first, followed by a match for the second, etc.
-.Pp
-A piece is an
-.Em atom
-possibly followed by a single**
-.Sq * ,
-.Sq + ,
-.Sq ?\& ,
-or
-.Em bound .
-An atom followed by
-.Sq *
-matches a sequence of 0 or more matches of the atom.
-An atom followed by
-.Sq +
-matches a sequence of 1 or more matches of the atom.
-An atom followed by
-.Sq ?\&
-matches a sequence of 0 or 1 matches of the atom.
-.Pp
-A bound is
-.Sq {
-followed by an unsigned decimal integer,
-possibly followed by
-.Sq ,\&
-possibly followed by another unsigned decimal integer,
-always followed by
-.Sq } .
-The integers must lie between 0 and
-.Dv RE_DUP_MAX
-(255**) inclusive,
-and if there are two of them, the first may not exceed the second.
-An atom followed by a bound containing one integer
-.Ar i
-and no comma matches
-a sequence of exactly
-.Ar i
-matches of the atom.
-An atom followed by a bound
-containing one integer
-.Ar i
-and a comma matches
-a sequence of
-.Ar i
-or more matches of the atom.
-An atom followed by a bound
-containing two integers
-.Ar i
-and
-.Ar j
-matches a sequence of
-.Ar i
-through
-.Ar j
-(inclusive) matches of the atom.
-.Pp
-An atom is a regular expression enclosed in
-.Sq ()
-(matching a part of the regular expression),
-an empty set of
-.Sq ()
-(matching the null string)**,
-a
-.Em bracket expression
-(see below),
-.Sq .\&
-(matching any single character),
-.Sq ^
-(matching the null string at the beginning of a line),
-.Sq $
-(matching the null string at the end of a line),
-a
-.Sq \e
-followed by one of the characters
-.Sq ^.[$()|*+?{\e
-(matching that character taken as an ordinary character),
-a
-.Sq \e
-followed by any other character**
-(matching that character taken as an ordinary character,
-as if the
-.Sq \e
-had not been present**),
-or a single character with no other significance (matching that character).
-A
-.Sq {
-followed by a character other than a digit is an ordinary character,
-not the beginning of a bound**.
-It is illegal to end an RE with
-.Sq \e .
-.Pp
-A bracket expression is a list of characters enclosed in
-.Sq [] .
-It normally matches any single character from the list (but see below).
-If the list begins with
-.Sq ^ ,
-it matches any single character
-.Em not
-from the rest of the list
-(but see below).
-If two characters in the list are separated by
-.Sq - ,
-this is shorthand for the full
-.Em range
-of characters between those two (inclusive) in the
-collating sequence, e.g.\&
-.Sq [0-9]
-in ASCII matches any decimal digit.
-It is illegal** for two ranges to share an endpoint, e.g.\&
-.Sq a-c-e .
-Ranges are very collating-sequence-dependent,
-and portable programs should avoid relying on them.
-.Pp
-To include a literal
-.Sq ]\&
-in the list, make it the first character
-(following a possible
-.Sq ^ ) .
-To include a literal
-.Sq - ,
-make it the first or last character,
-or the second endpoint of a range.
-To use a literal
-.Sq -
-as the first endpoint of a range,
-enclose it in
-.Sq [.
-and
-.Sq .]
-to make it a collating element (see below).
-With the exception of these and some combinations using
-.Sq [
-(see next paragraphs),
-all other special characters, including
-.Sq \e ,
-lose their special significance within a bracket expression.
-.Pp
-Within a bracket expression, a collating element
-(a character,
-a multi-character sequence that collates as if it were a single character,
-or a collating-sequence name for either)
-enclosed in
-.Sq [.
-and
-.Sq .]
-stands for the sequence of characters of that collating element.
-The sequence is a single element of the bracket expression's list.
-A bracket expression containing a multi-character collating element
-can thus match more than one character,
-e.g. if the collating sequence includes a
-.Sq ch
-collating element,
-then the RE
-.Sq [[.ch.]]*c
-matches the first five characters of
-.Sq chchcc .
-.Pp
-Within a bracket expression, a collating element enclosed in
-.Sq [=
-and
-.Sq =]
-is an equivalence class, standing for the sequences of characters
-of all collating elements equivalent to that one, including itself.
-(If there are no other equivalent collating elements,
-the treatment is as if the enclosing delimiters were
-.Sq [.
-and
-.Sq .] . )
-For example, if
-.Sq x
-and
-.Sq y
-are the members of an equivalence class,
-then
-.Sq [[=x=]] ,
-.Sq [[=y=]] ,
-and
-.Sq [xy]
-are all synonymous.
-An equivalence class may not** be an endpoint of a range.
-.Pp
-Within a bracket expression, the name of a
-.Em character class
-enclosed
-in
-.Sq [:
-and
-.Sq :]
-stands for the list of all characters belonging to that class.
-Standard character class names are:
-.Bd -literal -offset indent
-alnum digit punct
-alpha graph space
-blank lower upper
-cntrl print xdigit
-.Ed
-.Pp
-These stand for the character classes defined in
-.Xr ctype 3 .
-A locale may provide others.
-A character class may not be used as an endpoint of a range.
-.Pp
-There are two special cases** of bracket expressions:
-the bracket expressions
-.Sq [[:<:]]
-and
-.Sq [[:>:]]
-match the null string at the beginning and end of a word, respectively.
-A word is defined as a sequence of
-characters starting and ending with a word character
-which is neither preceded nor followed by
-word characters.
-A word character is an
-.Em alnum
-character (as defined by
-.Xr ctype 3 )
-or an underscore.
-This is an extension,
-compatible with but not specified by POSIX,
-and should be used with
-caution in software intended to be portable to other systems.
-.Pp
-In the event that an RE could match more than one substring of a given
-string,
-the RE matches the one starting earliest in the string.
-If the RE could match more than one substring starting at that point,
-it matches the longest.
-Subexpressions also match the longest possible substrings, subject to
-the constraint that the whole match be as long as possible,
-with subexpressions starting earlier in the RE taking priority over
-ones starting later.
-Note that higher-level subexpressions thus take priority over
-their lower-level component subexpressions.
-.Pp
-Match lengths are measured in characters, not collating elements.
-A null string is considered longer than no match at all.
-For example,
-.Sq bb*
-matches the three middle characters of
-.Sq abbbc ;
-.Sq (wee|week)(knights|nights)
-matches all ten characters of
-.Sq weeknights ;
-when
-.Sq (.*).*
-is matched against
-.Sq abc ,
-the parenthesized subexpression matches all three characters;
-and when
-.Sq (a*)*
-is matched against
-.Sq bc ,
-both the whole RE and the parenthesized subexpression match the null string.
-.Pp
-If case-independent matching is specified,
-the effect is much as if all case distinctions had vanished from the
-alphabet.
-When an alphabetic that exists in multiple cases appears as an
-ordinary character outside a bracket expression, it is effectively
-transformed into a bracket expression containing both cases,
-e.g.\&
-.Sq x
-becomes
-.Sq [xX] .
-When it appears inside a bracket expression,
-all case counterparts of it are added to the bracket expression,
-so that, for example,
-.Sq [x]
-becomes
-.Sq [xX]
-and
-.Sq [^x]
-becomes
-.Sq [^xX] .
-.Pp
-No particular limit is imposed on the length of REs**.
-Programs intended to be portable should not employ REs longer
-than 256 bytes,
-as an implementation can refuse to accept such REs and remain
-POSIX-compliant.
-.Pp
-The following is a list of extended regular expressions:
-.Bl -tag -width Ds
-.It Ar c
-Any character
-.Ar c
-not listed below matches itself.
-.It \e Ns Ar c
-Any backslash-escaped character
-.Ar c
-matches itself.
-.It \&.
-Matches any single character that is not a newline
-.Pq Sq \en .
-.It Bq Ar char-class
-Matches any single character in
-.Ar char-class .
-To include a
-.Ql \&]
-in
-.Ar char-class ,
-it must be the first character.
-A range of characters may be specified by separating the end characters
-of the range with a
-.Ql - ;
-e.g.\&
-.Ar a-z
-specifies the lower case characters.
-The following literal expressions can also be used in
-.Ar char-class
-to specify sets of characters:
-.Bd -unfilled -offset indent
-[:alnum:] [:cntrl:] [:lower:] [:space:]
-[:alpha:] [:digit:] [:print:] [:upper:]
-[:blank:] [:graph:] [:punct:] [:xdigit:]
-.Ed
-.Pp
-If
-.Ql -
-appears as the first or last character of
-.Ar char-class ,
-then it matches itself.
-All other characters in
-.Ar char-class
-match themselves.
-.Pp
-Patterns in
-.Ar char-class
-of the form
-.Eo [.
-.Ar col-elm
-.Ec .]\&
-or
-.Eo [=
-.Ar col-elm
-.Ec =]\& ,
-where
-.Ar col-elm
-is a collating element, are interpreted according to
-.Xr setlocale 3
-.Pq not currently supported .
-.It Bq ^ Ns Ar char-class
-Matches any single character, other than newline, not in
-.Ar char-class .
-.Ar char-class
-is defined as above.
-.It ^
-If
-.Sq ^
-is the first character of a regular expression, then it
-anchors the regular expression to the beginning of a line.
-Otherwise, it matches itself.
-.It $
-If
-.Sq $
-is the last character of a regular expression,
-it anchors the regular expression to the end of a line.
-Otherwise, it matches itself.
-.It [[:<:]]
-Anchors the single character regular expression or subexpression
-immediately following it to the beginning of a word.
-.It [[:>:]]
-Anchors the single character regular expression or subexpression
-immediately following it to the end of a word.
-.It Pq Ar re
-Defines a subexpression
-.Ar re .
-Any set of characters enclosed in parentheses
-matches whatever the set of characters without parentheses matches
-(that is a long-winded way of saying the constructs
-.Sq (re)
-and
-.Sq re
-match identically).
-.It *
-Matches the single character regular expression or subexpression
-immediately preceding it zero or more times.
-If
-.Sq *
-is the first character of a regular expression or subexpression,
-then it matches itself.
-The
-.Sq *
-operator sometimes yields unexpected results.
-For example, the regular expression
-.Ar b*
-matches the beginning of the string
-.Qq abbb
-(as opposed to the substring
-.Qq bbb ) ,
-since a null match is the only leftmost match.
-.It +
-Matches the singular character regular expression
-or subexpression immediately preceding it
-one or more times.
-.It ?
-Matches the singular character regular expression
-or subexpression immediately preceding it
-0 or 1 times.
-.Sm off
-.It Xo
-.Pf { Ar n , m No }\ \&
-.Pf { Ar n , No }\ \&
-.Pf { Ar n No }
-.Xc
-.Sm on
-Matches the single character regular expression or subexpression
-immediately preceding it at least
-.Ar n
-and at most
-.Ar m
-times.
-If
-.Ar m
-is omitted, then it matches at least
-.Ar n
-times.
-If the comma is also omitted, then it matches exactly
-.Ar n
-times.
-.It \*(Ba
-Used to separate patterns.
-For example,
-the pattern
-.Sq cat\*(Badog
-matches either
-.Sq cat
-or
-.Sq dog .
-.El
-.Sh BASIC REGULAR EXPRESSIONS
-Basic regular expressions differ in several respects:
-.Bl -bullet -offset 3n
-.It
-.Sq \*(Ba ,
-.Sq + ,
-and
-.Sq ?\&
-are ordinary characters and there is no equivalent
-for their functionality.
-.It
-The delimiters for bounds are
-.Sq \e{
-and
-.Sq \e} ,
-with
-.Sq {
-and
-.Sq }
-by themselves ordinary characters.
-.It
-The parentheses for nested subexpressions are
-.Sq \e(
-and
-.Sq \e) ,
-with
-.Sq (
-and
-.Sq )\&
-by themselves ordinary characters.
-.It
-.Sq ^
-is an ordinary character except at the beginning of the
-RE or** the beginning of a parenthesized subexpression.
-.It
-.Sq $
-is an ordinary character except at the end of the
-RE or** the end of a parenthesized subexpression.
-.It
-.Sq *
-is an ordinary character if it appears at the beginning of the
-RE or the beginning of a parenthesized subexpression
-(after a possible leading
-.Sq ^ ) .
-.It
-Finally, there is one new type of atom, a
-.Em back-reference :
-.Sq \e
-followed by a non-zero decimal digit
-.Ar d
-matches the same sequence of characters matched by the
-.Ar d Ns th
-parenthesized subexpression
-(numbering subexpressions by the positions of their opening parentheses,
-left to right),
-so that, for example,
-.Sq \e([bc]\e)\e1
-matches
-.Sq bb\&
-or
-.Sq cc
-but not
-.Sq bc .
-.El
-.Pp
-The following is a list of basic regular expressions:
-.Bl -tag -width Ds
-.It Ar c
-Any character
-.Ar c
-not listed below matches itself.
-.It \e Ns Ar c
-Any backslash-escaped character
-.Ar c ,
-except for
-.Sq { ,
-.Sq } ,
-.Sq \&( ,
-and
-.Sq \&) ,
-matches itself.
-.It \&.
-Matches any single character that is not a newline
-.Pq Sq \en .
-.It Bq Ar char-class
-Matches any single character in
-.Ar char-class .
-To include a
-.Ql \&]
-in
-.Ar char-class ,
-it must be the first character.
-A range of characters may be specified by separating the end characters
-of the range with a
-.Ql - ;
-e.g.\&
-.Ar a-z
-specifies the lower case characters.
-The following literal expressions can also be used in
-.Ar char-class
-to specify sets of characters:
-.Bd -unfilled -offset indent
-[:alnum:] [:cntrl:] [:lower:] [:space:]
-[:alpha:] [:digit:] [:print:] [:upper:]
-[:blank:] [:graph:] [:punct:] [:xdigit:]
-.Ed
-.Pp
-If
-.Ql -
-appears as the first or last character of
-.Ar char-class ,
-then it matches itself.
-All other characters in
-.Ar char-class
-match themselves.
-.Pp
-Patterns in
-.Ar char-class
-of the form
-.Eo [.
-.Ar col-elm
-.Ec .]\&
-or
-.Eo [=
-.Ar col-elm
-.Ec =]\& ,
-where
-.Ar col-elm
-is a collating element, are interpreted according to
-.Xr setlocale 3
-.Pq not currently supported .
-.It Bq ^ Ns Ar char-class
-Matches any single character, other than newline, not in
-.Ar char-class .
-.Ar char-class
-is defined as above.
-.It ^
-If
-.Sq ^
-is the first character of a regular expression, then it
-anchors the regular expression to the beginning of a line.
-Otherwise, it matches itself.
-.It $
-If
-.Sq $
-is the last character of a regular expression,
-it anchors the regular expression to the end of a line.
-Otherwise, it matches itself.
-.It [[:<:]]
-Anchors the single character regular expression or subexpression
-immediately following it to the beginning of a word.
-.It [[:>:]]
-Anchors the single character regular expression or subexpression
-immediately following it to the end of a word.
-.It \e( Ns Ar re Ns \e)
-Defines a subexpression
-.Ar re .
-Subexpressions may be nested.
-A subsequent backreference of the form
-.Pf \e Ns Ar n ,
-where
-.Ar n
-is a number in the range [1,9], expands to the text matched by the
-.Ar n Ns th
-subexpression.
-For example, the regular expression
-.Ar \e(.*\e)\e1
-matches any string consisting of identical adjacent substrings.
-Subexpressions are ordered relative to their left delimiter.
-.It *
-Matches the single character regular expression or subexpression
-immediately preceding it zero or more times.
-If
-.Sq *
-is the first character of a regular expression or subexpression,
-then it matches itself.
-The
-.Sq *
-operator sometimes yields unexpected results.
-For example, the regular expression
-.Ar b*
-matches the beginning of the string
-.Qq abbb
-(as opposed to the substring
-.Qq bbb ) ,
-since a null match is the only leftmost match.
-.Sm off
-.It Xo
-.Pf \e{ Ar n , m No \e}\ \&
-.Pf \e{ Ar n , No \e}\ \&
-.Pf \e{ Ar n No \e}
-.Xc
-.Sm on
-Matches the single character regular expression or subexpression
-immediately preceding it at least
-.Ar n
-and at most
-.Ar m
-times.
-If
-.Ar m
-is omitted, then it matches at least
-.Ar n
-times.
-If the comma is also omitted, then it matches exactly
-.Ar n
-times.
-.El
-.Sh SEE ALSO
-.Xr ctype 3 ,
-.Xr regex 3
-.Sh STANDARDS
-.St -p1003.1-2004 :
-Base Definitions, Chapter 9 (Regular Expressions).
-.Sh BUGS
-Having two kinds of REs is a botch.
-.Pp
-The current POSIX spec says that
-.Sq )\&
-is an ordinary character in the absence of an unmatched
-.Sq ( ;
-this was an unintentional result of a wording error,
-and change is likely.
-Avoid relying on it.
-.Pp
-Back-references are a dreadful botch,
-posing major problems for efficient implementations.
-They are also somewhat vaguely defined
-(does
-.Sq a\e(\e(b\e)*\e2\e)*d
-match
-.Sq abbbd ? ) .
-Avoid using them.
-.Pp
-POSIX's specification of case-independent matching is vague.
-The
-.Dq one case implies all cases
-definition given above
-is the current consensus among implementors as to the right interpretation.
-.Pp
-The syntax for word boundaries is incredibly ugly.
diff --git a/android/regex/regcomp.c b/android/regex/regcomp.c
index 5b632c8..19f4790 100644
--- a/android/regex/regcomp.c
+++ b/android/regex/regcomp.c
@@ -249,8 +249,8 @@ static void
p_ere(struct parse *p, int stop) /* character this ERE should end at */
{
char c;
- sopno prevback;
- sopno prevfwd;
+ sopno prevback = 0;
+ sopno prevfwd = 0;
sopno conc;
int first = 1; /* is this the first alternative? */
@@ -767,7 +767,7 @@ static void
p_b_cclass(struct parse *p, cset *cs)
{
char *sp = p->next;
- struct cclass *cp;
+ const struct cclass *cp;
size_t len;
char *u;
char c;
@@ -831,7 +831,7 @@ p_b_coll_elem(struct parse *p,
int endc) /* name ended by endc,']' */
{
char *sp = p->next;
- struct cname *cp;
+ const struct cname *cp;
int len;
while (MORE() && !SEETWO(endc, ']'))
@@ -1084,7 +1084,7 @@ freeset(struct parse *p, cset *cs)
cset *top = &p->g->sets[p->g->ncsets];
size_t css = (size_t)p->g->csetsize;
- for (i = 0; i < css; i++)
+ for (i = 0; i < (ssize_t)css; i++)
CHsub(cs, i);
if (cs == top-1) /* recover only the easy case */
p->g->ncsets--;
@@ -1112,10 +1112,10 @@ freezeset(struct parse *p, cset *cs)
for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
if (cs2->hash == h && cs2 != cs) {
/* maybe */
- for (i = 0; i < css; i++)
+ for (i = 0; i < (ssize_t)css; i++)
if (!!CHIN(cs2, i) != !!CHIN(cs, i))
break; /* no */
- if (i == css)
+ if (i == (ssize_t)css)
break; /* yes */
}
@@ -1136,7 +1136,7 @@ firstch(struct parse *p, cset *cs)
int i;
size_t css = (size_t)p->g->csetsize;
- for (i = 0; i < css; i++)
+ for (i = 0; i < (ssize_t)css; i++)
if (CHIN(cs, i))
return((char)i);
assert(never);
@@ -1153,7 +1153,7 @@ nch(struct parse *p, cset *cs)
size_t css = (size_t)p->g->csetsize;
int n = 0;
- for (i = 0; i < css; i++)
+ for (i = 0; i < (ssize_t)css; i++)
if (CHIN(cs, i))
n++;
return(n);
@@ -1412,7 +1412,7 @@ static void
findmust(struct parse *p, struct re_guts *g)
{
sop *scan;
- sop *start; /* start initialized in the default case, after that */
+ sop *start = NULL; /* start initialized in the default case, after that */
sop *newstart; /* newstart was initialized in the OCHAR case */
sopno newlen;
sop s;
diff --git a/android/regex/regerror.c b/android/regex/regerror.c
index e75be18..838ec8f 100644
--- a/android/regex/regerror.c
+++ b/android/regex/regerror.c
@@ -46,7 +46,7 @@
static char *regatoi(const regex_t *, char *, int);
-static struct rerr {
+static const struct rerr {
int code;
char *name;
char *explain;
@@ -78,7 +78,7 @@ static struct rerr {
size_t
regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
{
- struct rerr *r;
+ const struct rerr *r;
size_t len;
int target = errcode &~ REG_ITOA;
char *s;
@@ -90,7 +90,7 @@ regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
for (r = rerrs; r->code != 0; r++)
if (r->code == target)
break;
-
+
if (errcode®_ITOA) {
if (r->code != 0) {
assert(strlen(r->name) < sizeof(convbuf));
@@ -117,7 +117,7 @@ regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
static char *
regatoi(const regex_t *preg, char *localbuf, int localbufsize)
{
- struct rerr *r;
+ const struct rerr *r;
for (r = rerrs; r->code != 0; r++)
if (strcmp(r->name, preg->re_endp) == 0)
diff --git a/android/regex/regex.3 b/android/regex/regex.3
deleted file mode 100644
index c851b8d..0000000
--- a/android/regex/regex.3
+++ /dev/null
@@ -1,667 +0,0 @@
-.\" $OpenBSD: regex.3,v 1.21 2007/05/31 19:19:30 jmc Exp $
-.\"
-.\" Copyright (c) 1997, Phillip F Knaack. All rights reserved.
-.\"
-.\" Copyright (c) 1992, 1993, 1994 Henry Spencer.
-.\" Copyright (c) 1992, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Henry Spencer.
-.\"
-.\" 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.
-.\" 3. 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.
-.\"
-.\" @(#)regex.3 8.4 (Berkeley) 3/20/94
-.\"
-.Dd $Mdocdate: May 31 2007 $
-.Dt REGEX 3
-.Os
-.Sh NAME
-.Nm regcomp ,
-.Nm regexec ,
-.Nm regerror ,
-.Nm regfree
-.Nd regular expression routines
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <regex.h>
-.Ft int
-.Fn regcomp "regex_t *preg" "const char *pattern" "int cflags"
-.Pp
-.Ft int
-.Fn regexec "const regex_t *preg" "const char *string" "size_t nmatch" \
- "regmatch_t pmatch[]" "int eflags"
-.Pp
-.Ft size_t
-.Fn regerror "int errcode" "const regex_t *preg" "char *errbuf" \
- "size_t errbuf_size"
-.Pp
-.Ft void
-.Fn regfree "regex_t *preg"
-.Sh DESCRIPTION
-These routines implement
-.St -p1003.2
-regular expressions
-.Pq Dq REs ;
-see
-.Xr re_format 7 .
-.Fn regcomp
-compiles an RE written as a string into an internal form,
-.Fn regexec
-matches that internal form against a string and reports results,
-.Fn regerror
-transforms error codes from either into human-readable messages, and
-.Fn regfree
-frees any dynamically allocated storage used by the internal form
-of an RE.
-.Pp
-The header
-.Aq Pa regex.h
-declares two structure types,
-.Li regex_t
-and
-.Li regmatch_t ,
-the former for compiled internal forms and the latter for match reporting.
-It also declares the four functions,
-a type
-.Li regoff_t ,
-and a number of constants with names starting with
-.Dv REG_ .
-.Pp
-.Fn regcomp
-compiles the regular expression contained in the
-.Fa pattern
-string,
-subject to the flags in
-.Fa cflags ,
-and places the results in the
-.Li regex_t
-structure pointed to by
-.Fa preg .
-.Fa cflags
-is the bitwise
-.Tn OR
-of zero or more of the following flags:
-.Bl -tag -width XREG_EXTENDEDX
-.It Dv REG_EXTENDED
-Compile modern
-.Pq Dq extended
-REs,
-rather than the obsolete
-.Pq Dq basic
-REs that are the default.
-.It Dv REG_BASIC
-This is a synonym for 0,
-provided as a counterpart to
-.Dv REG_EXTENDED
-to improve readability.
-.It Dv REG_NOSPEC
-Compile with recognition of all special characters turned off.
-All characters are thus considered ordinary,
-so the RE is a literal string.
-This is an extension,
-compatible with but not specified by
-.St -p1003.2 ,
-and should be used with
-caution in software intended to be portable to other systems.
-.Dv REG_EXTENDED
-and
-.Dv REG_NOSPEC
-may not be used in the same call to
-.Fn regcomp .
-.It Dv REG_ICASE
-Compile for matching that ignores upper/lower case distinctions.
-See
-.Xr re_format 7 .
-.It Dv REG_NOSUB
-Compile for matching that need only report success or failure,
-not what was matched.
-.It Dv REG_NEWLINE
-Compile for newline-sensitive matching.
-By default, newline is a completely ordinary character with no special
-meaning in either REs or strings.
-With this flag,
-.Ql \&[^
-bracket expressions and
-.Ql \&.
-never match newline,
-a
-.Ql ^
-anchor matches the null string after any newline in the string
-in addition to its normal function,
-and the
-.Ql $
-anchor matches the null string before any newline in the
-string in addition to its normal function.
-.It Dv REG_PEND
-The regular expression ends,
-not at the first NUL,
-but just before the character pointed to by the
-.Fa re_endp
-member of the structure pointed to by
-.Fa preg .
-The
-.Fa re_endp
-member is of type
-.Fa const\ char\ * .
-This flag permits inclusion of NULs in the RE;
-they are considered ordinary characters.
-This is an extension,
-compatible with but not specified by
-.St -p1003.2 ,
-and should be used with
-caution in software intended to be portable to other systems.
-.El
-.Pp
-When successful,
-.Fn regcomp
-returns 0 and fills in the structure pointed to by
-.Fa preg .
-One member of that structure
-(other than
-.Fa re_endp )
-is publicized:
-.Fa re_nsub ,
-of type
-.Fa size_t ,
-contains the number of parenthesized subexpressions within the RE
-(except that the value of this member is undefined if the
-.Dv REG_NOSUB
-flag was used).
-If
-.Fn regcomp
-fails, it returns a non-zero error code;
-see DIAGNOSTICS.
-.Pp
-.Fn regexec
-matches the compiled RE pointed to by
-.Fa preg
-against the
-.Fa string ,
-subject to the flags in
-.Fa eflags ,
-and reports results using
-.Fa nmatch ,
-.Fa pmatch ,
-and the returned value.
-The RE must have been compiled by a previous invocation of
-.Fn regcomp .
-The compiled form is not altered during execution of
-.Fn regexec ,
-so a single compiled RE can be used simultaneously by multiple threads.
-.Pp
-By default,
-the NUL-terminated string pointed to by
-.Fa string
-is considered to be the text of an entire line, minus any terminating
-newline.
-The
-.Fa eflags
-argument is the bitwise
-.Tn OR
-of zero or more of the following flags:
-.Bl -tag -width XREG_STARTENDX
-.It Dv REG_NOTBOL
-The first character of
-the string
-is not the beginning of a line, so the
-.Ql ^
-anchor should not match before it.
-This does not affect the behavior of newlines under
-.Dv REG_NEWLINE .
-.It Dv REG_NOTEOL
-The NUL terminating
-the string
-does not end a line, so the
-.Ql $
-anchor should not match before it.
-This does not affect the behavior of newlines under
-.Dv REG_NEWLINE .
-.It Dv REG_STARTEND
-The string is considered to start at
-\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_so\fR
-and to have a terminating NUL located at
-\fIstring\fR\ + \fIpmatch\fR[0].\fIrm_eo\fR
-(there need not actually be a NUL at that location),
-regardless of the value of
-.Fa nmatch .
-See below for the definition of
-.Fa pmatch
-and
-.Fa nmatch .
-This is an extension,
-compatible with but not specified by
-.St -p1003.2 ,
-and should be used with
-caution in software intended to be portable to other systems.
-Note that a non-zero \fIrm_so\fR does not imply
-.Dv REG_NOTBOL ;
-.Dv REG_STARTEND
-affects only the location of the string,
-not how it is matched.
-.El
-.Pp
-See
-.Xr re_format 7
-for a discussion of what is matched in situations where an RE or a
-portion thereof could match any of several substrings of
-.Fa string .
-.Pp
-Normally,
-.Fn regexec
-returns 0 for success and the non-zero code
-.Dv REG_NOMATCH
-for failure.
-Other non-zero error codes may be returned in exceptional situations;
-see DIAGNOSTICS.
-.Pp
-If
-.Dv REG_NOSUB
-was specified in the compilation of the RE,
-or if
-.Fa nmatch
-is 0,
-.Fn regexec
-ignores the
-.Fa pmatch
-argument (but see below for the case where
-.Dv REG_STARTEND
-is specified).
-Otherwise,
-.Fa pmatch
-points to an array of
-.Fa nmatch
-structures of type
-.Li regmatch_t .
-Such a structure has at least the members
-.Fa rm_so
-and
-.Fa rm_eo ,
-both of type
-.Fa regoff_t
-(a signed arithmetic type at least as large as an
-.Li off_t
-and a
-.Li ssize_t ) ,
-containing respectively the offset of the first character of a substring
-and the offset of the first character after the end of the substring.
-Offsets are measured from the beginning of the
-.Fa string
-argument given to
-.Fn regexec .
-An empty substring is denoted by equal offsets,
-both indicating the character following the empty substring.
-.Pp
-The 0th member of the
-.Fa pmatch
-array is filled in to indicate what substring of
-.Fa string
-was matched by the entire RE.
-Remaining members report what substring was matched by parenthesized
-subexpressions within the RE;
-member
-.Va i
-reports subexpression
-.Va i ,
-with subexpressions counted (starting at 1) by the order of their opening
-parentheses in the RE, left to right.
-Unused entries in the array\(emcorresponding either to subexpressions that
-did not participate in the match at all, or to subexpressions that do not
-exist in the RE (that is, \fIi\fR\ > \fIpreg\fR\->\fIre_nsub\fR)\(emhave both
-.Fa rm_so
-and
-.Fa rm_eo
-set to \-1.
-If a subexpression participated in the match several times,
-the reported substring is the last one it matched.
-(Note, as an example in particular, that when the RE
-.Dq (b*)+
-matches
-.Dq bbb ,
-the parenthesized subexpression matches each of the three
-.Sq b Ns s
-and then
-an infinite number of empty strings following the last
-.Sq b ,
-so the reported substring is one of the empties.)
-.Pp
-If
-.Dv REG_STARTEND
-is specified,
-.Fa pmatch
-must point to at least one
-.Li regmatch_t
-(even if
-.Fa nmatch
-is 0 or
-.Dv REG_NOSUB
-was specified),
-to hold the input offsets for
-.Dv REG_STARTEND .
-Use for output is still entirely controlled by
-.Fa nmatch ;
-if
-.Fa nmatch
-is 0 or
-.Dv REG_NOSUB
-was specified,
-the value of
-.Fa pmatch[0]
-will not be changed by a successful
-.Fn regexec .
-.Pp
-.Fn regerror
-maps a non-zero
-.Va errcode
-from either
-.Fn regcomp
-or
-.Fn regexec
-to a human-readable, printable message.
-If
-.Fa preg
-is non-NULL,
-the error code should have arisen from use of
-the
-.Li regex_t
-pointed to by
-.Fa preg ,
-and if the error code came from
-.Fn regcomp ,
-it should have been the result from the most recent
-.Fn regcomp
-using that
-.Li regex_t .
-.Pf ( Fn regerror
-may be able to supply a more detailed message using information
-from the
-.Li regex_t . )
-.Fn regerror
-places the NUL-terminated message into the buffer pointed to by
-.Fa errbuf ,
-limiting the length (including the NUL) to at most
-.Fa errbuf_size
-bytes.
-If the whole message won't fit,
-as much of it as will fit before the terminating NUL is supplied.
-In any case,
-the returned value is the size of buffer needed to hold the whole
-message (including the terminating NUL).
-If
-.Fa errbuf_size
-is 0,
-.Fa errbuf
-is ignored but the return value is still correct.
-.Pp
-If the
-.Fa errcode
-given to
-.Fn regerror
-is first
-.Tn OR Ns 'ed
-with
-.Dv REG_ITOA ,
-the
-.Dq message
-that results is the printable name of the error code,
-e.g.,
-.Dq REG_NOMATCH ,
-rather than an explanation thereof.
-If
-.Fa errcode
-is
-.Dv REG_ATOI ,
-then
-.Fa preg
-shall be non-null and the
-.Fa re_endp
-member of the structure it points to
-must point to the printable name of an error code;
-in this case, the result in
-.Fa errbuf
-is the decimal digits of
-the numeric value of the error code
-(0 if the name is not recognized).
-.Dv REG_ITOA
-and
-.Dv REG_ATOI
-are intended primarily as debugging facilities;
-they are extensions,
-compatible with but not specified by
-.St -p1003.2
-and should be used with
-caution in software intended to be portable to other systems.
-Be warned also that they are considered experimental and changes are possible.
-.Pp
-.Fn regfree
-frees any dynamically allocated storage associated with the compiled RE
-pointed to by
-.Fa preg .
-The remaining
-.Li regex_t
-is no longer a valid compiled RE
-and the effect of supplying it to
-.Fn regexec
-or
-.Fn regerror
-is undefined.
-.Pp
-None of these functions references global variables except for tables
-of constants;
-all are safe for use from multiple threads if the arguments are safe.
-.Sh IMPLEMENTATION CHOICES
-There are a number of decisions that
-.St -p1003.2
-leaves up to the implementor,
-either by explicitly saying
-.Dq undefined
-or by virtue of them being
-forbidden by the RE grammar.
-This implementation treats them as follows.
-.Pp
-See
-.Xr re_format 7
-for a discussion of the definition of case-independent matching.
-.Pp
-There is no particular limit on the length of REs,
-except insofar as memory is limited.
-Memory usage is approximately linear in RE size, and largely insensitive
-to RE complexity, except for bounded repetitions.
-See
-.Sx BUGS
-for one short RE using them
-that will run almost any system out of memory.
-.Pp
-A backslashed character other than one specifically given a magic meaning
-by
-.St -p1003.2
-(such magic meanings occur only in obsolete REs)
-is taken as an ordinary character.
-.Pp
-Any unmatched
-.Ql \&[
-is a
-.Dv REG_EBRACK
-error.
-.Pp
-Equivalence classes cannot begin or end bracket-expression ranges.
-The endpoint of one range cannot begin another.
-.Pp
-RE_DUP_MAX, the limit on repetition counts in bounded repetitions, is 255.
-.Pp
-A repetition operator (?, *, +, or bounds) cannot follow another
-repetition operator.
-A repetition operator cannot begin an expression or subexpression
-or follow
-.Ql ^
-or
-.Ql | .
-.Pp
-A
-.Ql |
-cannot appear first or last in a (sub)expression, or after another
-.Ql | ,
-i.e., an operand of
-.Ql |
-cannot be an empty subexpression.
-An empty parenthesized subexpression,
-.Ql \&(\&) ,
-is legal and matches an
-empty (sub)string.
-An empty string is not a legal RE.
-.Pp
-A
-.Ql {
-followed by a digit is considered the beginning of bounds for a
-bounded repetition, which must then follow the syntax for bounds.
-A
-.Ql {
-.Em not
-followed by a digit is considered an ordinary character.
-.Pp
-.Ql ^
-and
-.Ql $
-beginning and ending subexpressions in obsolete
-.Pq Dq basic
-REs are anchors, not ordinary characters.
-.Sh DIAGNOSTICS
-Non-zero error codes from
-.Fn regcomp
-and
-.Fn regexec
-include the following:
-.Pp
-.Bl -tag -compact -width XREG_ECOLLATEX
-.It Er REG_NOMATCH
-regexec() failed to match
-.It Er REG_BADPAT
-invalid regular expression
-.It Er REG_ECOLLATE
-invalid collating element
-.It Er REG_ECTYPE
-invalid character class
-.It Er REG_EESCAPE
-\e applied to unescapable character
-.It Er REG_ESUBREG
-invalid backreference number
-.It Er REG_EBRACK
-brackets [ ] not balanced
-.It Er REG_EPAREN
-parentheses ( ) not balanced
-.It Er REG_EBRACE
-braces { } not balanced
-.It Er REG_BADBR
-invalid repetition count(s) in { }
-.It Er REG_ERANGE
-invalid character range in [ ]
-.It Er REG_ESPACE
-ran out of memory
-.It Er REG_BADRPT
-?, *, or + operand invalid
-.It Er REG_EMPTY
-empty (sub)expression
-.It Er REG_ASSERT
-.Dq can't happen
-\(emyou found a bug
-.It Er REG_INVARG
-invalid argument, e.g., negative-length string
-.El
-.Sh SEE ALSO
-.Xr grep 1 ,
-.Xr re_format 7
-.Pp
-.St -p1003.2 ,
-sections 2.8 (Regular Expression Notation)
-and
-B.5 (C Binding for Regular Expression Matching).
-.Sh HISTORY
-Originally written by Henry Spencer.
-Altered for inclusion in the
-.Bx 4.4
-distribution.
-.Sh BUGS
-This is an alpha release with known defects.
-Please report problems.
-.Pp
-There is one known functionality bug.
-The implementation of internationalization is incomplete:
-the locale is always assumed to be the default one of
-.St -p1003.2 ,
-and only the collating elements etc. of that locale are available.
-.Pp
-The back-reference code is subtle and doubts linger about its correctness
-in complex cases.
-.Pp
-.Fn regexec
-performance is poor.
-This will improve with later releases.
-.Fa nmatch
-exceeding 0 is expensive;
-.Fa nmatch
-exceeding 1 is worse.
-.Fn regexec
-is largely insensitive to RE complexity
-.Em except
-that back references are massively expensive.
-RE length does matter; in particular, there is a strong speed bonus
-for keeping RE length under about 30 characters,
-with most special characters counting roughly double.
-.Pp
-.Fn regcomp
-implements bounded repetitions by macro expansion,
-which is costly in time and space if counts are large
-or bounded repetitions are nested.
-A RE like, say,
-.Dq ((((a{1,100}){1,100}){1,100}){1,100}){1,100}
-will (eventually) run almost any existing machine out of swap space.
-.Pp
-There are suspected problems with response to obscure error conditions.
-Notably,
-certain kinds of internal overflow,
-produced only by truly enormous REs or by multiply nested bounded repetitions,
-are probably not handled well.
-.Pp
-Due to a mistake in
-.St -p1003.2 ,
-things like
-.Ql a)b
-are legal REs because
-.Ql \&)
-is
-a special character only in the presence of a previous unmatched
-.Ql \&( .
-This can't be fixed until the spec is fixed.
-.Pp
-The standard's definition of back references is vague.
-For example, does
-.Dq a\e(\e(b\e)*\e2\e)*d
-match
-.Dq abbbd ?
-Until the standard is clarified,
-behavior in such cases should not be relied on.
-.Pp
-The implementation of word-boundary matching is a bit of a kludge,
-and bugs may lurk in combinations of word-boundary matching and anchoring.
diff --git a/android/regex/regexec.c b/android/regex/regexec.c
index 7b3bfc7..6feed3b 100644
--- a/android/regex/regexec.c
+++ b/android/regex/regexec.c
@@ -153,7 +153,7 @@ regexec(const regex_t *preg, const char *string, size_t nmatch,
return(REG_BADPAT);
eflags = GOODFLAGS(eflags);
- if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE))
+ if (g->nstates <= (int)(CHAR_BIT*sizeof(states1)) && !(eflags®_LARGE))
return(smatcher(g, (char *)string, nmatch, pmatch, eflags));
else
return(lmatcher(g, (char *)string, nmatch, pmatch, eflags));
diff --git a/android/regex/regfree.c b/android/regex/regfree.c
index 6b67228..a57eba3 100644
--- a/android/regex/regfree.c
+++ b/android/regex/regfree.c
@@ -37,7 +37,6 @@
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
-#include <limits.h>
#include <regex.h>
#include "utils.h"
diff --git a/android/regex/utils.h b/android/regex/utils.h
index 2dea710..3e184fc 100644
--- a/android/regex/utils.h
+++ b/android/regex/utils.h
@@ -36,7 +36,7 @@
*/
/* utility definitions */
-#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */
+#define DUPMAX 255
#define INFINITY (DUPMAX + 1)
#define NC (CHAR_MAX - CHAR_MIN + 1)
typedef unsigned char uch;
--
1.7.4.1
0005-update-make-files-to-build-for-Android-using-the-NDK.patch [^] (6,520 bytes) 2012-05-05 05:22 [Show Content] [Hide Content]From 93aaa3466f2b4fc58d29f02e01f4c3651591cbf4 Mon Sep 17 00:00:00 2001
From: Hans-Christoph Steiner <hans@eds.org>
Date: Wed, 4 Apr 2012 19:07:18 -0400
Subject: [PATCH 05/10] update make files to build for Android using the NDK
---
Makefile | 7 ++++++-
Makefile.inc | 13 +++++++------
android/README | 5 ++++-
android/regex/Makefile.inc | 13 -------------
make/Makefile.android | 43 ++++++++++++++++++++++++++++++++-----------
5 files changed, 49 insertions(+), 32 deletions(-)
delete mode 100644 android/regex/Makefile.inc
diff --git a/Makefile b/Makefile
index e061d21..c48216c 100644
--- a/Makefile
+++ b/Makefile
@@ -183,6 +183,7 @@ libs:
libs_clean clean_libs:
-for dir in $(SUBDIRS);do $(MAKECMD) -C lib/$$dir LIBDIR=$(LIBDIR) clean;rm -f lib/$$dir/*.so lib/$$dir/*.dll;done
+ -rm -f $(REGEX_OBJS)
libs_install install_libs:
@set -e;for dir in $(SUBDIRS);do $(MAKECMD) -C lib/$$dir LIBDIR=$(LIBDIR) install;done
@@ -283,7 +284,11 @@ mdns_uninstall:
# no targets for mini: it's an example plugin
#
-nameservice:
+# nameserver uses regex, which was only recently added to Android. On
+# Android, $(REGEX_OBJS) will have all of the files needed, on all
+# other platforms, it'll be empty and therefore ignored.
+nameservice: $(REGEX_OBJS)
+ @$(MAKECMD) -C lib/nameservice clean
@$(MAKECMD) -C lib/nameservice
nameservice_clean:
diff --git a/Makefile.inc b/Makefile.inc
index 34af527..d70578e 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -230,12 +230,13 @@ help:
@echo ' by setting the OS variable! Valid '
@echo ' target OSes are: '
@echo ' --------------------------------- '
- @echo ' linux - GNU/Linux '
- @echo ' win32 - MS Windows '
- @echo ' fbsd - FreeBSD '
- @echo ' nbsd - NetBSD '
- @echo ' obsd - OpenBSD '
- @echo ' osx - Mac OS X '
+ @echo ' linux - GNU/Linux '
+ @echo ' win32 - MS Windows '
+ @echo ' fbsd - FreeBSD '
+ @echo ' nbsd - NetBSD '
+ @echo ' obsd - OpenBSD '
+ @echo ' osx - Mac OS X '
+ @echo ' android - Android '
@echo ' --------------------------------- '
@echo ' Example - build for windows: '
@echo ' make OS=win32 '
diff --git a/android/README b/android/README
index 8c1da51..a842eba 100644
--- a/android/README
+++ b/android/README
@@ -1 +1,4 @@
-This directory contains some Android specific code. (Mostly dealing with providing missing filesfrom Android NDK.)
+This directory contains some Android specific code. (Mostly dealing
+with providing missing filesfrom Android NDK.)
+
+ * regex support was not added until NDK platform android-8 (v2.2)
diff --git a/android/regex/Makefile.inc b/android/regex/Makefile.inc
deleted file mode 100644
index 9c44858..0000000
--- a/android/regex/Makefile.inc
+++ /dev/null
@@ -1,13 +0,0 @@
-# $OpenBSD: Makefile.inc,v 1.6 2005/04/15 02:07:04 millert Exp $
-# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
-# regex sources
-.PATH: ${LIBCSRCDIR}/regex
-
-CFLAGS+=-DPOSIX_MISTAKE
-
-SRCS+= regcomp.c regerror.c regexec.c regfree.c
-
-MAN+= regex.3 re_format.7
-
-MLINKS+=regex.3 regcomp.3 regex.3 regexec.3 regex.3 regerror.3 regex.3 regfree.3
diff --git a/make/Makefile.android b/make/Makefile.android
index fabef9c..c015ef8 100644
--- a/make/Makefile.android
+++ b/make/Makefile.android
@@ -3,11 +3,10 @@
#
# 1) Download and extract the Android NDK from
# http://developer.android.com/sdk/ndk/index.html
-# (e.g. into to /opt, otherwise call 'make NDK=')
+# (e.g. into to /opt, otherwise call 'make NDK_BASE=')
#
# 2) Compile olsrd with the make command:
-# make OS=android DEBUG=0 build_all
-# (expect lots of warnings which is normal)
+# make OS=android DEBUG=0 NDK_BASE=/opt
#
# 3) Install olsrd on your local PC, e.g.
# sudo make OS=android DEBUG=0 install_all
@@ -34,8 +33,18 @@ LIBDIR = $(PREFIX)/lib
DOCDIR =
MANDIR =
-SRCS += $(wildcard src/linux/*.c src/unix/*.c)
-HDRS += $(wildcard src/linux/*.h src/unix/*.h)
+# there probably should be an Android log.c and misc.c to support
+# Logcat, but this works for now
+SRCS += $(wildcard src/unix/*.c src/linux/*.c)
+HDRS += $(wildcard src/unix/*.h src/linux/*.h)
+
+# Android didn't add regex until android-8 so include this one
+REGEX_SRCS = \
+ android/regex/regcomp.c \
+ android/regex/regerror.c \
+ android/regex/regexec.c \
+ android/regex/regfree.c
+REGEX_OBJS = $(REGEX_SRCS:.c=.o)
CPPFLAGS += -Dlinux -DLINUX_NETLINK_ROUTING
@@ -44,10 +53,11 @@ CPPFLAGS += -DOLSRD_GLOBAL_CONF_FILE=\"$(CFGFILE)\"
CPPFLAGS += -DINET_ADDRSTRLEN=16
CPPFLAGS += -D'IPTOS_PREC(tos)=((tos)&0xe0)'
CPPFLAGS += -D'IPTOS_TOS(tos)=((tos)&0x1e)'
-# Android NDK is missing linux/if_tunnel.h, we have it here:
+# Android NDK is missing some Linux headers and regex, we have them here:
CPPFLAGS += -I$(TOPDIR)/android
# Compilation flags from build/toolchains/arm-eabi-4.2.1/setup.mk
+# * removed -fstrict-aliasing since the code has a lot of type-punning
CPPFLAGS += \
-march=armv5te -mtune=xscale \
-msoft-float -fpic \
@@ -61,13 +71,11 @@ CPPFLAGS += \
ifeq ($(DEBUG),0)
CPPFLAGS += \
-fomit-frame-pointer \
- -fstrict-aliasing \
-funswitch-loops \
-finline-limit=300
else
CPPFLAGS += \
- -fno-omit-frame-pointer \
- -fno-strict-aliasing
+ -fno-omit-frame-pointer
endif
ifdef OLSRD_PLUGIN
@@ -92,8 +100,8 @@ HOST = arm-linux-androideabi
NDK_BASE = /opt/android-ndk
CURRENT_SYSTEM := $(shell uname -s | tr A-Z a-z)
NDK_TOOLCHAIN_BASE = $(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(CURRENT_SYSTEM)-x86
-# we need regex.h, which wasn't added until android-8
-NDK_PLATFORM_VERSION = 8
+
+NDK_PLATFORM_VERSION = 4
NDK_SYSROOT = $(NDK_BASE)/platforms/android-$(NDK_PLATFORM_VERSION)/arch-arm
CROSS_COMPILE = $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-
@@ -104,6 +112,19 @@ ifeq ($(DEBUG),0)
STRIP = $(CROSS_COMPILE)strip
endif
+
+# The Android NDK didn't add proper regex support until android-8
+# (2.2), so we include the Android files here, and build with
+# -DPOSIX_MISTAKE like Android does.
+$(REGEX_OBJS): $(REGEX_SRCS)
+ echo "[CC] $<"
+ $(CC) $(CFLAGS) $(CPPFLAGS) -DPOSIX_MISTAKE -c -o $@ $<
+
+regex: $(REGEX_OBJS)
+
+regex_clean:
+ rm -f $(REGEX_OBJS)
+
# Local Variables:
# mode: makefile
# End:
--
1.7.4.1
|