Annotation of freem/src/cmd_if.c, revision 1.4

1.1       snw         1: /*
                      2:  *
1.4     ! snw         3:  *   $Id$
1.1       snw         4:  *    Implementation of the IF command
                      5:  *
                      6:  *  
1.2       snw         7:  *   Author: Serena Willis <snw@coherent-logic.com>
1.1       snw         8:  *    Copyright (C) 1998 MUG Deutschland
1.3       snw         9:  *    Copyright (C) 2023, 2025 Coherent Logic Development LLC
1.1       snw        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:  *
1.4     ! snw        27:  *   $Log: cmd_if.c,v $
        !            28:  *   Revision 1.3  2025/03/09 19:14:24  snw
        !            29:  *   First phase of REUSE compliance and header reformat
        !            30:  *
1.3       snw        31:  *
                     32:  * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
                     33:  * SPDX-License-Identifier: AGPL-3.0-or-later
1.1       snw        34:  **/
                     35: 
                     36: #include <string.h>
                     37: #include <stdlib.h>
                     38: #include <ctype.h>
                     39: #include "mpsdef.h"
                     40: #include "mcommand.h"
                     41: 
                     42: MRESULT cmd_if(MACTION *ra)
                     43: {
                     44:     if (*codptr == SP || *codptr == EOL) {           /* no argument form of IF */
                     45:         if (test) {
                     46:             *ra = RA_NEXTCMND;
                     47:             return OK;
                     48:         }
                     49:         *ra = RA_SKIPLINE;
                     50:         return OK;
                     51:     }
                     52:     
                     53:     expr (STRING);
                     54:     
                     55:     if (*argptr == '1') {
                     56:         test = TRUE;
                     57:         *ra = RA_CONTINUE;
                     58:         return OK;
                     59:     }
                     60:     
                     61:     if (merr ()) return merr ();
                     62:     
                     63:     if (*argptr == '0' && argptr[1] == EOL) {
                     64:         test = FALSE;
                     65:         *ra = RA_SKIPLINE;
                     66:         return OK;
                     67:     }
                     68:     
                     69:     if ((test = tvexpr (argptr)) == FALSE) {
                     70:         *ra = RA_SKIPLINE;
                     71:         return OK;
                     72:     }
                     73: 
                     74:     *ra = RA_CONTINUE;
                     75:     return OK;    
                     76: }

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