View | Details | Raw Unified | Return to bug 18681 | Differences between
and this patch

Collapse All | Expand All

(-)a/NEWS (+9 lines)
Lines 5-10 See the end for copying conditions. Link Here
5
Please send GNU C library bug reports via <http://sourceware.org/bugzilla/>
5
Please send GNU C library bug reports via <http://sourceware.org/bugzilla/>
6
using `glibc' in the "product" field.
6
using `glibc' in the "product" field.
7
7
8
Version 2.23
9
10
* The following bugs are resolved with this release:
11
12
  18681.
13
14
* The obsolete header <regexp.h> has been removed.  Programs that require
15
  this header must be updated to use <regex.h> instead.
16
8
Version 2.22
17
Version 2.22
9
18
10
* The following bugs are resolved with this release:
19
* The following bugs are resolved with this release:
(-)a/misc/regexp.c (-7 / +22 lines)
Lines 1-4 Link Here
1
/* Define function and variables for the obsolete <regexp.h> interface.
1
/* Compatibility symbols for the obsolete <regexp.h> interface.
2
   Copyright (C) 1996-2015 Free Software Foundation, Inc.
2
   Copyright (C) 1996-2015 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
3
   This file is part of the GNU C Library.
4
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
4
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
Lines 17-33 Link Here
17
   License along with the GNU C Library; if not, see
17
   License along with the GNU C Library; if not, see
18
   <http://www.gnu.org/licenses/>.  */
18
   <http://www.gnu.org/licenses/>.  */
19
19
20
/* We don't include regexp.h here because of the macros it requires, and
20
/* regexp.h now contains only an #error directive, so it cannot be
21
   because it now contains an unconditional #warning. */
21
   used in this file.
22
23
   The function that would produce an 'expbuf' to use as the second
24
   argument to 'step' and 'advance' was defined only in regexp.h,
25
   as its definition depended on macros defined by the user.  */
22
26
23
#include <regex.h>
27
#include <regex.h>
28
#include <shlib-compat.h>
29
30
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
24
31
25
/* Define the variables used for the interface.  */
32
/* Define the variables used for the interface.  */
26
char *loc1;
33
char *loc1;
27
char *loc2;
34
char *loc2;
35
compat_symbol (libc, loc1, loc1, GLIBC_2_0);
36
compat_symbol (libc, loc2, loc2, GLIBC_2_0);
28
37
29
/* Although we do not support the use we define this variable as well.  */
38
/* Although we do not support the use we define this variable as well.  */
30
char *locs;
39
char *locs;
40
compat_symbol (libc, locs, locs, GLIBC_2_0);
31
41
32
42
33
/* Find the next match in STRING.  The compiled regular expression is
43
/* Find the next match in STRING.  The compiled regular expression is
Lines 35-41 char *locs; Link Here
35
   first character matched and `loc2' points to the next unmatched
45
   first character matched and `loc2' points to the next unmatched
36
   character.  */
46
   character.  */
37
int
47
int
38
__step (const char *string, const char *expbuf)
48
weak_function attribute_compat_text_section
49
step (const char *string, const char *expbuf)
39
{
50
{
40
  regmatch_t match;	/* We only need info about the full match.  */
51
  regmatch_t match;	/* We only need info about the full match.  */
41
52
Lines 50-63 __step (const char *string, const char *expbuf) Link Here
50
  loc2 = (char *) string + match.rm_eo;
61
  loc2 = (char *) string + match.rm_eo;
51
  return 1;
62
  return 1;
52
}
63
}
53
weak_alias (__step, step)
64
compat_symbol (libc, step, step, GLIBC_2_0);
54
65
55
66
56
/* Match the beginning of STRING with the compiled regular expression
67
/* Match the beginning of STRING with the compiled regular expression
57
   in EXPBUF.  If the match is successful `loc2' will contain the
68
   in EXPBUF.  If the match is successful `loc2' will contain the
58
   position of the first unmatched character.  */
69
   position of the first unmatched character.  */
