/* Implementation of the SYSTEM intrinsic.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007 Free Software Foundation, Inc.
Contributed by Tobias Schlüter.
-This file is part of GCC.
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
-GCC is free software; you can redistribute it and/or modify it under
+Libgfortran is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
the file, and distribution when not linked into a combined
executable.)
-GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
+Libgfortran 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 General Public License
for more details.
You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+along with libgfortran; see the file COPYING. If not, write to the Free
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA. */
-#include "config.h"
-
-#ifdef HAVE_STRING_H
+#include "libgfortran.h"
#include <string.h>
-#endif
+
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
-#include "libgfortran.h"
-
extern void system_sub (const char *fcmd, GFC_INTEGER_4 * status,
gfc_charlen_type cmd_len);
iexport_proto(system_sub);
char cmd[cmd_len + 1];
int stat;
+ /* Flush all I/O units before executing the command. */
+ flush_all_units();
+
memcpy (cmd, fcmd, cmd_len);
cmd[cmd_len] = '\0';