aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorGravatar Eric Andersen <andersen@codepoet.org>2004-02-04 10:57:46 +0000
committerGravatar Eric Andersen <andersen@codepoet.org>2004-02-04 10:57:46 +0000
commitc06f568ddaaa65a05080234ec205593e2424dc45 (patch)
tree8193ad31bf33f4f0dbb8505c4d4fd0e1d806c5c3 /editors
parent4575bbf7b846d9dfd6ff50bb4bc1f6f4ac31f3c0 (diff)
downloadbusybox-c06f568ddaaa65a05080234ec205593e2424dc45.tar.gz
busybox-c06f568ddaaa65a05080234ec205593e2424dc45.tar.bz2
Rob Landley writes:
While building glibc with busybox as part of the development environment, I found a bug in glibc's regexec can throw sed into an endless loop. This fixes it. Should I put an #ifdef around it or something? (Note, this patch also contains the "this is not gnu sed 4.0" hack I posted earlier, which is also needed to build glibc...)
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/editors/sed.c b/editors/sed.c
index a0d0cf74b..5832e99a9 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -618,6 +618,15 @@ static int do_subst_command(sed_cmd_t * sed_cmd, char **line)
do {
int i;
+ /* Work around bug in glibc regexec, demonstrated by:
+ echo " a.b" | busybox sed 's [^ .]* x g'
+ The match_count check is so not to break
+ echo "hi" | busybox sed 's/^/!/g' */
+ if(!regmatch[0].rm_so && !regmatch[0].rm_eo && match_count) {
+ pipe_putc(*(oldline++));
+ continue;
+ }
+
match_count++;
/* If we aren't interested in this match, output old line to
@@ -1073,6 +1082,14 @@ extern int sed_main(int argc, char **argv)
bb_perror_msg_and_die("atexit");
#endif
+#define LIE_TO_AUTOCONF
+#ifdef LIE_TO_AUTOCONF
+ if(argc==2 && !strcmp(argv[1],"--version")) {
+ printf("This is not GNU sed version 4.0\n");
+ exit(0);
+ }
+#endif
+
/* do normal option parsing */
while ((opt = getopt(argc, argv, "ne:f:")) > 0) {
switch (opt) {