File:  [Coherent Logic Development] / freem / src / cmd_if.c
Revision 1.4: download - view: text, annotated - select for diffs
Sun May 18 18:15:38 2025 UTC (2 months, 2 weeks ago) by snw
Branches: MAIN
CVS tags: HEAD
Add ZEDIT command for editing routines

    1: /*
    2:  *
    3:  *   $Id: cmd_if.c,v 1.4 2025/05/18 18:15:38 snw Exp $
    4:  *    Implementation of the IF command
    5:  *
    6:  *  
    7:  *   Author: Serena Willis <snw@coherent-logic.com>
    8:  *    Copyright (C) 1998 MUG Deutschland
    9:  *    Copyright (C) 2023, 2025 Coherent Logic Development LLC
   10:  *
   11:  *
   12:  *   This file is part of FreeM.
   13:  *
   14:  *   FreeM is free software: you can redistribute it and/or modify
   15:  *   it under the terms of the GNU Affero Public License as published by
   16:  *   the Free Software Foundation, either version 3 of the License, or
   17:  *   (at your option) any later version.
   18:  *
   19:  *   FreeM is distributed in the hope that it will be useful,
   20:  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   22:  *   GNU Affero Public License for more details.
   23:  *
   24:  *   You should have received a copy of the GNU Affero Public License
   25:  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
   26:  *
   27:  *   $Log: cmd_if.c,v $
   28:  *   Revision 1.4  2025/05/18 18:15:38  snw
   29:  *   Add ZEDIT command for editing routines
   30:  *
   31:  *   Revision 1.3  2025/03/09 19:14:24  snw
   32:  *   First phase of REUSE compliance and header reformat
   33:  *
   34:  *
   35:  * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
   36:  * SPDX-License-Identifier: AGPL-3.0-or-later
   37:  **/
   38: 
   39: #include <string.h>
   40: #include <stdlib.h>
   41: #include <ctype.h>
   42: #include "mpsdef.h"
   43: #include "mcommand.h"
   44: 
   45: MRESULT cmd_if(MACTION *ra)
   46: {
   47:     if (*codptr == SP || *codptr == EOL) {           /* no argument form of IF */
   48:         if (test) {
   49:             *ra = RA_NEXTCMND;
   50:             return OK;
   51:         }
   52:         *ra = RA_SKIPLINE;
   53:         return OK;
   54:     }
   55:     
   56:     expr (STRING);
   57:     
   58:     if (*argptr == '1') {
   59:         test = TRUE;
   60:         *ra = RA_CONTINUE;
   61:         return OK;
   62:     }
   63:     
   64:     if (merr ()) return merr ();
   65:     
   66:     if (*argptr == '0' && argptr[1] == EOL) {
   67:         test = FALSE;
   68:         *ra = RA_SKIPLINE;
   69:         return OK;
   70:     }
   71:     
   72:     if ((test = tvexpr (argptr)) == FALSE) {
   73:         *ra = RA_SKIPLINE;
   74:         return OK;
   75:     }
   76: 
   77:     *ra = RA_CONTINUE;
   78:     return OK;    
   79: }

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