移動指令moveは文書行の並べ替えを行う。
/format/m/end/-1pとすると、最初に見つけた"format"を含む行を "end"を含む行の1行前に移動し、印刷する。
先に示したdocmdの該当部分は、つぎのようになる。
else if (lin(i) == MOVECOM) {
i = i + 1
if (getone(lin,i,line3,status) == EOF)
status = ERR
if (status == OK)
if (ckp(lin,i,pflag,status) == OK)
if (defalt(curlin,curln,status) == OK)
status = move(line3)
}
RATFOR版move()はは、以下の通り。
# move.r4 -- move line1 through line2 after line3
integer function move(line3)
integer line3
integer getind,nextln,prevln
integer k0,k1,k2,k3,k4,k5
include clines.ri
if (line1 <= 0 | (line1 <= line3 & line3 <= line2)) then
move = ERR
else
k0 = getind(prevln(line1))
k3 = getind(nextln(line2))
k1 = getind(line1)
k2 = getind(line2)
call relink(k0,k3,k0,k3)
if (line3 < line1) {
curln = line3
line3 = line3 - (line2 - line1 + 1)
}
else
curln = line3 + (line2 - line1 + 1)
k4 = getind(line3)
k5 = getind(nextln(line3))
call relink(k4,k1,k2,k5)
call relink(k2,k5,k4,k1)
move = OK
end if
return
end
WATCOM fortran 77版move()は、以下の通り。
c move.f -- move line1 through line2 after line3
integer function move(line3)
integer line3
integer getind,nextln,prevln
integer k0,k1,k2,k3,k4,k5
include clines.fi
if ((line1 .le. 0)
1 .or. (line1 .le. line3 .and. line3 .le. line2)) then
move = -3 ! ERR(-3)
else
k0 = getind(prevln(line1))
k3 = getind(nextln(line2))
k1 = getind(line1)
k2 = getind(line2)
call relink(k0,k3,k0,k3)
if (line3 .gt. line1) then
curln = line3
line3 = line3 - (line2 - line1 + 1)
else
curln = line3 + (line2 - line1 + 1)
end if
k4 = getind(line3)
k5 = getind(nextln(line3))
call relink(k4,k1,k2,k5)
call relink(k2,k5,k4,k1)
move = -2 ! OK(-2)
end if
return
end
※コメントの受付件数を超えているため、この記事にコメントすることができません。