Annotation of freem/src/cmd_throw.c, revision 1.4
1.1 snw 1: /*
1.4 ! snw 2: * $Id: cmd_throw.c,v 1.3 2025/03/09 19:14:24 snw Exp $
1.1 snw 3: * Implementation of the THROW command
4: *
5: *
1.2 snw 6: * Author: Serena Willis <snw@coherent-logic.com>
1.1 snw 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: *
1.4 ! snw 26: * $Log: cmd_throw.c,v $
! 27: * Revision 1.3 2025/03/09 19:14:24 snw
! 28: * First phase of REUSE compliance and header reformat
! 29: *
1.3 snw 30: *
31: * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
32: * SPDX-License-Identifier: AGPL-3.0-or-later
1.1 snw 33: **/
34:
35: #include <string.h>
36: #include <stdlib.h>
37: #include "mpsdef.h"
38: #include "mcommand.h"
39:
40: MRESULT cmd_throw(MACTION *ra)
41: {
42: char *throw_buf;
43: register char ch;
44:
45: if (rtn_dialect () != D_FREEM) {
46: return NOSTAND;
47: }
48:
49: throw_buf = (char *) malloc (STRLEN * sizeof (char));
50: NULLPTRCHK (throw_buf, "cmd_throw");
51:
52: expr (STRING);
1.4 ! snw 53: if (merr ()) {
! 54: free (throw_buf);
! 55: return merr ();
! 56: }
1.1 snw 57:
58: stcnv_m2c (argptr);
59:
60: snprintf (throw_buf, STRLEN - 1, ",%s,\201", argptr);
61:
62: merr_raise (merr_set_ecode (throw_buf));
63:
64: free (throw_buf);
65:
66: if (merr ()) return merr ();
67:
68: while ((ch = *(codptr++)) != SP && ch != EOL) ; /* skip to the end of the command */
69:
70: *ra = RA_NEXTCMND;
71: return merr ();
72: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>