# 2.11BSD#431 - /usr/src/new/jove/argcount.c

##### Functions

    Digit             X
    Digit0            X
    Digit1            X
    Digit2            X
    Digit3            X
    Digit4            X
    Digit5            X
    Digit6            X
    Digit7            X
    Digit8            X
    Digit9            X
    TimesFour         X
    arg_type          X
    arg_value         X
    clr_arg_value     X
    gather_numeric_argumentX
    is_an_arg         X
    negate_arg_value  X
    quad_numeric_arg  X
    set_arg_value     X
    set_is_an_arg     X

##### Variables

    arg_count         X
    arg_supplied_p    X
    private           X

##### Macros

    private           X

       1: /***************************************************************************
       2:  * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne.  JOVE *
       3:  * is provided to you without charge, and with no warranty.  You may give  *
       4:  * away copies of JOVE, including sources, provided that this notice is    *
       5:  * included in all the files.                                              *
       6:  ***************************************************************************/
       7:
       8: #include "jove.h"
       9: #include <ctype.h>
      10:
      11: #ifdef MAC
      12: #	undef private
      13: #	define private
      14: #endif
      15:
      16: #ifdef  LINT_ARGS
      17: private void
      18:     gather_numeric_argument(int),
      19:     quad_numeric_arg(void);
      20: #else
      21: private void
      22:     gather_numeric_argument(),
      23:     quad_numeric_arg();
      24: #endif
      25:
      26: #ifdef MAC
      27: #	undef private
      28: #	define private static
      29: #endif
      30:
      31: private int arg_supplied_p,
      32:         arg_count;
      33:
      34: int
      35: arg_type()
      36: {
      37:     return arg_supplied_p;
      38: }
      39:
      40: void
      41: set_is_an_arg(there_is)
      42: {
      43:     arg_supplied_p = there_is;
      44: }
      45:
      46: void
      47: set_arg_value(n)
      48: {
      49:     arg_supplied_p = YES;
      50:     arg_count = n;
      51: }
      52:
      53: void
      54: negate_arg_value()
      55: {
      56:     arg_count = -arg_count;
      57: }
      58:
      59: void
      60: clr_arg_value()
      61: {
      62:     arg_supplied_p = NO;
      63:     arg_count = 1;
      64: }
      65:
      66: /* return whether there is currently a numeric argument */
      67:
      68: int
      69: is_an_arg()
      70: {
      71:     return (arg_supplied_p != NO);
      72: }
      73:
      74: /* return the numeric argument */
      75:
      76: int
      77: arg_value()
      78: {
      79:     return arg_count;
      80: }
      81:
      82: /* called by C-U to gather a numeric argument, either C-U's or digits,
      83:    but not both */
      84:
      85: void
      86: TimesFour()
      87: {
      88:     quad_numeric_arg();
      89: }
      90:
      91: /* This initializes the numeric argument to 1 and starts multiplying
      92:    by 4 (the magic number Stallman came up with).  It is an error to
      93:    invoke quad_numeric_arg() interactively (via TimesFour()), because
      94:    it uses the LastKeyStruck variable to know what character signals
      95:    to multiply again (in the loop). */
      96: private void
      97: quad_numeric_arg()
      98: {
      99:     int oldc = LastKeyStruck,
     100:         newc,
     101:         narg_count,
     102:         slow;
     103:
     104:     slow = 0;
     105:     arg_supplied_p = YES;
     106:     arg_count = 1;
     107:     this_cmd = ARG_CMD;
     108:     do {
     109:         if ((narg_count = arg_count * 4) != 0)
     110:             arg_count = narg_count;
     111:         if (!slow)
     112:             newc = waitchar(&slow);
     113:         else
     114:             newc = getch();
     115:         if (isdigit(newc) || newc == '-') {
     116:              arg_supplied_p = NO;
     117:              gather_numeric_argument(newc);
     118:              return;
     119:         }
     120:         if (slow)
     121:             message(key_strokes);
     122:     } while (newc == oldc);
     123:     Ungetc(newc);
     124: }
     125:
     126: private void
     127: gather_numeric_argument(c)
     128: {
     129:     int sign = 0;
     130:     static int  digited;
     131:     int slow = 0;
     132:
     133:     if (!isdigit(c) && c != '-')
     134:         complain((char *) 0);
     135:     if (arg_supplied_p == NO) { /* if we just got here */
     136:         arg_count = 0;  /* start over */
     137:         digited = NO;
     138:     } else if (arg_supplied_p == YES_NODIGIT) {
     139:         sign = (arg_count < 0) ? -1 : 1;
     140:         arg_count = 0;
     141:     }
     142:
     143:     if (!sign)
     144:         sign = (arg_count < 0) ? -1 : 1;
     145:     if (sign == -1)
     146:         arg_count = -arg_count;
     147:     if (c == '-') {
     148:         sign = -sign;
     149:         goto goread;
     150:     }
     151:     for (;;) {
     152:         if (slow)
     153:             message(key_strokes);
     154:         if (isdigit(c)) {
     155:             arg_count = (arg_count * 10) + (c - '0');
     156:             digited = YES;
     157:         } else {
     158:             if (digited)
     159:                 arg_supplied_p = YES;
     160:             else {
     161:                 arg_count = 1;
     162:                 if (arg_supplied_p == NO)
     163:                     arg_supplied_p = YES_NODIGIT;
     164:             }
     165:             arg_count *= sign;
     166:             this_cmd = ARG_CMD;
     167:             Ungetc(c);
     168:             return;
     169:         }
     170: goread:     if (!slow)
     171:             c = waitchar(&slow);
     172:         else {
     173:             add_mess(NullStr);
     174:             c = getch();
     175:         }
     176:     }
     177: }
     178:
     179: void
     180: Digit()
     181: {
     182:     gather_numeric_argument(LastKeyStruck);
     183: }
     184:
     185: void
     186: Digit0()
     187: {
     188:     gather_numeric_argument('0');
     189: }
     190:
     191: void
     192: Digit1()
     193: {
     194:     gather_numeric_argument('1');
     195: }
     196:
     197: void
     198: Digit2()
     199: {
     200:     gather_numeric_argument('2');
     201: }
     202:
     203: void
     204: Digit3()
     205: {
     206:     gather_numeric_argument('3');
     207: }
     208:
     209: void
     210: Digit4()
     211: {
     212:     gather_numeric_argument('4');
     213: }
     214:
     215: void
     216: Digit5()
     217: {
     218:     gather_numeric_argument('5');
     219: }
     220:
     221: void
     222: Digit6()
     223: {
     224:     gather_numeric_argument('6');
     225: }
     226:
     227: void
     228: Digit7()
     229: {
     230:     gather_numeric_argument('7');
     231: }
     232:
     233: void
     234: Digit8()
     235: {
     236:     gather_numeric_argument('8');
     237: }
     238:
     239: void
     240: Digit9()
     241: {
     242:     gather_numeric_argument('9');
     243: }

