]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgfortran/runtime/pause.c
Merge tree-ssa-20020619-branch into mainline.
[thirdparty/gcc.git] / libgfortran / runtime / pause.c
1 /* Implementation of the STOP statement.
2 Copyright 2002 Free Software Foundation, Inc.
3 Contributed by Paul Brook <paul@nowt.org>
4
5 This file is part of the GNU Fortran 95 runtime library (libgfor).
6
7 Libgfor is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 Libgfor is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with libgfor; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #include "config.h"
23 #include <string.h>
24 #include <stdio.h>
25
26 #include "libgfortran.h"
27
28 #define pause_numeric prefix(pause_numeric)
29 #define pause_string prefix(pause_string)
30
31 static void
32 do_pause (void)
33 {
34 char buff[4];
35 st_printf ("To resume execution, type go. "
36 "Other input will terminate the job.\n");
37
38 fgets(buff, 4, stdin);
39 if (strncmp(buff, "go\n", 3) != 0)
40 stop_numeric (-1);
41 st_printf ("RESUMED\n");
42 }
43
44 /* A numeric or blank STOP statement. */
45 void
46 pause_numeric (GFC_INTEGER_4 code)
47 {
48 show_locus ();
49
50 if (code == -1)
51 st_printf ("PAUSE\n");
52 else
53 st_printf ("PAUSE %d\n", (int)code);
54
55 do_pause ();
56 }
57
58
59 void
60 pause_string (char *string, GFC_INTEGER_4 len)
61 {
62 show_locus ();
63
64 st_printf ("PAUSE ");
65 while (len--)
66 st_printf ("%c", *(string++));
67 st_printf ("\n");
68
69 do_pause ();
70 }
71