/*
*
* $Log: cmd_if.c,v $
* Revision 1.3 2025/03/09 19:14:24 snw
* First phase of REUSE compliance and header reformat
*
* Implementation of the IF command
*
*
* Author: Serena Willis <snw@coherent-logic.com>
* Copyright (C) 1998 MUG Deutschland
* Copyright (C) 2023, 2025 Coherent Logic Development LLC
*
*
* This file is part of FreeM.
*
* FreeM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero Public License for more details.
*
* You should have received a copy of the GNU Affero Public License
* along with FreeM. If not, see <https://www.gnu.org/licenses/>.
*
* $Log: cmd_if.c,v $
* Revision 1.3 2025/03/09 19:14:24 snw
* First phase of REUSE compliance and header reformat
*
*
* SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
* SPDX-License-Identifier: AGPL-3.0-or-later
**/
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "mpsdef.h"
#include "mcommand.h"
MRESULT cmd_if(MACTION *ra)
{
if (*codptr == SP || *codptr == EOL) { /* no argument form of IF */
if (test) {
*ra = RA_NEXTCMND;
return OK;
}
*ra = RA_SKIPLINE;
return OK;
}
expr (STRING);
if (*argptr == '1') {
test = TRUE;
*ra = RA_CONTINUE;
return OK;
}
if (merr ()) return merr ();
if (*argptr == '0' && argptr[1] == EOL) {
test = FALSE;
*ra = RA_SKIPLINE;
return OK;
}
if ((test = tvexpr (argptr)) == FALSE) {
*ra = RA_SKIPLINE;
return OK;
}
*ra = RA_CONTINUE;
return OK;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>