Merge from vendor branch GCC:
[dragonfly.git] / contrib / libf2c / libF77 / s_paus.c
1 #include <stdio.h>
2 #include "f2c.h"
3 #define PAUSESIG 15
4
5 #include "signal1.h"
6 #ifdef KR_headers
7 #define Void /* void */
8 #define Int /* int */
9 #else
10 #define Void void
11 #define Int int
12 #undef abs
13 #undef min
14 #undef max
15 #include <stdlib.h>
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 extern int getpid(void), isatty(int), pause(void);
20 #endif
21
22 extern VOID f_exit(Void);
23
24  static VOID
25 waitpause(Sigarg)
26 {       Use_Sigarg;
27         return;
28         }
29
30  static VOID
31 #ifdef KR_headers
32 s_1paus(fin) FILE *fin;
33 #else
34 s_1paus(FILE *fin)
35 #endif
36 {
37         fprintf(stderr,
38         "To resume execution, type go.  Other input will terminate the job.\n");
39         fflush(stderr);
40         if( getc(fin)!='g' || getc(fin)!='o' || getc(fin)!='\n' ) {
41                 fprintf(stderr, "STOP\n");
42 #ifdef NO_ONEXIT
43                 f_exit();
44 #endif
45                 exit(0);
46                 }
47         }
48
49  int
50 #ifdef KR_headers
51 s_paus(s, n) char *s; ftnlen n;
52 #else
53 s_paus(char *s, ftnlen n)
54 #endif
55 {
56         fprintf(stderr, "PAUSE ");
57         if(n > 0)
58                 fprintf(stderr, " %.*s", (int)n, s);
59         fprintf(stderr, " statement executed\n");
60         if( isatty(fileno(stdin)) )
61                 s_1paus(stdin);
62         else {
63 #if (defined (MSDOS) && !defined (GO32)) || defined (_WIN32)
64                 FILE *fin;
65                 fin = fopen("con", "r");
66                 if (!fin) {
67                         fprintf(stderr, "s_paus: can't open con!\n");
68                         fflush(stderr);
69                         exit(1);
70                         }
71                 s_1paus(fin);
72                 fclose(fin);
73 #else
74                 fprintf(stderr,
75                 "To resume execution, execute a   kill -%d %d   command\n",
76                         PAUSESIG, getpid() );
77                 signal1(PAUSESIG, waitpause);
78                 fflush(stderr);
79                 pause();
80 #endif
81                 }
82         fprintf(stderr, "Execution resumes after PAUSE.\n");
83         fflush(stderr);
84         return 0; /* NOT REACHED */
85 #ifdef __cplusplus
86         }
87 #endif
88 }