]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgfortran/runtime/pause.c
Update copyright years.
[thirdparty/gcc.git] / libgfortran / runtime / pause.c
CommitLineData
1028b2bd 1/* Implementation of the PAUSE statement.
7adcbafe 2 Copyright (C) 2002-2022 Free Software Foundation, Inc.
6de9cd9a
DN
3 Contributed by Paul Brook <paul@nowt.org>
4
1028b2bd 5This file is part of the GNU Fortran runtime library (libgfortran).
6de9cd9a 6
57dea9f6
TM
7Libgfortran is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public
6de9cd9a 9License as published by the Free Software Foundation; either
748086b7 10version 3 of the License, or (at your option) any later version.
57dea9f6
TM
11
12Libgfortran is distributed in the hope that it will be useful,
6de9cd9a
DN
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57dea9f6 15GNU General Public License for more details.
6de9cd9a 16
748086b7
JJ
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
6de9cd9a 25
36ae8a61 26#include "libgfortran.h"
6de9cd9a 27#include <string.h>
19f0e98f
DE
28
29#ifdef HAVE_UNISTD_H
1028b2bd 30#include <unistd.h>
19f0e98f
DE
31#endif
32
6de9cd9a 33
6de9cd9a
DN
34static void
35do_pause (void)
36{
37 char buff[4];
1028b2bd
JB
38 estr_write ("To resume execution, type go. "
39 "Other input will terminate the job.\n");
6de9cd9a
DN
40
41 fgets(buff, 4, stdin);
42 if (strncmp(buff, "go\n", 3) != 0)
dffb1e22 43 stop_string ('\0', 0, false);
1028b2bd 44 estr_write ("RESUMED\n");
6de9cd9a
DN
45}
46
6d1b0f92 47/* A numeric PAUSE statement. */
7d7b8bfe 48
6cc22cf4 49extern void pause_numeric (GFC_INTEGER_8);
7d7b8bfe
RH
50export_proto(pause_numeric);
51
6de9cd9a 52void
6cc22cf4 53pause_numeric (GFC_INTEGER_8 code)
6de9cd9a 54{
6cc22cf4 55 st_printf ("PAUSE %ld\n", (long) code);
6de9cd9a
DN
56 do_pause ();
57}
58
6d1b0f92
JD
59/* A character string or blank PAUSE statement. */
60
6cc22cf4 61extern void pause_string (char *string, size_t len);
7d7b8bfe 62export_proto(pause_string);
6de9cd9a
DN
63
64void
6cc22cf4 65pause_string (char *string, size_t len)
6de9cd9a 66{
edaaef60
JB
67 struct iovec iov[3];
68
69 iov[0].iov_base = (char*) "PAUSE ";
70 iov[0].iov_len = strlen (iov[0].iov_base);
71 iov[1].iov_base = string;
72 iov[1].iov_len = len;
73 iov[2].iov_base = (char*) "\n";
74 iov[2].iov_len = 1;
75 estr_writev (iov, 3);
6de9cd9a
DN
76
77 do_pause ();
78}