#### Defined functions

Digit defined in line 179; used 4 times

- in /usr/src/new/jove/externs.h line 252, 860
- in /usr/src/new/jove/funcdefs.c line 82, 347

Digit0 defined in line 185; used 4 times

- in /usr/src/new/jove/externs.h line 253, 861
- in /usr/src/new/jove/funcdefs.c line 83, 357

Digit1 defined in line 191; used 4 times

- in /usr/src/new/jove/externs.h line 254, 862
- in /usr/src/new/jove/funcdefs.c line 84, 348

Digit2 defined in line 197; used 4 times

- in /usr/src/new/jove/externs.h line 255, 863
- in /usr/src/new/jove/funcdefs.c line 85, 349

Digit3 defined in line 203; used 4 times

- in /usr/src/new/jove/externs.h line 256, 864
- in /usr/src/new/jove/funcdefs.c line 86, 350

Digit4 defined in line 209; used 4 times

- in /usr/src/new/jove/externs.h line 257, 865
- in /usr/src/new/jove/funcdefs.c line 87, 351

Digit5 defined in line 215; used 4 times

- in /usr/src/new/jove/externs.h line 258, 866
- in /usr/src/new/jove/funcdefs.c line 88, 352

Digit6 defined in line 221; used 4 times

- in /usr/src/new/jove/externs.h line 259, 867
- in /usr/src/new/jove/funcdefs.c line 89, 353

Digit7 defined in line 227; used 4 times

- in /usr/src/new/jove/externs.h line 260, 868
- in /usr/src/new/jove/funcdefs.c line 90, 354

Digit8 defined in line 233; used 4 times

