File: yuk.c

package info (click to toggle)
intercal 30:0.30-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,044 kB
  • sloc: ansic: 8,936; sh: 1,274; yacc: 1,073; lex: 518; lisp: 460; makefile: 435; perl: 295
file content (839 lines) | stat: -rw-r--r-- 26,065 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
/****************************************************************************

NAME
    yuk.c -- C-INTERCAL debugger and profiler code, linked into programs.

DESCRIPTION
    File linked into programs as a debugger or profiler.

LICENSE TERMS
    Copyright (C) 2006 Alex Smith

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

****************************************************************************/
#include "config.h" /* AIS: Generated by autoconf */
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# ifdef TIME_WITH_SYS_TIME
#  include <time.h>
# endif
#else
# include <time.h>
#endif
#include <signal.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <setjmp.h>
#include <string.h>

#define YUKDEBUG 1

#include "yuk.h"
#include "ick_lose.h"
#include "sizes.h"
#include "abcess.h"
#include "uncommon.h"

#if YPTIMERTYPE == 4
#include <sys/times.h>
#endif

extern signed char onewatch[];
extern signed char twowatch[];
extern ick_type16      oneold[];
extern ick_type32      twoold[];

char** globalargv;
int globalargc;
int yuklines = 0;
int yukloop = 0;
int yukcommands = 0; /* these 5 lines because externs must be defined
			somewhere */
/* Global variable storage types:
   static: limited to the file
   unadorned: defining an extern
   extern: defined elsewhere (unless initialised) */

static char buf[21];

static sig_atomic_t singlestep = 1; /* if 0, run until a breakpoint */
static sig_atomic_t writelines = 1; /* whether to display executed lines onscreen */
static int breakpoints[80]; /* initialised to all 0s. Breakpoint locations */
static int nbreakpoints = 1; /* how many breakpoints we have */
static int monitors[80]; /* monitors give a message when program flow passes them */
static int nmonitors = 0;
static int untilnext = -1; /* NEXTING level to break the program at */
static int firstrun = 1; /* ick_first time an interactive command point is reached */
static int yukerrcmdg = -1; /* the aboff that indicates an error in the 'g' command */

static yptimer tickcount; /* yptimer of last run */
static int lastaboff = 0; /* last value of aboff */

static void handlesigint(int i)
{ /* this is a signal handler, so can't do much */
  singlestep = 1;
  writelines = 1;
  /*@-noeffect@*/ (void) i; /*@=noeffect@*/
}

#if YPTIMERTYPE==1 || YPTIMERTYPE==2
static yptimer yukgettimeofday()
{
  static struct timeval tp;
  yptimer temp;
  /* gettimeofday is POSIX; config.sh has checked that it's
     available, so turn off the unrecog warning */
  /*@-unrecog@*/
  gettimeofday(&tp,0);
  /*@=unrecog@*/
  temp=(yptimer)tp.tv_usec +
    (yptimer)tp.tv_sec * (yptimer)1000000LU;
  /* here we make use of unsigned wraparound. In the case
     YPTIMERTYPE == 1, it seems quite likely that we're going
     to wraparound, but because everything is cast to the
     unsigned integral type yptimer, we get a value that will
     wraparound in such a way that - will give us the correct
     time interval. */
  return temp;
}
#elif YPTIMERTYPE == 4
yptimer yuktimes()
{
  static struct tms tp;
  times(&tp);
  return tp.tms_utime + tp.tms_stime;
}
#elif YPTIMERTYPE == 5
static yptimer yukclock_gettime()
{
  static struct timespec ts;
  yptimer temp;
  /* We've checked that this function is available; -lrt will be linked in. */
  /*@-unrecog@*/
#if defined(_POSIX_CPUTIME) && _POSIX_CPUTIME > 0
  clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&ts);
