summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2002-05-29 12:45:00 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2002-05-29 12:45:00 +0000
commitbbcb18ac1215ba5f3c59a8931c4984c374031232 (patch)
tree3756875e3ced5bfca4d87fb6a7765e7baa392c37 /usr.bin/mg
parent72654f620c12e7d0fb15f20c99ee85298a14250f (diff)
Add a few missing tests for BFREADONLY.
ok art@
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/region.c15
-rw-r--r--usr.bin/mg/word.c25
2 files changed, 38 insertions, 2 deletions
diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c
index 9b3142a20d2..af46a1205b5 100644
--- a/usr.bin/mg/region.c
+++ b/usr.bin/mg/region.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: region.c,v 1.9 2002/02/20 22:30:54 vincent Exp $ */
+/* $OpenBSD: region.c,v 1.10 2002/05/29 12:44:59 vincent Exp $ */
/*
* Region based commands.
@@ -93,6 +93,11 @@ lowerregion(f, n)
REGION region;
int loffs, c, s;
+ if (curbp->b_flag & BFREADONLY) {
+ ewprintf("Buffer is read-only");
+ return (FALSE);
+ }
+
if ((s = getregion(&region)) != TRUE)
return s;
@@ -130,6 +135,10 @@ upperregion(f, n)
REGION region;
int loffs, c, s;
+ if (curbp->b_flag & BFREADONLY) {
+ ewprintf("Buffer is read-only");
+ return (FALSE);
+ }
if ((s = getregion(&region)) != TRUE)
return s;
@@ -261,6 +270,10 @@ prefixregion(f, n)
int nline;
int s;
+ if (curbp->b_flag & BFREADONLY) {
+ ewprintf("Buffer is read-only");
+ return (FALSE);
+ }
if ((f == TRUE) && ((s = setprefix(FFRAND, 1)) != TRUE))
return s;
diff --git a/usr.bin/mg/word.c b/usr.bin/mg/word.c
index e1dfe2bb908..e92c667ade4 100644
--- a/usr.bin/mg/word.c
+++ b/usr.bin/mg/word.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: word.c,v 1.6 2002/02/21 15:27:29 deraadt Exp $ */
+/* $OpenBSD: word.c,v 1.7 2002/05/29 12:44:59 vincent Exp $ */
/*
* Word mode commands.
@@ -69,6 +69,11 @@ upperword(f, n)
{
int c;
+ if (curbp->b_flag & BFREADONLY) {
+ ewprintf("Buffer is read-only");
+ return (FALSE);
+ }
+
if (n < 0)
return FALSE;
while (n--) {
@@ -101,6 +106,10 @@ lowerword(f, n)
{
int c;
+ if (curbp->b_flag & BFREADONLY) {
+ ewprintf("Buffer is read-only");
+ return (FALSE);
+ }
if (n < 0)
return FALSE;
while (n--) {
@@ -135,6 +144,11 @@ capword(f, n)
{
int c;
+ if (curbp->b_flag & BFREADONLY) {
+ ewprintf("Buffer is read-only");
+ return (FALSE);
+ }
+
if (n < 0)
return FALSE;
while (n--) {
@@ -178,6 +192,10 @@ delfword(f, n)
LINE *dotp;
int doto;
+ if (curbp->b_flag & BFREADONLY) {
+ ewprintf("Buffer is read-only");
+ return (FALSE);
+ }
if (n < 0)
return FALSE;
@@ -226,6 +244,11 @@ delbword(f, n)
{
RSIZE size;
+ if (curbp->b_flag & BFREADONLY) {
+ ewprintf("Buffer is read-only");
+ return (FALSE);
+ }
+
if (n < 0)
return FALSE;