projects
/
mmh
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7e5bac1
)
Convert to the use of siglongjmp()
author
Ken Hornstein
<kenh@pobox.com>
Fri, 27 Jan 2012 18:34:17 +0000
(13:34 -0500)
committer
Ken Hornstein
<kenh@pobox.com>
Fri, 27 Jan 2012 18:34:17 +0000
(13:34 -0500)
sbr/getans.c
patch
|
blob
|
history
diff --git
a/sbr/getans.c
b/sbr/getans.c
index
95e34c4
..
682a3b1
100644
(file)
--- a/
sbr/getans.c
+++ b/
sbr/getans.c
@@
-13,7
+13,7
@@
#include <signal.h>
static char ansbuf[BUFSIZ];
#include <signal.h>
static char ansbuf[BUFSIZ];
-static jmp_buf sigenv;
+static sigjmp_buf sigenv;
/*
* static prototypes
/*
* static prototypes
@@
-28,10
+28,11
@@
getans (char *prompt, struct swit *ansp)
SIGNAL_HANDLER istat = NULL;
char *cp, **cpp;
SIGNAL_HANDLER istat = NULL;
char *cp, **cpp;
- if (!(m_setjmp (sigenv))) {
+ if (!(sigsetjmp(sigenv, 1))) {
istat = SIGNAL (SIGINT, intrser);
} else {
SIGNAL (SIGINT, istat);
istat = SIGNAL (SIGINT, intrser);
} else {
SIGNAL (SIGINT, istat);
+ printf("returning NULL\n");
return NULL;
}
return NULL;
}
@@
-40,8
+41,10
@@
getans (char *prompt, struct swit *ansp)
fflush (stdout);
cp = ansbuf;
while ((i = getchar ()) != '\n') {
fflush (stdout);
cp = ansbuf;
while ((i = getchar ()) != '\n') {
- if (i == EOF)
- longjmp (sigenv, 1);
+ if (i == EOF) {
+ printf("Got EOF\n");
+ siglongjmp (sigenv, 1);
+ }
if (cp < &ansbuf[sizeof ansbuf - 1])
*cp++ = i;
}
if (cp < &ansbuf[sizeof ansbuf - 1])
*cp++ = i;
}
@@
-75,5
+78,5
@@
intrser (int i)
/*
* should this be siglongjmp?
*/
/*
* should this be siglongjmp?
*/
- longjmp (sigenv, 1);
+ siglongjmp (sigenv, 1);
}
}