home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume7 / rvi / part2 / rv_input.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  995 b   |  50 lines

  1. #include "rv.h"
  2.  
  3. #ifdef CRAY
  4. #define cmd_countptr   c_countptr
  5. #endif
  6.  
  7. /*
  8.  * Read a command character, possibly prefixed with a count.
  9.  *    c               - Command character
  10.  *    cmd_count       - Command count, default 1.
  11.  *
  12.  *    Returns TRUE if an explicit count was specified
  13.  */
  14. boolean read_cmd(cptr, cmd_countptr)
  15. INT  *cptr;
  16. INT  *cmd_countptr;
  17. {
  18.     register    INT    c;
  19.     register    INT    cmd_count;
  20.     boolean        specified_count;
  21.  
  22.     cmd_count = 0;
  23.     specified_count = FALSE;
  24.     do { 
  25.         c = getch();
  26.         if (c == ERR || c == EOF)
  27.             quit();
  28.                 
  29.         if (c != '0') /* '0' is a command! */
  30.             while (c >= '0' && c <= '9') {
  31.                 specified_count = TRUE;
  32.                 cmd_count = cmd_count * 10 + c - '0';
  33.                 c = getch();
  34.             }
  35.         if (c == '\"') {
  36.             yank_cmd = getch();
  37.             (void) char_to_yank(yank_cmd);
  38.             if (errflag) /* If bad "x yank letter */
  39.                 break;
  40.         }
  41.     } while (c == '\"');
  42.  
  43.     if (!specified_count)
  44.         *cmd_countptr = 1;  /* default */
  45.     else
  46.         *cmd_countptr = cmd_count;
  47.     *cptr = c;
  48.     return(specified_count);
  49. }
  50.