WATCOM Fortran77版は下記の通り。
c maksub -- make subtitution string in sub integer function maksub(arg,from,delim,sub) integer*1 arg(81),delim,sub(81) ! MAXARG(81) MAXPAT(81) integer from integer*1 esc integer addset,i,j,junk j = 1 i = from while ((arg(i) .ne. delim) .and. (arg(i) .ne. -2)) do ! EOS(-2) if (arg(i) .eq. 35) then ! SHARP(35 '#') junk = addset(-3,sub,j,81) ! DITTO(-3) MAXPAT(81) else junk = addset(esc(arg,i),sub,j,81) ! MAXPAT(81) end if i = i + 1 end while if (arg(i) .ne. delim) then ! missing delimiter maksub = -1 ! ERR(-1) else if (addset(-2,sub,j,81) .eq. 0) then ! no room ! EOS(-2) MAXPAT81) NO(0) maksub = -1 ! ERR(-1) else maksub = i end if return end
catsub()で、置き換えられた文字列を出力用文字列に追加します。 繰り返し記号が出てきたら、まず原型を追加します。
RATFOR版は下記の通り。
# catsub -- add replacement text to end of new subroutine catsub(lin,from,to,sub,new,k,maxnew) character lin(MAXLINE+1),sub(CMAXPAT),new(maxnew) integer from,to,k,maxnew integer addset,i,j,junk for (i = 1; sub(i) != EOS; i = i + 1) do if (sub(i) == DITTO) for (j = from; j < to; j = j + 1) junk = addset(lin(j),new,k,maxnew) else junk = addset(sub(i),new,k,maxnew) return end
WATCOM Fortran77版は下記の通り。
c catsub -- add replacement text to end of new subroutine catsub(lin,from,to,sub,new,k,maxnew) integer*1 lin(81+1),sub(81),new(maxnew) ! MAXLINE(81) MAXPAT(81) integer from,to,k,maxnew integer addset,i,j,junk i = 1 while (sub(i) .ne. -2) do ! EOS(-2) if (sub(i) .eq. -3) then ! DITTO(-3) j = from while (j .lt. to) do junk = addset(lin(j),new,k,maxnew) j = j + 1 end while else junk = addset(sub(i),new,k,maxnew) end if i = i + 1 end while return end
※コメントの受付件数を超えているため、この記事にコメントすることができません。