summaryrefslogtreecommitdiff
path: root/usr.bin/mg/region.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mg/region.c')
-rw-r--r--usr.bin/mg/region.c139
1 files changed, 72 insertions, 67 deletions
diff --git a/usr.bin/mg/region.c b/usr.bin/mg/region.c
index 8112296f81a..0c3395150c0 100644
--- a/usr.bin/mg/region.c
+++ b/usr.bin/mg/region.c
@@ -13,17 +13,17 @@
* to figure out the bounds of the region.
* Move "." to the start, and kill the characters.
*/
-/*ARGSUSED*/
+/* ARGSUSED */
killregion(f, n)
{
- register int s;
- REGION region;
+ register int s;
+ REGION region;
- if ((s=getregion(&region)) != TRUE)
+ if ((s = getregion(&region)) != TRUE)
return (s);
- if ((lastflag&CFKILL) == 0) /* This is a kill type */
- kdelete(); /* command, so do magic */
- thisflag |= CFKILL; /* kill buffer stuff. */
+ if ((lastflag & CFKILL) == 0) /* This is a kill type */
+ kdelete(); /* command, so do magic */
+ thisflag |= CFKILL; /* kill buffer stuff. */
curwp->w_dotp = region.r_linep;
curwp->w_doto = region.r_offset;
return (ldelete(region.r_size, KFORW));
@@ -35,30 +35,30 @@ killregion(f, n)
* at all. This is a bit like a kill region followed
* by a yank.
*/
-/*ARGSUSED*/
+/* ARGSUSED */
copyregion(f, n)
{
- register LINE *linep;
- register int loffs;
- register int s;
- REGION region;
- VOID kdelete();
+ register LINE *linep;
+ register int loffs;
+ register int s;
+ REGION region;
+ VOID kdelete();
- if ((s=getregion(&region)) != TRUE)
+ if ((s = getregion(&region)) != TRUE)
return s;
- if ((lastflag&CFKILL) == 0) /* Kill type command. */
+ if ((lastflag & CFKILL) == 0) /* Kill type command. */
kdelete();
thisflag |= CFKILL;
- linep = region.r_linep; /* Current line. */
- loffs = region.r_offset; /* Current offset. */
+ linep = region.r_linep; /* Current line. */
+ loffs = region.r_offset;/* Current offset. */
while (region.r_size--) {
- if (loffs == llength(linep)) { /* End of line. */
- if ((s=kinsert('\n', KFORW)) != TRUE)
+ if (loffs == llength(linep)) { /* End of line. */
+ if ((s = kinsert('\n', KFORW)) != TRUE)
return (s);
linep = lforw(linep);
loffs = 0;
- } else { /* Middle of line. */
- if ((s=kinsert(lgetc(linep, loffs), KFORW)) != TRUE)
+ } else { /* Middle of line. */
+ if ((s = kinsert(lgetc(linep, loffs), KFORW)) != TRUE)
return s;
++loffs;
}
@@ -73,16 +73,16 @@ copyregion(f, n)
* doing the changes. Call "lchange" to ensure that
* redisplay is done in all buffers.
*/
-/*ARGSUSED*/
+/* ARGSUSED */
lowerregion(f, n)
{
- register LINE *linep;
- register int loffs;
- register int c;
- register int s;
- REGION region;
+ register LINE *linep;
+ register int loffs;
+ register int c;
+ register int s;
+ REGION region;
- if ((s=getregion(&region)) != TRUE)
+ if ((s = getregion(&region)) != TRUE)
return s;
lchange(WFHARD);
linep = region.r_linep;
@@ -108,17 +108,17 @@ lowerregion(f, n)
* doing the changes. Call "lchange" to ensure that
* redisplay is done in all buffers.
*/
-/*ARGSUSED*/
+/* ARGSUSED */
upperregion(f, n)
{
- register LINE *linep;
- register int loffs;
- register int c;
- register int s;
- REGION region;
- VOID lchange();
+ register LINE *linep;
+ register int loffs;
+ register int c;
+ register int s;
+ REGION region;
+ VOID lchange();
- if ((s=getregion(&region)) != TRUE)
+ if ((s = getregion(&region)) != TRUE)
return s;
lchange(WFHARD);
linep = region.r_linep;
@@ -150,60 +150,65 @@ upperregion(f, n)
* get an ABORT status, because I might add a "if regions is big,
* ask before clobberring" flag.
*/
-getregion(rp) register REGION *rp; {
- register LINE *flp;
- register LINE *blp;
- register long fsize; /* Long now. */
- register long bsize;
+getregion(rp)
+ register REGION *rp;
+{
+ register LINE *flp;
+ register LINE *blp;
+ register long fsize; /* Long now. */
+ register long bsize;
if (curwp->w_markp == NULL) {
ewprintf("No mark set in this window");
return (FALSE);
}
- if (curwp->w_dotp == curwp->w_markp) { /* "r_size" always ok. */
+ if (curwp->w_dotp == curwp->w_markp) { /* "r_size" always ok. */
rp->r_linep = curwp->w_dotp;
if (curwp->w_doto < curwp->w_marko) {
rp->r_offset = curwp->w_doto;
- rp->r_size = (RSIZE) (curwp->w_marko-curwp->w_doto);
+ rp->r_size = (RSIZE) (curwp->w_marko - curwp->w_doto);
} else {
rp->r_offset = curwp->w_marko;
- rp->r_size = (RSIZE) (curwp->w_doto-curwp->w_marko);
+ rp->r_size = (RSIZE) (curwp->w_doto - curwp->w_marko);
}
return TRUE;
}
- flp = blp = curwp->w_dotp; /* Get region size. */
+ flp = blp = curwp->w_dotp; /* Get region size. */
bsize = curwp->w_doto;
- fsize = llength(flp)-curwp->w_doto+1;
- while (lforw(flp)!=curbp->b_linep || lback(blp)!=curbp->b_linep) {
+ fsize = llength(flp) - curwp->w_doto + 1;
+ while (lforw(flp) != curbp->b_linep || lback(blp) != curbp->b_linep) {
if (lforw(flp) != curbp->b_linep) {
flp = lforw(flp);
if (flp == curwp->w_markp) {
rp->r_linep = curwp->w_dotp;
rp->r_offset = curwp->w_doto;
return (setsize(rp,
- (RSIZE) (fsize+curwp->w_marko)));
+ (RSIZE) (fsize + curwp->w_marko)));
}
- fsize += llength(flp)+1;
+ fsize += llength(flp) + 1;
}
if (lback(blp) != curbp->b_linep) {
blp = lback(blp);
- bsize += llength(blp)+1;
+ bsize += llength(blp) + 1;
if (blp == curwp->w_markp) {
rp->r_linep = blp;
rp->r_offset = curwp->w_marko;
return (setsize(rp,
- (RSIZE) (bsize-curwp->w_marko)));
+ (RSIZE) (bsize - curwp->w_marko)));
}
}
}
- ewprintf("Bug: lost mark"); /* Gak! */
+ ewprintf("Bug: lost mark"); /* Gak! */
return FALSE;
}
/*
* Set size, and check for overflow.
*/
-setsize(rp, size) register REGION *rp; register RSIZE size; {
+setsize(rp, size)
+ register REGION *rp;
+ register RSIZE size;
+{
rp->r_size = size;
if (rp->r_size != size) {
@@ -223,7 +228,7 @@ setsize(rp, size) register REGION *rp; register RSIZE size; {
*/
#define PREFIXLENGTH 40
-static char prefix_string[PREFIXLENGTH] = { '>', '\0' };
+static char prefix_string[PREFIXLENGTH] = {'>', '\0'};
/*
* Prefix the region with whatever is in prefix_string.
@@ -232,14 +237,14 @@ static char prefix_string[PREFIXLENGTH] = { '>', '\0' };
* line prefix string.
*/
-/*ARGSUSED*/
+/* ARGSUSED */
prefixregion(f, n)
{
- register int s;
- register LINE *first, *last;
- register int nline;
- REGION region;
- char *prefix = prefix_string;
+ register int s;
+ register LINE *first, *last;
+ register int nline;
+ REGION region;
+ char *prefix = prefix_string;
if ((f == TRUE) && ((s = setprefix(FFRAND, 1)) != TRUE))
return s;
@@ -252,7 +257,7 @@ prefixregion(f, n)
for (nline = 1; first != last; nline++)
first = lforw(first);
- /*move to beginning of region */
+ /* move to beginning of region */
curwp->w_dotp = region.r_linep;
curwp->w_doto = region.r_offset;
@@ -271,20 +276,20 @@ prefixregion(f, n)
* Set prefix string.
*/
-/*ARGSUSED*/
+/* ARGSUSED */
setprefix(f, n)
{
- char buf[PREFIXLENGTH];
- register int s;
+ char buf[PREFIXLENGTH];
+ register int s;
if (prefix_string[0] == '\0')
- s = ereply("Prefix string: ",buf,sizeof buf);
+ s = ereply("Prefix string: ", buf, sizeof buf);
else
s = ereply("Prefix string (default %s): ",
- buf,sizeof buf,prefix_string);
+ buf, sizeof buf, prefix_string);
if (s == TRUE)
(VOID) strcpy(prefix_string, buf);
- if ((s == FALSE) && (prefix_string[0] != '\0')) /* CR -- use old one */
+ if ((s == FALSE) && (prefix_string[0] != '\0')) /* CR -- use old one */
s = TRUE;
return s;
}