Module Name: src Committed By: martin Date: Mon Aug 18 07:44:03 UTC 2014
Modified Files: src/usr.bin/sed [netbsd-7]: process.c Log Message: Pull up following revision(s) (requested by christos in ticket #34): usr.bin/sed/process.c: revision 1.46 PR/49109: Jeremie Le Hen: fix sed relative addressin (1,+N) https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192108 http://svnweb.freebsd.org/base?view=revision&revision=269302 XXX: pullup 7. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.45.2.1 src/usr.bin/sed/process.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/sed/process.c diff -u src/usr.bin/sed/process.c:1.45 src/usr.bin/sed/process.c:1.45.2.1 --- src/usr.bin/sed/process.c:1.45 Thu Jun 26 02:14:32 2014 +++ src/usr.bin/sed/process.c Mon Aug 18 07:44:03 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: process.c,v 1.45 2014/06/26 02:14:32 christos Exp $ */ +/* $NetBSD: process.c,v 1.45.2.1 2014/08/18 07:44:03 martin Exp $ */ /*- * Copyright (c) 1992 Diomidis Spinellis. @@ -38,7 +38,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: process.c,v 1.45 2014/06/26 02:14:32 christos Exp $"); +__RCSID("$NetBSD: process.c,v 1.45.2.1 2014/08/18 07:44:03 martin Exp $"); #ifdef __FBSDID __FBSDID("$FreeBSD: head/usr.bin/sed/process.c 192732 2009-05-25 06:45:33Z brian $"); #endif @@ -295,24 +295,32 @@ applies(struct s_command *cp) r = 1; else if (cp->a2) if (cp->startline > 0) { - if (MATCH(cp->a2)) { - cp->startline = 0; - lastaddr = 1; - r = 1; - } else if (linenum - cp->startline <= cp->a2->u.l) - r = 1; - else if ((cp->a2->type == AT_LINE && - linenum > cp->a2->u.l) || - (cp->a2->type == AT_RELLINE && - linenum - cp->startline > cp->a2->u.l)) { - /* - * We missed the 2nd address due to a branch, - * so just close the range and return false. - */ - cp->startline = 0; - r = 0; - } else - r = 1; + switch (cp->a2->type) { + case AT_RELLINE: + if (linenum - cp->startline <= cp->a2->u.l) + r = 1; + else { + cp->startline = 0; + r = 0; + } + break; + default: + if (MATCH(cp->a2)) { + cp->startline = 0; + lastaddr = 1; + r = 1; + } else if (cp->a2->type == AT_LINE && + linenum > cp->a2->u.l) { + /* + * We missed the 2nd address due to a + * branch, so just close the range and + * return false. + */ + cp->startline = 0; + r = 0; + } else + r = 1; + } } else if (cp->a1 && MATCH(cp->a1)) { /* * If the second address is a number less than or