summaryrefslogtreecommitdiff
path: root/usr.bin/mg/grep.c
diff options
context:
space:
mode:
authorKjell Wooding <kjell@cvs.openbsd.org>2006-07-25 08:27:10 +0000
committerKjell Wooding <kjell@cvs.openbsd.org>2006-07-25 08:27:10 +0000
commit6fa69567b7af822d74014fa4cbf3f5d3d8f34ffc (patch)
tree5ce76eb7ce91f51b9dd1960fbe251c0aa0c1e1b7 /usr.bin/mg/grep.c
parentb27fa2f6a9aae6a0a87897200334b193aa2882dd (diff)
Add bfirstlp(), blastlp() macros, returning the first and last lines
of a buffer respectively. Removes an ugly construction than necessitated "go to first line"-type comments throughout the code. No binary change
Diffstat (limited to 'usr.bin/mg/grep.c')
-rw-r--r--usr.bin/mg/grep.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/mg/grep.c b/usr.bin/mg/grep.c
index 8fe20157b9a..b2258760324 100644
--- a/usr.bin/mg/grep.c
+++ b/usr.bin/mg/grep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grep.c,v 1.31 2006/07/25 08:22:32 kjell Exp $ */
+/* $OpenBSD: grep.c,v 1.32 2006/07/25 08:27:09 kjell Exp $ */
/*
* Copyright (c) 2001 Artur Grabowski <art@openbsd.org>.
* Copyright (c) 2005 Kjell Wooding <kjell@openbsd.org>.
@@ -269,7 +269,7 @@ compile_mode(const char *name, const char *command)
else
addlinef(bp, "Command finished at %s", timestr);
- bp->b_dotp = lforw(bp->b_headp); /* go to first line */
+ bp->b_dotp = bfirstlp(bp);
bp->b_modes[0] = name_mode("fundamental");
bp->b_modes[1] = name_mode("compile");
bp->b_nmodes = 1;
@@ -297,7 +297,7 @@ compile_goto_error(int f, int n)
compile_win = curwp;
compile_buffer = curbp;
- last = lback(compile_buffer->b_headp);
+ last = blastlp(compile_buffer);
retry:
/* last line is compilation result */
@@ -340,7 +340,7 @@ compile_goto_error(int f, int n)
return (TRUE);
fail:
free(line);
- if (curwp->w_dotp != lback(curbp->b_headp)) {
+ if (curwp->w_dotp != blastlp(curbp)) {
curwp->w_dotp = lforw(curwp->w_dotp);
curwp->w_flag |= WFMOVE;
goto retry;
@@ -359,7 +359,7 @@ next_error(int f, int n)
}
curwp = compile_win;
curbp = compile_buffer;
- if (curwp->w_dotp == lback(curbp->b_headp)) {
+ if (curwp->w_dotp == blastlp(curbp)) {
ewprintf("No more hits");
return (FALSE);
}