#! /usr/bin/gawk -f # Last edited on 2025-12-09 22:00:57 by stolfi # Adds specfified increments to the coodinates # of an "annotate.sh" script. # For now adjusts only "+LA", "-LA", "+LC", "-LC" directives. # Passes all other driectives unchanged. BEGIN { if (dx == "") { arg_error("must define {dx}") } if (dy == "") { arg_error("must define {dy}") } } /^ *[-+]L[CA]/ { op=$1; xp=$2; yp=$3; rr=$4; xt=$5; yt = $6; lab=$7; xp=adjust(xp,dx); yp=adjust(yp,dy); if (substr(op,1,1) == "-") { xt=adjust(xt,dx); yt = adjust(yt,dy); } printf " %s %4d %3d %03d %4d %3d %s \\\n", \ op, xp, yp, rr, xt, yt, lab next } //{ print; next; } function adjust(x,d, xc) { if (x >= 0) { xc = x + d; if (xc < 0) { xc = x; } x = xc } return x }