home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume6 / lbl / src / actions.c next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  1.5 KB  |  81 lines

  1. /* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  2.  *
  3.  *    Permission is hereby given to reproduce or modify this
  4.  *    software freely, provided that this notice be retained,
  5.  *    and that no use be made of the software for commercial
  6.  *    purposes without the express written permission of the
  7.  *    author.
  8.  */
  9.  
  10. /* actions.c:
  11.  *    keyword action routines
  12.  */
  13.  
  14. #include    <lbl.h>
  15. #include    <ctype.h>
  16.  
  17. extern char    *def_format;
  18. extern int    sflag;
  19. extern FILE    *tempfile;
  20.  
  21. /*ARGSUSED*/
  22. a_delimiter(nargs, argvec)
  23.     int    nargs;
  24.     char    *argvec[];
  25. {
  26.     if (strcmp(argvec[1], "off") == 0)
  27.     {
  28.         if (!sflag)
  29.             fprintf(tempfile, "%c%c%c\n", MAGIC1, MAGIC2, M_DELIM);
  30.         return;
  31.     }
  32.     if (argvec[1][1] != '\0')
  33.     {
  34.         error("delimiter more than 1 character");
  35.         return;
  36.     }
  37.     if (argvec[1][0] == '\0')
  38.     {
  39.         error("null delimiter character");
  40.         return;
  41.     }
  42.     if (!sflag)
  43.         fprintf(tempfile, "%c%c%c%c\n", MAGIC1, MAGIC2,
  44.                 M_DELIM, argvec[1][0]);
  45. }
  46.  
  47. /*ARGSUSED*/
  48. a_format(nargs, argvec)
  49.     int    nargs;
  50.     char    *argvec[];
  51. {
  52.     type    *tp    = findtype(argvec[1], 1);
  53.  
  54.     if (tp->t_format != def_format)
  55.         error("[warning] format for %s redefined", tp->t_name);
  56.     tp->t_format = copy(argvec[2]);
  57. }
  58.  
  59. /*ARGSUSED*/
  60. a_last(nargs, argvec)
  61.     int    nargs;
  62.     char    *argvec[];
  63. {
  64.     type    *tp    = findtype(argvec[1], 1);
  65.     int    indx;
  66.  
  67.     nargs -= 2;
  68.     argvec += 2;
  69.     for (indx = 0; indx < nargs; indx++)
  70.     {
  71.         if (!isdigit(argvec[indx][0]))
  72.         {
  73.             error("non-numeric label index");
  74.             break;
  75.         }
  76.         tp->t_levels[indx] = atoi(argvec[indx]);
  77.     }
  78.     while (indx < NLEVELS)
  79.         tp->t_levels[indx++] = 0;
  80. }
  81.