File:  [Coherent Logic Development] / freem / src / cmd_kvalue.c
Revision 1.1: download - view: text, annotated - select for diffs
Sun Jan 19 02:04:04 2025 UTC (14 months, 1 week ago) by snw
Branches: MAIN
CVS tags: HEAD
Initial revision

    1: /*
    2:  *                            *
    3:  *                           * *
    4:  *                          *   *
    5:  *                     ***************
    6:  *                      * *       * *
    7:  *                       *  MUMPS  *
    8:  *                      * *       * *
    9:  *                     ***************
   10:  *                          *   *
   11:  *                           * *
   12:  *                            *
   13:  *
   14:  *   cmd_kvalue.c
   15:  *    Implementation of the KVALUE command
   16:  *
   17:  *  
   18:  *   Author: Serena Willis <jpw@coherent-logic.com>
   19:  *    Copyright (C) 1998 MUG Deutschland
   20:  *    Copyright (C) 2023 Coherent Logic Development LLC
   21:  *
   22:  *
   23:  *   This file is part of FreeM.
   24:  *
   25:  *   FreeM is free software: you can redistribute it and/or modify
   26:  *   it under the terms of the GNU Affero Public License as published by
   27:  *   the Free Software Foundation, either version 3 of the License, or
   28:  *   (at your option) any later version.
   29:  *
   30:  *   FreeM is distributed in the hope that it will be useful,
   31:  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   32:  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   33:  *   GNU Affero Public License for more details.
   34:  *
   35:  *   You should have received a copy of the GNU Affero Public License
   36:  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
   37:  *
   38:  **/
   39: 
   40: #include <string.h>
   41: #include <stdlib.h>
   42: #include "mpsdef.h"
   43: #include "mcommand.h"
   44: #include "consttbl.h"
   45: 
   46: MRESULT cmd_kvalue(MACTION *ra)
   47: {
   48:     register char ch;
   49:     char vn[255];
   50:     
   51:     if ((rtn_dialect () != D_FREEM) &&
   52:         (rtn_dialect () != D_MDS)) {
   53:         return NOSTAND;
   54:     }
   55:     
   56:     /* argumentless: KVALUE nukleurrr winturr */
   57:     if (((ch = *codptr) == SP) || ch == EOL) {
   58:         write_m ("Argumentless KVALUE not yet implemented.\201");
   59:         *ra = RA_NEXTCMND;
   60:         return OK;
   61:     }
   62:     
   63:     
   64:     if (ch != '(') { /* inclusive KVALUE */
   65:         
   66:         for (;;) {
   67: 
   68:             expr (NAME);                            /* try to interpret an mname */
   69:             if (merr ()) return merr ();
   70:             
   71:             stcpy (vn, varnam);
   72:             
   73:             if (vn[0] != '^') {
   74:                 symtab (killone, vn, NULL);
   75:             }
   76:             else {
   77:                 if (vn[1] == '$') {
   78:                     ssvn (killone, vn, NULL);
   79:                 }
   80:                 else {
   81:                     global (killone, vn, NULL);
   82:                 }
   83:             }
   84:             
   85:             if (merr ()) return merr ();
   86:             
   87:             if ((ch = *(codptr + 1)) == EOL) {
   88:                 codptr++;
   89:                 break;
   90:             }
   91:             else if (ch == ',') {
   92:                 codptr += 2;
   93:             }
   94:             else {
   95:                 return CMMND;
   96:             }
   97:         } 
   98:         
   99:     }
  100:     else { /* exclusive KVALUE */
  101:         
  102:         write_m ("Exclusive KVALUE not yet implemented.\201");
  103:         
  104:         while ((ch = *(codptr++)) != SP && ch != EOL) ; /* skip to the end of the command */
  105:         
  106:     }
  107: 
  108:     *ra = RA_NEXTCMND;
  109:     return OK;
  110: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>