#else
# if defined(_POSIX_THREAD_CPUTIME) && _POSIX_THREAD_CPUTIME > 0
  clock_gettime(CLOCK_THREAD_CPUTIME_ID,&ts);
# else
#  if defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK > 0
  clock_gettime(CLOCK_MONOTONIC,&ts);
#  else
#   ifndef CLOCK_REALTIME
#    error clock_gettime is defined, but no clocks seem to be; try changing YPTIMERTYPE in src/yuk.h
#   endif
  clock_gettime(CLOCK_REALTIME,&ts);
#  endif
# endif
#endif
  /*@=unrecog@*/
  temp=(yptimer)ts.tv_nsec +
    (yptimer)ts.tv_sec * (yptimer)1000000000LU;
  /* using wraparound as with gettimeofday */
  return temp;
}
#endif /* YPTIMERTYPE */

void yukterm(void)
{
  int i,lastline,thisline,inrow=0;
  yptimer avgtime,avgtime2;
  FILE *dummy;
  if(yukopts==2) (void) puts("Program ended without error.");
  if(!(yukopts&1)) return;
  /* Print profiling information */
  (void) puts("Profiling information saved to \"yuk.out\".");
  /* Bletch.  GCC's unsuppressible warning forces us to this */
  dummy = freopen("yuk.out","w",stdout);
  i=-1;
  lastline=-1;
  while(++i<yukcommands)
  {
    thisline=lineofaboff[i];
    if(thisline==lastline) inrow++; else
    {
      inrow=1;
      printf("%5d:\t%s\n",thisline,textlines[thisline]);
    }
    lastline=thisline;
    avgtime=ypexecount[i]+ypabscount[i];
    if(avgtime) avgtime=ypexectime[i]/avgtime;
    avgtime2=0;
    if(ypexecount[i]) avgtime2=ypexectime[i]/ypexecount[i];
    /*@-formatcode@*/ /* Splint doesn't understand string interpolation */
    printf("C%d: Time%4" YPTIMERTFORMAT ".%0" YPTIMERTFORMATD
	   ", Avg%2" YPTIMERTFORMAT ".%0" YPTIMERTFORMATD ", "
	   "Avg Exec%2" YPTIMERTFORMAT ".%0" YPTIMERTFORMATD
	   ", Exec%8" YPCOUNTERTFORMAT ", Abs%8" YPCOUNTERTFORMAT "\n",
	   inrow,ypexectime[i]/YPTIMERSCALE, ypexectime[i]%YPTIMERSCALE,
	   avgtime/YPTIMERSCALE, avgtime%YPTIMERSCALE,
	   avgtime2/YPTIMERSCALE, avgtime2%YPTIMERSCALE,
	   ypexecount[i],ypabscount[i]);
    /*@=formatcode@*/
  }
}