59
int
70
int
60
__advance (const char *string, const char *expbuf)
71
weak_function attribute_compat_text_section
72
advance (const char *string, const char *expbuf)
61
{
73
{
62
  regmatch_t match;	/* We only need info about the full match.  */
74
  regmatch_t match;	/* We only need info about the full match.  */
63
75
Lines 74-77 __advance (const char *string, const char *expbuf) Link Here
74
  loc2 = (char *) string + match.rm_eo;
86
  loc2 = (char *) string + match.rm_eo;
75
  return 1;
87
  return 1;
76
}
88
}
77
weak_alias (__advance, advance)
89
compat_symbol (libc, advance, advance, GLIBC_2_0);
90
91
92
#endif /* SHLIB_COMPAT (2.0, 2.23) */
(-)a/misc/regexp.h (-202 / +4 lines)
Lines 24-230 Link Here
24
   In issue 4, version 2, it was marked as TO BE WITHDRAWN, and it was
24
   In issue 4, version 2, it was marked as TO BE WITHDRAWN, and it was
25
   duly withdrawn in issue 6.
25
   duly withdrawn in issue 6.
26
26
27
   This header is provided only for backward compatibility, and it will
27
   As of GNU libc 2.23, the interfaces in this header have been removed.
28
   be removed in the next release of GNU libc.  New code should use
28
   Use the <regex.h> interfaces instead. */
29
   <regex.h> instead.  */
30
29
31
#warning "regexp.h is obsolete and buggy."
30
#error "GNU libc no longer implements <regexp.h>."
32
#warning "It will be removed in the next release of GNU libc."
31
#error "Please update your code to use <regex.h> (no trailing 'p')."
33
#warning "Please update your code to use regex.h instead (no trailing 'p')."
34
35
#include <features.h>
36
#include <alloca.h>
37
#include <regex.h>
38
#include <stdlib.h>
39
#include <string.h>
40
41
/* The implementation provided here emulates the needed functionality
42
   by mapping to the POSIX regular expression matcher.  The interface
43
   for the here included function is weird (this really is a harmless
44
   word).
45
46
   The user has to provide six macros before this header file can be
47
   included:
48
49
   INIT		Declarations vor variables which can be used by the
50
		other macros.
51
52
   GETC()	Return the value of the next character in the regular
53
		expression pattern.  Successive calls should return
54
		successive characters.
55
56
   PEEKC()	Return the value of the next character in the regular
57
		expression pattern.  Immediately successive calls to
58
		PEEKC() should return the same character which should
59
		also be the next character returned by GETC().
60
61
   UNGETC(c)	Cause `c' to be returned by the next call to GETC() and
62
		PEEKC().
63
64
   RETURN(ptr)	Used for normal exit of the `compile' function.  `ptr'
65
		is a pointer to the character after the last character of
66
		the compiled regular expression.
67
68
   ERROR(val)	Used for abnormal return from `compile'.  `val' is the
69
		error number.  The error codes are:
70
		11	Range endpoint too large.
71
		16	Bad number.
72
		25	\digit out of range.
73
		36	Illegal or missing delimiter.
74
		41	No remembered search string.
75
		42	\( \) imbalance.
76
		43	Too many \(.
77
		44	More tan two numbers given in \{ \}.
78
		45	} expected after \.
79
		46	First number exceeds second in \{ \}.
80
		49	[ ] imbalance.
81
		50	Regular expression overflow.
82
83
  */
84
85
__BEGIN_DECLS
86
87
/* Interface variables.  They contain the results of the successful
88
   calls to `setp' and `advance'.  */
89
extern char *loc1;
90
extern char *loc2;
91
92
/* The use of this variable in the `advance' function is not
93
   supported.  */
94
extern char *locs;
95
96
97
#ifndef __DO_NOT_DEFINE_COMPILE
98
/* Get and compile the user supplied pattern up to end of line or
99
   string or until EOF is seen, whatever happens first.  The result is
100
   placed in the buffer starting at EXPBUF and delimited by ENDBUF.
101
102
   This function cannot be defined in the libc itself since it depends
103
   on the macros.  */
104
char *
105
compile (char *__restrict instring, char *__restrict expbuf,
106
	 const char *__restrict endbuf, int eof)
