]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgfortran/intrinsics/system.c
re PR fortran/17776 (no subroutine system)
[thirdparty/gcc.git] / libgfortran / intrinsics / system.c
CommitLineData
5b1374e9
TS
1/* Implementation of the SYSTEM intrinsic.
2 Copyright (C) 2004 Free Software Foundation, Inc.
3 Contributed by Tobias Schlüter.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 2, or (at your option) any later
10version.
11
12In addition to the permissions in the GNU General Public License, the
13Free Software Foundation gives you unlimited permission to link the
14compiled version of this file into combinations with other programs,
15and to distribute those combinations without any restriction coming
16from the use of this file. (The General Public License restrictions
17do apply in other respects; for example, they cover modification of
18the file, and distribution when not linked into a combined
19executable.)
20
21GCC is distributed in the hope that it will be useful, but WITHOUT ANY
22WARRANTY; without even the implied warranty of MERCHANTABILITY or
23FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24for more details.
25
26You should have received a copy of the GNU General Public License
27along with GCC; see the file COPYING. If not, write to the Free
28Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2902111-1307, USA. */
30
31#include "config.h"
32#include "libgfortran.h"
33
34#ifdef HAVE_STRING_H
35#include <string.h>
36#endif
37#ifdef HAVE_STDLIB_H
38#include <stdlib.h>
39#endif
40
41void
42prefix(system_sub) (const char * fcmd, GFC_INTEGER_4 * status,
43 gfc_charlen_type cmd_len)
44{
45 char cmd[cmd_len + 1];
46 int stat;
47
48 memcpy (cmd, fcmd, cmd_len);
49 cmd[cmd_len] = '\0';
50
51 stat = system (cmd);
52 if (status)
53 *status = stat;
54}
55
56GFC_INTEGER_4
57prefix(system) (char * fcmd, gfc_charlen_type cmd_len)
58{
59 GFC_INTEGER_4 stat;
60
61 prefix(system_sub) (fcmd, &stat, cmd_len);
62 return stat;
63}