From a6feaecef45645b1112c7ce911090d48aceb8848 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 6 Nov 2010 12:57:40 +0000 Subject: [PATCH] slopecalc handles non-initial @ correctly --- layout/slopecalc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/layout/slopecalc b/layout/slopecalc index a89dd5e..fd42c16 100755 --- a/layout/slopecalc +++ b/layout/slopecalc @@ -17,8 +17,8 @@ # the slope _has_ changed a default distance is supplied # # the first use of @... to specify an absolute location -# acts only to fix the zero point of the absolute position scale -# and does not actually specify the location of the current point +# acts only to fix the zero point of the absolute position scale; +# the (relative to start) location of the current point must already be known use strict qw(vars refs); @@ -30,8 +30,8 @@ our @cp= ({ L => 0 }); # $cp[]{H} height # $cp[]{L} absolute dist # $cp[]{S} slope - our $absoffset; + our $numre= '(?:\\d{1,6}(?:\\.\\d*)?|\\.\\d+)'; our $progname= $0; @@ -147,10 +147,16 @@ sub parse_args () { arg_item(S, $1 * 0.01); } elsif (m/^\@([-+]?$numre)$/o) { if (defined $absoffset) { - arg_item(L, $1 + $absoffset); - } else { - $absoffset= -$1; - } + arg_item(L, $1 + $absoffset); + } else { + if (!@cp) { + $absoffset= -$1; + } elsif (defined $cp[$#cp]{L}) { + $absoffset= $cp[$#cp]{L} - $1; + } else { + arg_error("point \#$#cp location still unknown at \`$_'"); + } + } } elsif (m/^\+($numre)$/o) { complete_current_point("new point started because of +..."); arg_item(L, $cp[$#cp]{L} + $1); -- 2.30.2