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

Defined functions

branch defined in line 19; used 1 times
branchto defined in line 69; used 2 times
Last modified: 1995-02-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2839
Valid CSS Valid XHTML 1.0 Strict