1: # include   "monitor.h"
   2: # include   <ingres.h>
   3: # include   <aux.h>
   4: #include    <sccs.h>
   5: 
   6: SCCSID(@(#)branch.c	8.1	12/31/84)
   7: 
   8: 
   9: 
  10: /*
  11: **  BRANCH
  12: **
  13: **	The "filename" following the \b op must match the "filename"
  14: **	which follows some \k command somewhere in this same file.
  15: **	The input pointer is placed at that point if possible.  If
  16: **	the label does not exist, an error is printed and the next
  17: **	character read is an EOF.
  18: **
  19: **	Trace Flags:
  20: **		33
  21: */
  22: 
  23: branch()
  24: {
  25:     register char   c;
  26:     register int    i;
  27:     extern char getch();
  28: 
  29: #	ifdef xMTR2
  30:     if (tTf(33, -1))
  31:         printf(">>branch: ");
  32: #	endif
  33: 
  34:     /* see if conditional */
  35:     while ((c = getch()) > 0)
  36:         if (c != ' ' && c != '\t')
  37:             break;
  38:     if (c == '?')
  39:     {
  40:         /* got a conditional; evaluate it */
  41:         Oneline = TRUE;
  42:         macinit(getch, 0, 0);
  43:         i = expr();
  44: 
  45:         if (i <= 0)
  46:         {
  47:             /* no branch */
  48: #			ifdef xMTR2
  49:             if (tTf(33, 0))
  50:                 printf("no branch\n");
  51: #			endif
  52:             getfilenm();
  53:             return;
  54:         }
  55:     }
  56:     else
  57:     {
  58:         ungetc(c, Input);
  59:     }
  60: 
  61:     /* get the target label */
  62:     if (branchto(getfilenm()) == 0)
  63:         if (branchto(macro("{default}")) == 0)
  64:         {
  65:             GiveEof = TRUE;
  66:             printf("Cannot branch\n");
  67:         }
  68:     return;
  69: }
  70: 
  71: 
  72: branchto(label)
  73: char    *label;
  74: {
  75:     char        target[100];
  76:     register char   c;
  77: 
  78:     smove(label, target);
  79:     if (rewind(Input))
  80:     {
  81:         printf("Cannot branch on a terminal\n");
  82:         return (1);
  83:     }
  84: 
  85:     /* search for the label */
  86:     while ((c = getch()) > 0)
  87:     {
  88:         if (c != '\\')
  89:             continue;
  90:         if (getescape(0) != C_MARK)
  91:             continue;
  92:         if (sequal(getfilenm(), target))
  93:             return;
  94:     }
  95: }

Defined functions

branch defined in line 6; used 1 times
branchto defined in line 72; used 2 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 846
Valid CSS Valid XHTML 1.0 Strict