rsalz@uunet.UUCP (10/01/87)
Submitted-by: jpayne@cs.rochester.edu
Posting-number: Volume 11, Issue 81
Archive-name: jove.pch/patch1
[ We let this one slip by. Sorry, folks. --r$ ]
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: argcount.c
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f argcount.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"argcount.c\"
else
echo shar: Extracting \"argcount.c\" \(3367 characters\)
sed "s/^X//" >argcount.c <<'END_OF_argcount.c'
X/************************************************************************
X * This program is Copyright (C) 1986 by Jonathan Payne. JOVE is *
X * provided to you without charge, and with no warranty. You may give *
X * away copies of JOVE, including sources, provided that this notice is *
X * included in all the files. *
X ************************************************************************/
X
X#include "jove.h"
X#include <ctype.h>
X
Xprivate int arg_supplied_p,
X arg_count;
X
Xarg_type()
X{
X return arg_supplied_p;
X}
X
Xset_is_an_arg(there_is)
X{
X arg_supplied_p = there_is;
X}
X
Xset_arg_value(n)
X{
X arg_supplied_p = YES;
X arg_count = n;
X}
X
Xnegate_arg_value()
X{
X arg_count = -arg_count;
X}
X
Xclr_arg_value()
X{
X arg_supplied_p = NO;
X arg_count = 1;
X}
X
X/* return whether there is currently a numeric argument */
Xis_an_arg()
X{
X return (arg_supplied_p != NO);
X}
X
X/* return the numeric argument */
Xarg_value()
X{
X return arg_count;
X}
X
X/* called by C-U to gather a numeric argument, either C-U's or digits,
X but not both */
XTimesFour()
X{
X quad_numeric_arg();
X}
X
X/* This initializes the numeric argument to 1 and starts multiplying
X by 4 (the magic number Stallman came up with). It is an error to
X invoke quad_numeric_arg() interactively (via TimesFour()), because
X it uses the LastKeyStruck variable to know what character signals
X to multiply again (in the loop). */
Xprivate
Xquad_numeric_arg()
X{
X int oldc = LastKeyStruck,
X newc,
X narg_count,
X slow;
X
X slow = 0;
X arg_supplied_p = YES;
X arg_count = 1;
X this_cmd = ARG_CMD;
X do {
X if ((narg_count = arg_count * 4) != 0)
X arg_count = narg_count;
X if (!slow)
X newc = waitchar(&slow);
X else
X newc = getch();
X if (isdigit(newc) || newc == '-') {
X arg_supplied_p = NO;
X gather_numeric_argument(newc);
X return;
X }
X if (slow)
X message(key_strokes);
X } while (newc == oldc);
X Ungetc(newc);
X}
X
Xprivate
Xgather_numeric_argument(c)
X{
X int sign = 0;
X static int digited;
X int slow = 0;
X
X if (!isdigit(c) && c != '-')
X complain((char *) 0);
X if (arg_supplied_p == NO) { /* if we just got here */
X arg_count = 0; /* start over */
X digited = NO;
X } else if (arg_supplied_p == YES_NODIGIT) {
X sign = (arg_count < 0) ? -1 : 1;
X arg_count = 0;
X }
X
X if (!sign)
X sign = (arg_count < 0) ? -1 : 1;
X if (sign == -1)
X arg_count = -arg_count;
X if (c == '-') {
X sign = -sign;
X goto goread;
X }
X for (;;) {
X if (slow)
X message(key_strokes);
X if (isdigit(c)) {
X arg_count = (arg_count * 10) + (c - '0');
X digited = YES;
X } else {
X if (digited)
X arg_supplied_p = YES;
X else {
X arg_count = 1;
X if (arg_supplied_p == NO)
X arg_supplied_p = YES_NODIGIT;
X }
X arg_count *= sign;
X this_cmd = ARG_CMD;
X Ungetc(c);
X return;
X }
Xgoread: if (!slow)
X c = waitchar(&slow);
X else {
X add_mess(NullStr);
X c = getch();
X }
X }
X}
X
XDigit()
X{
X gather_numeric_argument(LastKeyStruck);
X}
X
XDigit0()
X{
X gather_numeric_argument('0');
X}
X
XDigit1()
X{
X gather_numeric_argument('1');
X}
X
XDigit2()
X{
X gather_numeric_argument('2');
X}
X
XDigit3()
X{
X gather_numeric_argument('3');
X}
X
XDigit4()
X{
X gather_numeric_argument('4');
X}
X
XDigit5()
X{
X gather_numeric_argument('5');
X}
X
XDigit6()
X{
X gather_numeric_argument('6');
X}
X
XDigit7()
X{
X gather_numeric_argument('7');
X}
X
XDigit8()
X{
X gather_numeric_argument('8');
X}
X
XDigit9()
X{
X gather_numeric_argument('9');
X}
END_OF_argcount.c
if test 3367 -ne `wc -c <argcount.c`; then
echo shar: \"argcount.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0