      SUBROUTINE MAIN
      LOGICAL*1 GETCH
      LOGICAL*1 C, BUF(400)
      INTEGER INT, WC, I
      INTEGER OPEN, GETARG, WCOUNT
      WC = 0
      I=1
23000 IF(.NOT.(GETARG(I,BUF,400).NE.-1))GOTO 23002
      IF(.NOT.(BUF(1) .EQ. 63 .AND. BUF(2) .EQ. 0))GOTO 23003
      CALL ERROR(24Husage:  wcnt [file ...].)
23003 CONTINUE
      IF(.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 0))GOTO 23005
      INT = 1
      GOTO 23006
23005 CONTINUE
      INT = OPEN(BUF,1)
      IF(.NOT.(INT .EQ. -3))GOTO 23007
      CALL CANT(BUF)
23007 CONTINUE
23006 CONTINUE
      WC = WC + WCOUNT(INT)
      IF(.NOT.(INT .NE. 1))GOTO 23009
      CALL CLOSE(INT)
23009 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF(.NOT.(I.EQ.1))GOTO 23011
      WC = WCOUNT(1)
23011 CONTINUE
      CALL PUTDEC(WC, 1)
      CALL PUTC(10)
      RETURN
      END
      INTEGER FUNCTION WCOUNT(INT)
      LOGICAL*1 GETCH
      LOGICAL*1 C
      INTEGER INWORD
      WCOUNT = 0
      INWORD = 0
23013 IF(.NOT.(GETCH(C,INT) .NE. -1))GOTO 23014
      IF(.NOT.(C .EQ. 32 .OR. C .EQ. 10 .OR. C .EQ. 9))GOTO 23015
      INWORD = 0
      GOTO 23016
23015 CONTINUE
      IF(.NOT.(INWORD .EQ. 0))GOTO 23017
      INWORD = 1
      WCOUNT = WCOUNT + 1
23017 CONTINUE
23016 CONTINUE
      GOTO 23013
23014 CONTINUE
      RETURN
      END