107
{
108
  char *__input_buffer = NULL;
109
  size_t __input_size = 0;
110
  size_t __current_size = 0;
111
  int __ch;
112
  int __error;
113
  INIT
114
115
  /* Align the expression buffer according to the needs for an object
116
     of type `regex_t'.  Then check for minimum size of the buffer for
117
     the compiled regular expression.  */
118
  regex_t *__expr_ptr;
119
# if defined __GNUC__ && __GNUC__ >= 2
120
  const size_t __req = __alignof__ (regex_t *);
121
# else
122
  /* How shall we find out?  We simply guess it and can change it is
123
     this really proofs to be wrong.  */
124
  const size_t __req = 8;
125
# endif
126
  expbuf += __req;
127
  expbuf -= (expbuf - ((char *) 0)) % __req;
128
  if (endbuf < expbuf + sizeof (regex_t))
129
    {
130
      ERROR (50);
131
    }
132
  __expr_ptr = (regex_t *) expbuf;
133
  /* The remaining space in the buffer can be used for the compiled
134
     pattern.  */
135
  __expr_ptr->__REPB_PREFIX (buffer) = expbuf + sizeof (regex_t);
136
  __expr_ptr->__REPB_PREFIX (allocated)
137
    = endbuf - (char *) __expr_ptr->__REPB_PREFIX (buffer);
138
139
  while ((__ch = (GETC ())) != eof)
140
    {
141
      if (__ch == '\0' || __ch == '\n')
142
	{
143
	  UNGETC (__ch);
144
	  break;
145
	}
146
147
      if (__current_size + 1 >= __input_size)
148
	{
149
	  size_t __new_size = __input_size ? 2 * __input_size : 128;
150
	  char *__new_room = (char *) alloca (__new_size);
151
	  /* See whether we can use the old buffer.  */
152
	  if (__new_room + __new_size == __input_buffer)
153
	    {
154
	      __input_size += __new_size;
155
	      __input_buffer = (char *) memcpy (__new_room, __input_buffer,
156
					       __current_size);
157
	    }
158
	  else if (__input_buffer + __input_size == __new_room)
159
	    __input_size += __new_size;
160
	  else
161
	    {
162
	      __input_size = __new_size;
163
	      __input_buffer = (char *) memcpy (__new_room, __input_buffer,
164
						__current_size);
165
	    }
166
	}
167
      __input_buffer[__current_size++] = __ch;
168
    }
169
  if (__current_size)
170
    __input_buffer[__current_size++] = '\0';
171
  else
172
    __input_buffer = "";
173
174
  /* Now compile the pattern.  */
175
  __error = regcomp (__expr_ptr, __input_buffer, REG_NEWLINE);
176
  if (__error != 0)
177
    /* Oh well, we have to translate POSIX error codes.  */
178
    switch (__error)
179
      {
180
      case REG_BADPAT:
181
      case REG_ECOLLATE:
182
      case REG_ECTYPE:
183
      case REG_EESCAPE:
184
      case REG_BADRPT:
185
      case REG_EEND:
186
      case REG_ERPAREN:
187
      default:
188
	/* There is no matching error code.  */
189
	ERROR (36);
190
      case REG_ESUBREG:
191
	ERROR (25);
192
      case REG_EBRACK:
193
	ERROR (49);
194
      case REG_EPAREN:
195
	ERROR (42);
196
      case REG_EBRACE:
197
	ERROR (44);
198
      case REG_BADBR:
199
	ERROR (46);
200
      case REG_ERANGE:
201
	ERROR (11);
202
      case REG_ESPACE:
203
      case REG_ESIZE:
204
	ERROR (50);
205
      }
206
207
  /* Everything is ok.  */
208
  RETURN ((char *) (__expr_ptr->__REPB_PREFIX (buffer)
209
		    + __expr_ptr->__REPB_PREFIX (used)));
210
}
211
#endif
212
213
214
/* Find the next match in STRING.  The compiled regular expression is
215
   found in the buffer starting at EXPBUF.  `loc1' will return the
216
   first character matched and `loc2' points to the next unmatched
217
   character.  */
218
extern int step (const char *__restrict __string,
219
		 const char *__restrict __expbuf) __THROW;
220
221
/* Match the beginning of STRING with the compiled regular expression
222
   in EXPBUF.  If the match is successful `loc2' will contain the
223
   position of the first unmatched character.  */
224
extern int advance (const char *__restrict __string,
225
		    const char *__restrict __expbuf) __THROW;
226
227
228
__END_DECLS
229
32
230
#endif /* regexp.h */
33
#endif /* regexp.h */
231
- 

Return to bug 18681