projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update from Rodney Ruddock
[unix-history]
/
usr
/
src
/
contrib
/
ed
/
w.c
diff --git
a/usr/src/contrib/ed/w.c
b/usr/src/contrib/ed/w.c
index
f65b86e
..
311f746
100644
(file)
--- a/
usr/src/contrib/ed/w.c
+++ b/
usr/src/contrib/ed/w.c
@@
-9,18
+9,21
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)w.c 5.
2
(Berkeley) %G%";
+static char sccsid[] = "@(#)w.c 5.
5
(Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
-#include <db.h>
#include <regex.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <regex.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef DBI
+#include <db.h>
+#endif
+
#include "ed.h"
#include "extern.h"
#include "ed.h"
#include "extern.h"
@@
-39,20
+42,20
@@
w(inputt, errnum)
{
FILE *fp;
int l_ttl = 0, l_q_flag = 0, l_sl;
{
FILE *fp;
int l_ttl = 0, l_q_flag = 0, l_sl;
- char *filename_read, *temp;
+ char *filename_read
=NULL
, *temp;
- if (
s
tart_default && End_default) {
-
s
tart = top;
+ if (
S
tart_default && End_default) {
+
S
tart = top;
End = bottom;
} else
End = bottom;
} else
- if (
s
tart_default)
-
s
tart = End;
- if (
s
tart == NULL) {
- strcpy(help_msg, "b
ad address
");
+ if (
S
tart_default)
+
S
tart = End;
+ if (
S
tart == NULL) {
+ strcpy(help_msg, "b
uffer empty
");
*errnum = -1;
return;
}
*errnum = -1;
return;
}
-
s
tart_default = End_default = 0;
+
S
tart_default = End_default = 0;
l_sl = ss;
ss = getc(inputt);
l_sl = ss;
ss = getc(inputt);
@@
-63,8
+66,6
@@
w(inputt, errnum)
ungetc(ss, inputt);
temp = filename(inputt, errnum);
ungetc(ss, inputt);
temp = filename(inputt, errnum);
- if (sigint_flag)
- SIGINT_ACTION;
if (*errnum == 1)
filename_read = temp;
else
if (*errnum == 1)
filename_read = temp;
else
@@
-85,6
+86,7
@@
w(inputt, errnum)
} else
filename_current = filename_read;
}
} else
filename_current = filename_read;
}
+ sigspecial++;
if (l_sl == 'W')
fp = fopen(filename_read, "a");
else
if (l_sl == 'W')
fp = fopen(filename_read, "a");
else
@@
-96,22
+98,21
@@
w(inputt, errnum)
ungetc('\n', inputt);
return;
}
ungetc('\n', inputt);
return;
}
- if (sigint_flag)
+ sigspecial--;
+ if (sigint_flag && (!sigspecial))
goto point;
/* Write it out and get a report on the number of bytes written. */
goto point;
/* Write it out and get a report on the number of bytes written. */
- l_ttl = edwrite(fp,
s
tart, End);
- if (explain_flag
!= 0)
/* For -s option. */
+ l_ttl = edwrite(fp,
S
tart, End);
+ if (explain_flag
> 0)
/* For -s option. */
printf("%d\n", l_ttl);
point: fclose(fp);
printf("%d\n", l_ttl);
point: fclose(fp);
- if (sigint_flag)
- SIGINT_ACTION;
if (filename_read != filename_current)
free(filename_read);
change_flag = 0L;
*errnum = 1;
if (filename_read != filename_current)
free(filename_read);
change_flag = 0L;
*errnum = 1;
- if (l_q_flag) { /* For "wq". */
+ if (l_q_flag) { /* For "wq"
and "Wq"
. */
ungetc('\n', inputt);
ss = (int) 'q';
q(inputt, errnum);
ungetc('\n', inputt);
ss = (int) 'q';
q(inputt, errnum);
@@
-131,7
+132,10
@@
edwrite(fp, begi, fini)
for (;;) {
get_line(begi->handle, begi->len);
for (;;) {
get_line(begi->handle, begi->len);
+ if (sigint_flag && (!sigspecial))
+ break;
+ sigspecial++;
/* Fwrite is about 20+% faster than fprintf -- no surprise. */
fwrite(text, sizeof(char), begi->len, fp);
fputc('\n', fp);
/* Fwrite is about 20+% faster than fprintf -- no surprise. */
fwrite(text, sizeof(char), begi->len, fp);
fputc('\n', fp);
@@
-140,8
+144,9
@@
edwrite(fp, begi, fini)
break;
else
begi = begi->below;
break;
else
begi = begi->below;
- if (sigint_flag)
- return (l_ttl);
+ sigspecial--;
+ if (sigint_flag && (!sigspecial))
+ break;
}
return (l_ttl);
}
}
return (l_ttl);
}