aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-02-21 01:52:32 +0000
committerUlrich Drepper <drepper@redhat.com>2003-02-21 01:52:32 +0000
commit54e1cabce616d89ad657731531620b7cd88fb8e2 (patch)
treef4b2384540f7f7d7314d76b6ff08a98a76205117
parent6eb74f33650b4b55e8bc7679145e9293c4b43f2f (diff)
downloadglibc-54e1cabce616d89ad657731531620b7cd88fb8e2.zip
glibc-54e1cabce616d89ad657731531620b7cd88fb8e2.tar.gz
glibc-54e1cabce616d89ad657731531620b7cd88fb8e2.tar.bz2
Update.
* inet/rcmd.c (rresvport_af): Avoid using invliad values. Wrap around in search if port IPPORT_RESERVED/2 has been test. 2002-02-20 Paolo Bonzini <bonzini@gnu.org> * posix/regcomp.c: Remove inclusions. * posix/regexec.c: Likewise. * posix/regex_internal.c: Likewise. * posix/regex_internal.h: Add inclusions here. * posix/regex.c: Only include sys/types.h before regex.h. Include regex_internal.h here. Include regex_internal.c before regcomp.c and regexec.c (might expose more opportunities to the C compiler). * posix/regcomp.c (parse_expression): Fix construct rejected by SGI CC. * posix/regex_internal.h [!_LIBC] (__mempcpy): Fix typo. [!_LIBC] (__wcrtomb): New definition. [!_LIBC]: Conditionalize enabling of I18N on HAVE_WCSCOLL and HAVE_LOCALE_H as well. 2003-02-20 Ulrich Drepper <drepper@redhat.com>
-rw-r--r--ChangeLog22
-rw-r--r--inet/rcmd.c16
-rw-r--r--posix/regcomp.c60
-rw-r--r--posix/regex.c15
-rw-r--r--posix/regex_internal.c46
-rw-r--r--posix/regex_internal.h69
-rw-r--r--posix/regexec.c29
7 files changed, 118 insertions, 139 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ae0129..6fe7daf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
2003-02-20 Ulrich Drepper <drepper@redhat.com>
+ * inet/rcmd.c (rresvport_af): Avoid using invliad values. Wrap
+ around in search if port IPPORT_RESERVED/2 has been test.
+
+2002-02-20 Paolo Bonzini <bonzini@gnu.org>
+
+ * posix/regcomp.c: Remove inclusions.
+ * posix/regexec.c: Likewise.
+ * posix/regex_internal.c: Likewise.
+ * posix/regex_internal.h: Add inclusions here.
+ * posix/regex.c: Only include sys/types.h before regex.h. Include
+ regex_internal.h here. Include regex_internal.c before regcomp.c
+ and regexec.c (might expose more opportunities to the C compiler).
+
+ * posix/regcomp.c (parse_expression): Fix construct rejected by SGI CC.
+
+ * posix/regex_internal.h [!_LIBC] (__mempcpy): Fix typo.
+ [!_LIBC] (__wcrtomb): New definition.
+ [!_LIBC]: Conditionalize enabling of I18N on HAVE_WCSCOLL and
+ HAVE_LOCALE_H as well.
+
+2003-02-20 Ulrich Drepper <drepper@redhat.com>
+
* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Remove obsolete
patch to check for system call errors.
diff --git a/inet/rcmd.c b/inet/rcmd.c
index 4737e6e..42871f7 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -464,7 +464,14 @@ rresvport_af(alport, family)
#endif
ss.ss_family = family;
- for (;;) {
+ /* Ignore invalid values. */
+ if (*alport < IPPORT_RESERVED / 2)
+ *alport = IPPORT_RESERVED / 2;
+ else if (*alport >= IPPORT_RESERVED)
+ *alport = IPPORT_RESERVED - 1;
+
+ int start = *alport;
+ do {
*sport = htons((uint16_t) *alport);
if (__bind(s, (struct sockaddr *)&ss, len) >= 0)
return s;
@@ -472,10 +479,9 @@ rresvport_af(alport, family)
(void)__close(s);
return -1;
}
- (*alport)--;
- if (*alport == IPPORT_RESERVED/2)
- break;
- }
+ if ((*alport)-- == IPPORT_RESERVED/2)
+ *alport = IPPORT_RESERVED - 1;
+ } while (*alport != start);
(void)__close(s);
__set_errno (EAGAIN);
return -1;
diff --git a/posix/regcomp.c b/posix/regcomp.c
index e36383b..f25ecae 100644
--- a/posix/regcomp.c
+++ b/posix/regcomp.c
@@ -18,56 +18,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <assert.h>
-#include <ctype.h>
-#include <limits.h>
-#include <locale.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined HAVE_WCHAR_H || defined _LIBC
-# include <wchar.h>
-#endif /* HAVE_WCHAR_H || _LIBC */
-#if defined HAVE_WCTYPE_H || defined _LIBC
-# include <wctype.h>
-#endif /* HAVE_WCTYPE_H || _LIBC */
-
-/* In case that the system doesn't have isblank(). */
-#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank
-# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
-#endif
-
-#ifdef _LIBC
-# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
-# define _RE_DEFINE_LOCALE_FUNCTIONS 1
-# include <locale/localeinfo.h>
-# include <locale/elem-hash.h>
-# include <locale/coll-lookup.h>
-# endif
-#endif
-
-/* This is for other GNU distributions with internationalized messages. */
-#if HAVE_LIBINTL_H || defined _LIBC
-# include <libintl.h>
-# ifdef _LIBC
-# undef gettext
-# define gettext(msgid) \
- INTUSE(__dcgettext) (INTUSE(_libc_intl_domainname), msgid, LC_MESSAGES)
-# endif
-#else
-# define gettext(msgid) (msgid)
-#endif
-
-#ifndef gettext_noop
-/* This define is so xgettext can find the internationalizable
- strings. */
-# define gettext_noop(String) String
-#endif
-
-#include <regex.h>
-#include "regex_internal.h"
-
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
int length, reg_syntax_t syntax);
static void re_compile_fastmap_iter (regex_t *bufp,
@@ -1995,7 +1945,10 @@ parse_expression (regexp, preg, token, syntax, nest, err)
mbc_remain = create_tree (NULL, NULL, 0, new_idx);
tree = create_tree (tree, mbc_remain, CONCAT, 0);
if (BE (new_idx == -1 || mbc_remain == NULL || tree == NULL, 0))
- return *err = REG_ESPACE, NULL;
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
}
}
#endif
@@ -2097,7 +2050,10 @@ parse_expression (regexp, preg, token, syntax, nest, err)
new_idx = re_dfa_add_node (dfa, *token, 0);
tree = create_tree (NULL, NULL, 0, new_idx);
if (BE (new_idx == -1 || tree == NULL, 0))
- return *err = REG_ESPACE, NULL;
+ {
+ *err = REG_ESPACE;
+ return NULL;
+ }
}
/* We must return here, since ANCHORs can't be followed
by repetition operators.
diff --git a/posix/regex.c b/posix/regex.c
index 8557094..98d86e1 100644
--- a/posix/regex.c
+++ b/posix/regex.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -41,16 +41,15 @@
# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
#endif
-#if __GNUC__ >= 3
-# define BE(expr, val) __builtin_expect (expr, val)
-#else
-# define BE(expr, val) (expr)
-# define inline
-#endif
+/* POSIX says that <sys/types.h> must be included (by the caller) before
+ <regex.h>. */
+#include <sys/types.h>
+#include <regex.h>
+#include "regex_internal.h"
+#include "regex_internal.c"
#include "regcomp.c"
#include "regexec.c"
-#include "regex_internal.c"
/* Binary backward compatibility. */
#if _LIBC
diff --git a/posix/regex_internal.c b/posix/regex_internal.c
index a3ce236..f969c7c 100644
--- a/posix/regex_internal.c
+++ b/posix/regex_internal.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -18,50 +18,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <assert.h>
-#include <ctype.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined HAVE_WCHAR_H || defined _LIBC
-# include <wchar.h>
-#endif /* HAVE_WCHAR_H || _LIBC */
-#if defined HAVE_WCTYPE_H || defined _LIBC
-# include <wctype.h>
-#endif /* HAVE_WCTYPE_H || _LIBC */
-
-#ifdef _LIBC
-# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
-# define _RE_DEFINE_LOCALE_FUNCTIONS 1
-# include <locale/localeinfo.h>
-# include <locale/elem-hash.h>
-# include <locale/coll-lookup.h>
-# endif
-#endif
-
-/* This is for other GNU distributions with internationalized messages. */
-#if HAVE_LIBINTL_H || defined _LIBC
-# include <libintl.h>
-# ifdef _LIBC
-# undef gettext
-# define gettext(msgid) \
- INTUSE(__dcgettext) (_libc_intl_domainname_internal, msgid, LC_MESSAGES)
-# endif
-#else
-# define gettext(msgid) (msgid)
-#endif
-
-#ifndef gettext_noop
-/* This define is so xgettext can find the internationalizable
- strings. */
-# define gettext_noop(String) String
-#endif
-
-#include "regex.h"
-#include "regex_internal.h"
-
static void re_string_construct_common (const char *str, int len,
re_string_t *pstr,
RE_TRANSLATE_TYPE trans, int icase);
diff --git a/posix/regex_internal.h b/posix/regex_internal.h
index ea04a6f..9487256 100644
--- a/posix/regex_internal.h
+++ b/posix/regex_internal.h
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -21,6 +21,70 @@
#ifndef _REGEX_INTERNAL_H
#define _REGEX_INTERNAL_H 1
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <assert.h>
+#include <ctype.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if defined HAVE_LOCALE_H || defined _LIBC
+# include <locale.h>
+#endif
+#if defined HAVE_WCHAR_H || defined _LIBC
+# include <wchar.h>
+#endif /* HAVE_WCHAR_H || _LIBC */
+#if defined HAVE_WCTYPE_H || defined _LIBC
+# include <wctype.h>
+#endif /* HAVE_WCTYPE_H || _LIBC */
+
+/* In case that the system doesn't have isblank(). */
+#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank
+# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
+#endif
+
+#ifdef _LIBC
+# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
+# define _RE_DEFINE_LOCALE_FUNCTIONS 1
+# include <locale/localeinfo.h>
+# include <locale/elem-hash.h>
+# include <locale/coll-lookup.h>
+# endif
+#endif
+
+/* This is for other GNU distributions with internationalized messages. */
+#if HAVE_LIBINTL_H || defined _LIBC
+# include <libintl.h>
+# ifdef _LIBC
+# undef gettext
+# define gettext(msgid) \
+ INTUSE(__dcgettext) (INTUSE(_libc_intl_domainname), msgid, LC_MESSAGES)
+# endif
+#else
+# define gettext(msgid) (msgid)
+#endif
+
+#ifndef gettext_noop
+/* This define is so xgettext can find the internationalizable
+ strings. */
+# define gettext_noop(String) String
+#endif
+
+#if (defined (MB_CUR_MAX) && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC
+#define RE_ENABLE_I18N
+#endif
+
+#if __GNUC__ >= 3
+# define BE(expr, val) __builtin_expect (expr, val)
+#else
+# define BE(expr, val) (expr)
+# define inline
+#endif
+
/* Number of bits in a byte. */
#define BYTE_BITS 8
/* Number of single byte character. */
@@ -37,7 +101,8 @@
# define __wctype wctype
# define __iswctype iswctype
# define __btowc btowc
-# define __mempcpy memcpy
+# define __mempcpy mempcpy
+# define __wcrtomb wcrtomb
# define attribute_hidden
#endif /* not _LIBC */
diff --git a/posix/regexec.c b/posix/regexec.c
index de88859..eb16baa 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -18,31 +18,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <assert.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined HAVE_WCHAR_H || defined _LIBC
-# include <wchar.h>
-#endif /* HAVE_WCHAR_H || _LIBC */
-#if defined HAVE_WCTYPE_H || defined _LIBC
-# include <wctype.h>
-#endif /* HAVE_WCTYPE_H || _LIBC */
-
-#ifdef _LIBC
-# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
-# define _RE_DEFINE_LOCALE_FUNCTIONS 1
-# include <locale/localeinfo.h>
-# include <locale/elem-hash.h>
-# include <locale/coll-lookup.h>
-# endif
-#endif
-
-#include "regex.h"
-#include "regex_internal.h"
-
static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
re_string_t *input, int n);
static void match_ctx_clean (re_match_context_t *mctx);
@@ -174,7 +149,7 @@ static reg_errcode_t get_subexp_sub (const regex_t *preg,
int bkref_node, int bkref_str);
static int find_subexp_node (re_dfa_t *dfa, re_node_set *nodes,
int subexp_idx, int fl_open);
-static reg_errcode_t check_arrival (const regex_t *preg,
+static reg_errcode_t check_arrival (const regex_t *preg,
re_match_context_t *mctx,
state_array_t *path, int top_node,
int top_str, int last_node, int last_str,