      SUBROUTINE MAIN
      LOGICAL*1 BUF(512)
      INTEGER GETARG, OPEN, CTOI
      INTEGER I, INT, WIDTH, J, N
      DATA WIDTH /80/
      CALL QUERY(29Husage:  unrot [-n] [file] ...)
      I=1
23000 IF (.NOT.(GETARG(I,BUF,512).NE.-1))GOTO 23002
      IF (.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .NE. 0))GOTO 23003
      J = 2
      N = CTOI(BUF,J)
      IF (.NOT.(N .GT. 0))GOTO 23005
      WIDTH = N
23005 CONTINUE
      GOTO 23001
23003 CONTINUE
      IF (.NOT.(BUF(1) .EQ. 45))GOTO 23007
      INT = 1
      GOTO 23008
23007 CONTINUE
      INT = OPEN(BUF, 1)
      IF (.NOT.(INT .EQ. -3))GOTO 23009
      CALL CANT(BUF)
23009 CONTINUE
23008 CONTINUE
23004 CONTINUE
      CALL NROT (INT, WIDTH)
      IF (.NOT.(INT .NE. 1))GOTO 23011
      CALL CLOSE(INT)
23011 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF (.NOT.(I.EQ.1))GOTO 23013
      CALL NROT (1, WIDTH)
23013 CONTINUE
      RETURN
      END
      SUBROUTINE NROT(INT, WIDTH)
      LOGICAL*1 INBUF(512), OUTBUF(512)
      INTEGER GETLIN, INDEXC
      INTEGER INT, I, J, WIDTH, MIDDLE
      MIDDLE = MAX0(WIDTH/2, 1)
23015 IF (.NOT.(GETLIN(INBUF, INT) .NE. -1))GOTO 23016
      I=1
23017 IF (.NOT.(I.LT.WIDTH))GOTO 23019
      OUTBUF(I) = 32
23018 I=I+1
      GOTO 23017
23019 CONTINUE
      J = MIDDLE
      I=1
23020 IF (.NOT.(INBUF(I).NE.36 .AND. INBUF(I).NE.10))GOTO 23022
      J = J + 1
      IF (.NOT.(I.GT.1 .AND. INBUF(I-1) .EQ. 32))GOTO 23023
      IF (.NOT.(NEXTJ(+1,INBUF,I,J) .GE. WIDTH - 1))GOTO 23025
      J = 1
23025 CONTINUE
23023 CONTINUE
      IF (.NOT.(J .GE. WIDTH - 1))GOTO 23027
      J = 1
23027 CONTINUE
      OUTBUF(J) = INBUF(I)
23021 I=I+1
      GOTO 23020
23022 CONTINUE
      IF (.NOT.(INBUF(I) .EQ. 36))GOTO 23029
      J = MIDDLE
      I=INDEXC(INBUF,10)-1
23031 IF (.NOT.(I.GT.0))GOTO 23033
      IF (.NOT.(INBUF(I) .EQ. 36))GOTO 23034
      GOTO 23033
23034 CONTINUE
      J = J -1
      IF (.NOT.(INBUF(I+1) .EQ. 32))GOTO 23036
      IF (.NOT.(NEXTJ(-1,INBUF,I,J) .LE. 0))GOTO 23038
      J = WIDTH - 2
23038 CONTINUE
23036 CONTINUE
      IF (.NOT.(J .LE. 0))GOTO 23040
      J = WIDTH - 2
23040 CONTINUE
      OUTBUF(J) = INBUF(I)
23032 I=I-1
      GOTO 23031
23033 CONTINUE
23029 CONTINUE
      I=WIDTH-2
23042 IF (.NOT.(I .GT. 0))GOTO 23044
      IF (.NOT.(OUTBUF(I) .NE. 32))GOTO 23045
      GOTO 23044
23045 CONTINUE
23043 I=I-1
      GOTO 23042
23044 CONTINUE
      OUTBUF(I+1) = 10
      OUTBUF(I+2) = 0
      CALL PUTLIN(OUTBUF, 2)
      GOTO 23015
23016 CONTINUE
      RETURN
      END
      INTEGER FUNCTION NEXTJ(INCMNT,BUF,I,J)
      LOGICAL*1 BUF(100)
      INTEGER INCMNT, I, J, K
      NEXTJ = J
      K=I
23047 IF (.NOT.(K.GT.0))GOTO 23049
      IF (.NOT.(BUF(K) .EQ. 32 .OR. BUF(K) .EQ. 36 .OR. BUF(K) .EQ. 10))
     *GOTO 23050
      GOTO 23049
23050 CONTINUE
      NEXTJ = NEXTJ + INCMNT
23048 K = K + INCMNT
      GOTO 23047
23049 CONTINUE
      RETURN
      END