- in /usr/src/new/jove/externs.h line 261, 869
- in /usr/src/new/jove/funcdefs.c line 91, 355

Digit9 defined in line 239; used 4 times

- in /usr/src/new/jove/externs.h line 262, 870
- in /usr/src/new/jove/funcdefs.c line 92, 356

TimesFour defined in line 85; used 4 times

- in /usr/src/new/jove/externs.h line 395, 1003
- in /usr/src/new/jove/funcdefs.c line 115, 406

arg_type defined in line 34; used 4 times

- in /usr/src/new/jove/disp.c line 1200, 1253
- in /usr/src/new/jove/externs.h line 65, 672

arg_value defined in line 76; used 48 times

- in /usr/src/new/jove/ask.c line 160, 205(2)
- in /usr/src/new/jove/buf.c line 71
- in /usr/src/new/jove/c.c line 242, 255, 268, 281
- in /usr/src/new/jove/case.c line 44, 74
- in /usr/src/new/jove/delete.c line 105, 114, 125
- in /usr/src/new/jove/disp.c line 1153, 1195, 1248, 1266, 1275, 1313, 1325
- in /usr/src/new/jove/externs.h line 66, 673
- in /usr/src/new/jove/insert.c line 152, 188-190(2), 335-338(2), 393, 466
- in /usr/src/new/jove/macros.c line 149
- in /usr/src/new/jove/misc.c line 115, 300, 308
- in /usr/src/new/jove/move.c line 69, 75, 83, 91, 229, 247, 304, 310
- in /usr/src/new/jove/paragraph.c line 514
- in /usr/src/new/jove/proc.c line 216
- in /usr/src/new/jove/wind.c line 394, 400, 484, 513, 525

clr_arg_value defined in line 59; used 5 times

- in /usr/src/new/jove/ask.c line 186
- in /usr/src/new/jove/externs.h line 433, 1041
- in /usr/src/new/jove/jove.c line 1012
- in /usr/src/new/jove/jove.h line 626

gather_numeric_argument defined in line 126; used 14 times

- in line 18-22(2), 117, 182, 188, 194, 200, 206, 212, 218, 224, 230, 236, 242

is_an_arg defined in line 68; used 22 times

- in /usr/src/new/jove/ask.c line 161
- in /usr/src/new/jove/buf.c line 70
- in /usr/src/new/jove/disp.c line 1152, 1314
- in /usr/src/new/jove/externs.h line 95, 702
- in /usr/src/new/jove/jove.c line 938
- in /usr/src/new/jove/marks.c line 108
- in /usr/src/new/jove/misc.c line 117, 244, 297-300(2)
- in /usr/src/new/jove/paragraph.c line 326, 364
- in /usr/src/new/jove/proc.c line 324, 462
- in /usr/src/new/jove/re.c line 874
- in /usr/src/new/jove/re1.c line 343, 367
- in /usr/src/new/jove/wind.c line 484, 513, 525

negate_arg_value defined in line 53; used 9 times

- in /usr/src/new/jove/c.c line 271, 284
- in /usr/src/new/jove/disp.c line 1196, 1249
- in /usr/src/new/jove/externs.h line 504, 1110
- in /usr/src/new/jove/misc.c line 146
- in /usr/src/new/jove/move.c line 232, 250

quad_numeric_arg defined in line 96; used 3 times

- in line 19-23(2), 88

set_arg_value defined in line 46; used 9 times

- in /usr/src/new/jove/ask.c line 241
- in /usr/src/new/jove/c.c line 245, 258
- in /usr/src/new/jove/delete.c line 119
- in /usr/src/new/jove/extend.c line 122
- in /usr/src/new/jove/externs.h line 528, 1134
- in /usr/src/new/jove/misc.c line 298, 305

set_is_an_arg defined in line 40; used 3 times

- in /usr/src/new/jove/ask.c line 242
- in /usr/src/new/jove/externs.h line 530, 1136

#### Defined variables

arg_count defined in line 32; used 18 times

- in line 50, 56(2), 63, 79, 106-110(3), 136-146(6), 155(2), 161-165(2)

arg_supplied_p defined in line 31; used 12 times

- in line 37, 43, 49, 62, 71, 105, 116, 135-138(2), 159-163(3)

private defined in line 126; never used

#### Defined macros

private defined in line 28; used 5 times

- in line 12-21(3), 27-31(2)

Last modified: 1988-03-15 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1078 |