Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Aug 2014 21:38:42 +0000 (UTC)
From:      Jeremie Le Hen <jlh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r269841 - stable/9/usr.bin/sed
Message-ID:  <53e937e2.2395.50059fa2@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jlh
Date: Mon Aug 11 21:38:41 2014
New Revision: 269841
URL: http://svnweb.freebsd.org/changeset/base/269841

Log:
  MFC r269302:
  
    Fix relative numerical addressing (addr,+N).
  
    As a bonus the patch untangles a bit the logic and makes the code
    easier to grasp.
  
    PR:           192108

Modified:
  stable/9/usr.bin/sed/process.c
Directory Properties:
  stable/9/usr.bin/sed/   (props changed)

Modified: stable/9/usr.bin/sed/process.c
==============================================================================
--- stable/9/usr.bin/sed/process.c	Mon Aug 11 21:14:08 2014	(r269840)
+++ stable/9/usr.bin/sed/process.c	Mon Aug 11 21:38:41 2014	(r269841)
@@ -288,24 +288,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 (MATCH(cp->a1)) {
 			/*
 			 * If the second address is a number less than or



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53e937e2.2395.50059fa2>