File:  [Coherent Logic Development] / freem / src / cmd_throw.c
Revision 1.4: download - view: text, annotated - select for diffs
Wed Apr 9 19:52:02 2025 UTC (3 months, 3 weeks ago) by snw
Branches: MAIN
CVS tags: HEAD
Eliminate as many warnings as possible while building with -Wall

    1: /*
    2:  *   $Id: cmd_throw.c,v 1.4 2025/04/09 19:52:02 snw Exp $
    3:  *    Implementation of the THROW command
    4:  *
    5:  *  
    6:  *   Author: Serena Willis <snw@coherent-logic.com>
    7:  *    Copyright (C) 1998 MUG Deutschland
    8:  *    Copyright (C) 2023 Coherent Logic Development LLC
    9:  *
   10:  *
   11:  *   This file is part of FreeM.
   12:  *
   13:  *   FreeM is free software: you can redistribute it and/or modify
   14:  *   it under the terms of the GNU Affero Public License as published by
   15:  *   the Free Software Foundation, either version 3 of the License, or
   16:  *   (at your option) any later version.
   17:  *
   18:  *   FreeM is distributed in the hope that it will be useful,
   19:  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   20:  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   21:  *   GNU Affero Public License for more details.
   22:  *
   23:  *   You should have received a copy of the GNU Affero Public License
   24:  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
   25:  *
   26:  *   $Log: cmd_throw.c,v $
   27:  *   Revision 1.4  2025/04/09 19:52:02  snw
   28:  *   Eliminate as many warnings as possible while building with -Wall
   29:  *
   30:  *   Revision 1.3  2025/03/09 19:14:24  snw
   31:  *   First phase of REUSE compliance and header reformat
   32:  *
   33:  *
   34:  * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
   35:  * SPDX-License-Identifier: AGPL-3.0-or-later 
   36:  **/
   37: 
   38: #include <string.h>
   39: #include <stdlib.h>
   40: #include "mpsdef.h"
   41: #include "mcommand.h"
   42: 
   43: MRESULT cmd_throw(MACTION *ra)
   44: {
   45:     char *throw_buf;
   46:     register char ch;
   47:     
   48:     if (rtn_dialect () != D_FREEM) {
   49:         return NOSTAND;
   50:     }
   51:     
   52:     throw_buf = (char *) malloc (STRLEN * sizeof (char));
   53:     NULLPTRCHK (throw_buf, "cmd_throw");
   54:     
   55:     expr (STRING);
   56:     if (merr ()) {
   57:         free (throw_buf);
   58:         return merr ();
   59:     }
   60:     
   61:     stcnv_m2c (argptr);
   62:     
   63:     snprintf (throw_buf, STRLEN - 1, ",%s,\201", argptr);
   64:     
   65:     merr_raise (merr_set_ecode (throw_buf));   
   66:     
   67:     free (throw_buf);
   68:     
   69:     if (merr ()) return merr ();
   70:     
   71:     while ((ch = *(codptr++)) != SP && ch != EOL) ; /* skip to the end of the command */
   72: 
   73:     *ra = RA_NEXTCMND;
   74:     return merr ();
   75: }

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