void yukline(int aboff,int emitlineno)
{ /* this runs every time a source line is encountered */
  int i;
  int broken; /* hit a breakpoint, monitorpoint, viewbreak, until */
  int keeplooping;
  int templine;
  int tempcmd;
  int temp;
  yptimer temptick;
  char* text=textlines[lineofaboff[aboff]];
  char copyloc[BUFSIZ+9];
  const char* tempcharp;
  if(!yukopts) return;
  if(globalargc!=3)
    ick_lose(IE778,emitlineno,(const char*)NULL);
  if(yukopts & 1)
  { /* profile */
    temptick=YPGETTIME;
    if(lastaboff) ypexectime[lastaboff]+=(yptimer)(temptick-tickcount);
    tickcount=temptick;
    if(ick_abstained[aboff]) ypabscount[aboff]++;
    else ypexecount[aboff]++;
    lastaboff=aboff;
  }
  if(yukopts & 2)
  { /* debug */
    if(firstrun)
    {
      /* GNU GPL requires a copyright notice at this point */
      (void) puts("yuk debugger Copyright (C) 2006 Alex Smith.");
      (void) puts("The yuk debugger is covered by the GNU GPL and can");
      (void) puts("be redistributed freely, but comes with ABSOLUTELY");
      (void) puts("NO WARRANTY. For more information, type *<RET>.\n");
      (void) puts("For help on yuk, type ?<RET>.\n");
    }
    i=nbreakpoints;
    broken=0;
    while(i--) broken|=breakpoints[i]==lineofaboff[aboff];
    if(yukloop&&broken&&*breakpoints!=lineofaboff[aboff]) broken=0;
    if(broken)
    {
      if(*breakpoints!=lineofaboff[aboff])
	printf("Breakpoint hit at line %d:\n",lineofaboff[aboff]);
      singlestep=1;
    }
    else
    {
      i=nmonitors;
      while(i--) broken|=monitors[i]==lineofaboff[aboff];
      if(yukloop) broken=0;
      if(broken) printf("Command flowed past line %d:\n",lineofaboff[aboff]);
    }
    if(ick_nextindex <= untilnext)
    {
      broken = 1;
      singlestep = 1;
    }
    if(!broken&&yukerrcmdg==aboff)
    {
      singlestep = 1;
      (void) puts("There are no commands on that line.");
      /* To the user, nothing will have happened but the error message! */
    }
    i=-1;
    while(++i,1)
    {
      if(yukvars[i].vartype==YUKEND) break;
      if(yukvars[i].vartype==ick_ONESPOT)
      {
	if(onewatch[yukvars[i].intername] != (char)0)
	{
	  if(ick_onespots[yukvars[i].intername]!=oneold[yukvars[i].intername]&&
	     onewatch[yukvars[i].intername]>(char)1)
	  {
	    oneold[yukvars[i].intername]=ick_onespots[yukvars[i].intername];
	    if(onewatch[yukvars[i].intername]==(char)2||!ick_onespots[yukvars[i].intername])
	    {
	      /*@-formatconst@*/ /* it's safe, I checked it */
	      printf(onewatch[yukvars[i].intername]==(char)2?
		     "Variable .%d changed.\n":"Variable .%d became 0.\n",
		     yukvars[i].extername);
	      /*@=formatconst@*/
	      broken=1; singlestep=1;
	    }
	  }
	  if(writelines||broken)
	  {
	    printf(".%d is:\n",yukvars[i].extername);
	    ick_pout(ick_onespots[yukvars[i].intername]);
	  }
	}
      }
      if(yukvars[i].vartype==ick_TWOSPOT)
      {
	if(twowatch[yukvars[i].intername] != (char)0)
	{
	  if(ick_twospots[yukvars[i].intername]!=twoold[yukvars[i].intername]&&
	     twowatch[yukvars[i].intername] > (char)1)
	  {
	    twoold[yukvars[i].intername]=ick_twospots[yukvars[i].intername];
	    if(twowatch[yukvars[i].intername]==(char)2||!ick_twospots[yukvars[i].intername])
	    {
	      /*@-formatconst@*/ /* there's just the one %d each way round */
	      printf(twowatch[yukvars[i].intername]==(char)2?
		     "Variable :%d changed.\n":"Variable :%d became 0.\n",
		     yukvars[i].extername);
	      /*@=formatconst@*/
	      broken=1; singlestep=1;
	    }
	  }
	  if(writelines||broken)
	  {
	    printf(":%d is:\n",yukvars[i].extername);
	    ick_pout(ick_twospots[yukvars[i].intername]);
	  }
	}
      }
    }
    if(writelines||broken)
    {
      /* write line that we're on */
      printf("%5d:\t%s\n",lineofaboff[aboff],text);
      /* write command within line that we're on */
      tempcmd=aboff;
      while(tempcmd&&lineofaboff[--tempcmd]==lineofaboff[aboff]);
      printf("On C%d: Abstained %d time%s\n",aboff?aboff-tempcmd:1,
	     ick_abstained[aboff]-yukloop,ick_abstained[aboff]-yukloop==1?".":"s.");
    }
    if(singlestep)
    {
      (void)signal(SIGINT,handlesigint); /* placing this line here means that a rapid
					    ^C^C will terminate the program, if it's
					    stuck in a loop somewhere */
      keeplooping = 1;
      breakpoints[0] = 0; /* breakpoints[0] goes whenever a breakpoint is hit */
      untilnext = -1;
      if(yukloop)
      { /* reverse the abstentions that g caused */
	i = -1;
	while(++i<yukcommands) ick_abstained[i]--;
      }
      yukloop = 0;
      yukerrcmdg = -1;
      do
      {
	printf("yuk007 "); /* this is our prompt, a sort of reverse
			      INTERCAL version of % */
	if (fgets(buf,20,stdin) == NULL)
	    break;;
	if(!strchr(buf,'\n'))
	{
	  ick_lose(IE810,emitlineno,(const char*)NULL);
	}
	templine=0;
	switch(*buf)
	{
	case '?':
	case '@':
	  (void) puts("a<line>\tabstain once from all non-ick_abstained commands on <line>");
	  (void) puts("b<line>\tset breakpoint at <line>");
	  (void) puts("c\tcontinue execution until a breakpoint is reached");
	  (void) puts("d<line>\tdelete breakpoint at <line>");
	  (void) puts("e<line>\texplain the ick_main expression on <line>");
	  (void) puts("f<line>\tstop producing messages when commands on <line> are run");
	  (void) puts("g<line>\tchange currently executing command to the ick_first command");
	  (void) puts("\ton <line> or the ick_next command if already on <line>");
	  (void) puts("h\tlist 10 lines either side of the current line");
	  (void) puts("i<var>\tignore a variable");
	  (void) puts("j<var>\tremember a variable");
	  (void) puts("k\tcontinue until we RESUME back to the current nexting level");
	  (void) puts("\t(that is, step unless we are on a NEXT, in which case execute");
	  (void) puts("\tuntil a RESUME or FORGET back to the same or smaller NEXT stack)");
	  (void) puts("l<line>\tlist 10 lines either side of <line>");
	  (void) puts("m<line>\tproduce a message every time a command on <line> is run");
	  (void) puts("n\tshow the NEXT stack");
	  (void) puts("o\tcontinue until we RESUME/FORGET below the current nexting level");
	  (void) puts("\tie until the NEXT stack becomes smaller than it is at present");
	  (void) puts("p\tdisplay the values of all onespot and twospot variables");
	  (void) puts("q\tabort execution");
	  (void) puts("r<line>\treinstate once all ick_abstained commands on <line>");
	  (void) puts("s\texecute one command");
	  (void) puts("t\tcontinue until a breakpoint, displaying all lines executed");
	  (void) puts("u<line>\texecute until just before <line> is reached");
	  (void) puts("v<var>\tshow value of variable every time a command is printed");
	  (void) puts("w\tshow the current line and current command");
	  (void) puts("x<var>\tremove a variable view, breakchange, or breakzero");
	  (void) puts("y<var>\tview variable every displayed line, and break on change");
	  (void) puts("z<var>\tview variable every displayed line, and break on zero");
	  (void) puts("<var>\tview the value of a onespot or twospot variable");
	  (void) puts("<<var>\tset the value of a onespot or twospot variable");
	  (void) puts("*\tview the GNU General Public License");
	  (void) puts("?\tview this help screen");
	  (void) puts("@\tview this help screen");
	  (void) puts("Line numbers refer to lines of source code, not line labels.");
	  (void) puts("Listings have (Axxxxxx) at the start of each line: this shows");
	  (void) puts("the abstention status of each command on that line.");
	  (void) puts("The values of variables must be input in proper INTERCAL");
	  (void) puts("notation (i.e. ONE TWO THREE), and are output as butchered");
	  (void) puts("Roman ick_numerals.");
#ifdef __DJGPP__
	  (void) puts("You can press <CTRL>-<BREAK> to interrupt an executing program.");
#else
	  (void) puts("You can press <CTRL>-C to interrupt an executing program.");
#endif
	  break;
	case 'q':
	  exit(0);
	  /*@-unreachable@*/ break; /*@=unreachable@*/
	case 'n':
	  i=ick_nextindex;
	  if(!i)
	  {
	    (void) puts("The NEXT stack is empty.");
	  }
	  else
	  {
	    (void) puts("Commands NEXTED from:");
	    while(i--)
	    {
	      /* write NEXT line */
	      printf("%5d:\t%s\n",lineofaboff[ick_next[i]-1],
		     textlines[lineofaboff[ick_next[i]-1]]);
	      /* write NEXT command within line */
	      tempcmd=(int)ick_next[i];
	      while(tempcmd&&lineofaboff[--tempcmd]==lineofaboff[ick_next[i]-1]);
	      printf("NEXTED from command C%u: Abstained %d time%s\n",ick_next[i]-1?
		     ick_next[i]-1-tempcmd:1,ick_abstained[ick_next[i]-1],
		     ick_abstained[ick_next[i]-1]==1?".":"s.");
    	    }
	  }
	  break;
	case 'w':
	  /* write line that we're on */
	  printf("%5d:\t%s\n",lineofaboff[aboff],text);
	  /* write command within line that we're on */
	  tempcmd=aboff;
	  while(tempcmd&&lineofaboff[--tempcmd]==lineofaboff[aboff]);
	  printf("On C%d: Abstained %d time%s\n",aboff?aboff-tempcmd:1,ick_abstained[aboff],
	     ick_abstained[aboff]==1?".":"s.");
	  break;
	case 'p':
	  i=-1;
	  while(++i,1)
	  {
	    if(yukvars[i].vartype==YUKEND) break;
	    if(yukvars[i].vartype==ick_ONESPOT)
	    {
	      printf("Variable .%d is:\n",yukvars[i].extername);
	      ick_pout(ick_onespots[yukvars[i].intername]);
	    }
	    if(yukvars[i].vartype==ick_TWOSPOT)
	    {
	      printf("Variable :%d is:\n",yukvars[i].extername);
	      ick_pout(ick_twospots[yukvars[i].intername]);
	    }
	  }
	  break;
	case '.':
	case ':':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(templine<1 || temp != 1)
	  {
	    (void) puts("Don't know which variable you mean.");
	    break;
	  }
	  i=-1;
	  temp=0;
	  while(++i,!temp)
	  {
	    if(yukvars[i].vartype==YUKEND) break;
	    if((*buf=='.'&&yukvars[i].vartype==ick_ONESPOT)||
	       (*buf==':'&&yukvars[i].vartype==ick_TWOSPOT))
	    {
	      if(yukvars[i].extername==templine)
	      {
		temp=1;
		if(yukvars[i].vartype==ick_ONESPOT)
		{
		  ick_pout(ick_onespots[yukvars[i].intername]);
		  (void) puts(ick_oneforget[yukvars[i].intername]?
		       "This variable is currently ignored.":
		       "This variable is currently remembered.");
		}
		if(yukvars[i].vartype==ick_TWOSPOT)
		{
		  ick_pout(ick_twospots[yukvars[i].intername]);
		  (void) puts(ick_twoforget[yukvars[i].intername]?
		       "This variable is currently ignored.":
		       "This variable is currently remembered.");
		}
	      }
	    }
	  }
	  if(temp) break;
	  (void) puts("That variable is not in the program.");
	  break;
	case 'v':
	case 'x':
	case 'y':
	case 'z':
	  if(buf[1]!='.'&&buf[1]!=':')
	  {
	    (void) puts("This command only works on onespot and twospot variables.");
	    break;
	  }
	  temp = sscanf(buf+2,"%d",&templine);
	  if(templine<1 || temp != 1)
	  {
	    (void) puts("Don't know which variable you mean.");
	    break;
	  }
	  i=-1;
	  temp=0;
	  while(++i,!temp)
	  {
	    if(yukvars[i].vartype==YUKEND) break;
	    if(yukvars[i].extername==templine)
	    {
	      if(buf[1]=='.'&&yukvars[i].vartype==ick_ONESPOT)
	      {
		if(*buf=='v') onewatch[yukvars[i].intername]=(char)1;
		if(*buf=='x') onewatch[yukvars[i].intername]=(char)0;
		if(*buf=='y') onewatch[yukvars[i].intername]=(char)2;
		if(*buf=='z') onewatch[yukvars[i].intername]=(char)3;
		oneold[yukvars[i].intername]=ick_onespots[yukvars[i].intername];
		temp=1;
	      }
	      if(buf[1]==':'&&yukvars[i].vartype==ick_TWOSPOT)
	      {
		if(*buf=='v') twowatch[yukvars[i].intername]=(char)1;
		if(*buf=='x') twowatch[yukvars[i].intername]=(char)0;
		if(*buf=='y') twowatch[yukvars[i].intername]=(char)2;
		if(*buf=='z') twowatch[yukvars[i].intername]=(char)3;
		twoold[yukvars[i].intername]=ick_twospots[yukvars[i].intername];
		temp=1;
	      }
	    }
	  }
	  if(!temp)
	  {
	    (void) puts("That variable is not in the program.");
	    break;
	  }
	  if(*buf=='v') (void) puts("Set a normal variable view.");
	  if(*buf=='x') (void) puts("Removed all views from that variable.");
	  if(*buf=='y') (void) puts("Set a breakchange variable view.");
	  if(*buf=='z') (void) puts("Set a breakzero variable view.");
	  break;
	case 'i':
	case 'j':
	  if(buf[1]!='.'&&buf[1]!=':'&&buf[1]!=','&&buf[1]!=';')
	  {
	    (void) puts("That isn't a real sort of variable.");
	    break;
	  }
	  temp = sscanf(buf+2,"%d",&templine);
	  if(templine<1 || temp != 1)
	  {
	    (void) puts("Don't know which variable you mean.");
	    break;
	  }
	  i=-1;
	  temp=0;
	  while(++i,!temp)
	  {
	    if(yukvars[i].vartype==YUKEND) break;
	    if((buf[1]=='.'&&yukvars[i].vartype==ick_ONESPOT)||
	       (buf[1]==':'&&yukvars[i].vartype==ick_TWOSPOT)||
	       (buf[1]==','&&yukvars[i].vartype==ick_TAIL)||
	       (buf[1]==';'&&yukvars[i].vartype==ick_HYBRID))
	    {
	      if(yukvars[i].extername==templine)
	      {
		temp=1;
		if(yukvars[i].vartype==ick_ONESPOT)
		  ick_oneforget[yukvars[i].intername]=*buf=='i';
		if(yukvars[i].vartype==ick_TWOSPOT)
		  ick_twoforget[yukvars[i].intername]=*buf=='i';
		if(yukvars[i].vartype==ick_TAIL)
		  ick_tailforget[yukvars[i].intername]=*buf=='i';
		if(yukvars[i].vartype==ick_HYBRID)
		  ick_hyforget[yukvars[i].intername]=*buf=='i';
	      }
	    }
	  }
	  if(temp)
	  {
	    if(*buf=='i')
	      (void) puts("Variable ignored.");
	    else
	      (void) puts("Variable remembered.");
	    break;
	  }
	  (void) puts("That variable is not in the program.");
	  break;
	  	case '<':
	  if(buf[1]!='.'&&buf[1]!=':')
	  {
	    (void) puts("You cannot set that sort of variable (if it exists at all).");
	    break;
	  }
	  temp = sscanf(buf+2,"%d",&templine);
	  if(templine<1 || temp != 1)
	  {
	    (void) puts("Don't know which variable you mean.");
	    break;
	  }
	  i=-1;
	  temp=0;
	  while(++i,!temp)
	  {
	    if(yukvars[i].vartype==YUKEND) break;
	    if((buf[1]=='.'&&yukvars[i].vartype==ick_ONESPOT)||
	       (buf[1]==':'&&yukvars[i].vartype==ick_TWOSPOT))
	    {
	      if(yukvars[i].extername==templine)
	      {
		temp=1;
		if(yukvars[i].vartype==ick_ONESPOT)
		  ick_onespots[yukvars[i].intername]=(ick_type16)ick_pin();
		if(yukvars[i].vartype==ick_TWOSPOT)
		  ick_twospots[yukvars[i].intername]=(ick_type32)ick_pin();
		/* note that when debugging, you can set an
		   ignored variable */
	      }
	    }
	  }
	  if(temp) break;
	  (void) puts("That variable is not in the program.");
	  break;
	case 'g':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(!templine || temp != 1)
	  {
	    (void) puts("Don't know which line you mean.");
	    break;
	  }
	  breakpoints[0] = templine;
	  yukloop = 1;
	  /* This is implemented by incrementing all ABSTAIN counts,
	     even the normally immutable ones on GIVE UP lines, setting
	     a temporary breakpoint ([0]) on the line given, and running the
	     program. When the breakpoint is hit singlestep will see that
	     yukloop is set (its purpose is to cause the program to go back
	     to the start when it reaches the end) and decrement all ABSTAIN
	     counts, putting the commands back the way they were. We set an error
	     breakpoint on this line in case the user is trying to jump to a
	     line with no commands (although this debugger command is called
	     'g', would I dare to describe this as a GOTO?) */
	  i = -1;
	  while(++i<yukcommands) ick_abstained[i]++;
	  yukerrcmdg = aboff;
	  singlestep = 0;
	  writelines = 0;
	  keeplooping = 0; /* to break out of the loop in the debugger! */
	  break;
	case 'a':
	case 'r':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(!templine || temp != 1)
	  {
	    (void) puts("Don't know which line you mean.");
	    break;
	  }
	  i=-1;
	  tempcmd=1;
	  while(++i<yukcommands)
	  {
	    if(lineofaboff[i]==templine)
	    {
	      temp=ick_abstained[i];
	      if(*buf=='a') if(!temp) ick_abstained[i]=1;
	      if(*buf=='r') if(temp) ick_abstained[i]--;
	      printf("Command %d on line %d was ick_abstained %d time%s, "
		     "now ick_abstained %d time%s.\n",tempcmd,templine,
		     temp,temp==1?"":"s",ick_abstained[i],
		     ick_abstained[i]==1?"":"s");
	      tempcmd++;
	    }
	  }
	  if(tempcmd==1) (void) puts("No commands start on this line.");
	  break;
	case 'k':
	case 'o':
	  untilnext=ick_nextindex-(*buf=='o');
	  /*@fallthrough@*/
	case 'c':
	  singlestep=0;
	  writelines=0;
	  keeplooping=0;
	  break;
	case 'b':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(templine && temp == 1)
	  {
	    printf("Breakpoint set at line %d.\n",templine);
	    breakpoints[nbreakpoints++]=templine;
	    if(nbreakpoints>=80) ick_lose(IE811,emitlineno,(const char*)NULL);
	  }
	  else
	    (void) puts("Don't know which line you mean.");
	  break;
	case 'd':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(templine && temp == 1)
	  {
	    printf("All breakpoints removed from line %d.\n",templine);
	    i=nbreakpoints;
	    while(i--) if(templine==breakpoints[i])
	    {
	      memmove(breakpoints+i,breakpoints+i+1,sizeof(int)*(nbreakpoints-i));
	      nbreakpoints--;
	    }
	  }
	  else
	    (void) puts("Don't know which line you mean.");
	  break;
	case 'm':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(templine && temp == 1)
	  {
	    printf("Monitor set at line %d.\n",templine);
	    monitors[nmonitors++]=templine;
	    if(nmonitors>=80) ick_lose(IE811,emitlineno,(const char*)NULL);
	  }
	  else
	    (void) puts("Don't know which line you mean.");
	  break;
	case 'f':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(templine && temp == 1)
	  {
	    printf("All monitors removed from line %d.\n",templine);
	    i=nmonitors;
	    while(i--) if(templine==monitors[i])
	    {
	      memmove(monitors+i,monitors+i+1,sizeof(int)*(nmonitors-i));
	      nmonitors--;
	    }
	  }
	  else
	    (void) puts("Don't know which line you mean.");
	  break;
	case 's':
	  singlestep=1;
	  writelines=1;
	  keeplooping=0;
	  break;
	case 't':
	  singlestep=0;
	  writelines=1;
	  keeplooping=0;
	  break;
	case 'u':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(templine && temp == 1)
	  {
	    breakpoints[0]=templine;
	    singlestep=0;
	    writelines=0;
	    keeplooping=0;
	  }
	  else
	    (void) puts("Don't know which line you mean.");
	  break;
	case 'e':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(!templine || temp != 1)
	  {
	    (void) puts("Don't know which line you mean.");
	    break;
	  }
	  tempcmd=-1;
	  temp=0;
	  i=0;
	  while(++tempcmd<yukcommands)
	  {
	    if(lineofaboff[tempcmd]==templine)
	    {
	      if(!yukexplain[tempcmd]) ++i;
	      else
	      {
		printf("C%d: Expression is %s\n",++i,yukexplain[tempcmd]);
		temp++;
	      }
	    }
	  }
	  if(!temp) (void) puts("No expressions on that line.");
	  break;
	case 'l':
	  temp = sscanf(buf+1,"%d",&templine);
	  if(!templine || temp != 1)
	  {
	    (void) puts("Don't know which line you mean.");
	    break;
	  }
	  /*@fallthrough@*/
	case 'h':
	  if(!templine) templine=lineofaboff[aboff];
	  templine-=10;
	  if(templine+21>=yuklines) templine=yuklines-22;
	  if(templine<1) templine=1;
	  i=templine;
	  while(i<templine+21&&i<yuklines)
	  {
	    buf[6]='\0';
	    buf[0]=buf[1]=buf[2]=buf[3]=buf[4]=buf[5]=' ';
	    tempcmd=-1;
	    temp=0;
	    while(++tempcmd<yukcommands)
	    {
	      if(lineofaboff[tempcmd]==i)
	      {
		if(ick_abstained[tempcmd]>9) buf[temp++]='!';
		else buf[temp++]='0'+(char)ick_abstained[tempcmd];
		if(temp==6) break;
	      }
	    }
	    printf("(A%s)%5d:\t%s\n",buf,i,textlines[i]);
	    i++;
	  }
	  break;
	case '*':
	  tempcharp=ick_findandtestopen("COPYING.txt",globalargv[1],
				    "r",globalargv[2]);
	  if(tempcharp != NULL)
	  {
#ifndef HAVE_SNPRINTF
	    (void) sprintf(copyloc,"more < %s",tempcharp);
#else
	    (void) snprintf(copyloc,sizeof copyloc,"more < %s",tempcharp);
#endif
	    if (system(copyloc) != 0) /* display the GNU GPL copyright */
		(void) puts("Your system is more confused.");
	  }
	  else
	    (void) puts("Couldn't find license file. See the file COPYING.txt that\n"
			"came with your C-INTERCAL distribution.");
	  break;
	default:
	  (void) puts("Not sure what you mean. Try typing ?<RET>.");
	  break;
	}
      } while(keeplooping);
    }
  }
  firstrun=0;
}