summaryrefslogtreecommitdiff
path: root/usr.bin/mg/re_search.c
diff options
context:
space:
mode:
authorDavid Berghoff <db@cvs.openbsd.org>2005-04-03 02:09:29 +0000
committerDavid Berghoff <db@cvs.openbsd.org>2005-04-03 02:09:29 +0000
commitb6dc95251a8aa6c607dcb85f78ca2049dab538f7 (patch)
treeaaa772418d7ccfd0a020a53d1c6d7e85f7f7a47a /usr.bin/mg/re_search.c
parentbadc0ff2f722af5ded41bf6344b8e76a32e9017d (diff)
This is a no binary change which does:
- spelling, punctuation fixes - variable declaration lineup - use parentheses for return and sizeof - K&R function declarations -> ANSI - other minor code beautification ok henning@
Diffstat (limited to 'usr.bin/mg/re_search.c')
-rw-r--r--usr.bin/mg/re_search.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/usr.bin/mg/re_search.c b/usr.bin/mg/re_search.c
index 221e01afa73..b89f4500816 100644
--- a/usr.bin/mg/re_search.c
+++ b/usr.bin/mg/re_search.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: re_search.c,v 1.13 2004/07/22 01:25:25 vincent Exp $ */
+/* $OpenBSD: re_search.c,v 1.14 2005/04/03 02:09:28 db Exp $ */
/*
* regular expression search commands for Mg
@@ -63,7 +63,7 @@ re_forwsearch(int f, int n)
/*
* Reverse search.
- * Get a search string from the user, and search, starting at "."
+ * Get a search string from the user, and search, starting at "."
* and proceeding toward the front of the buffer. If found "." is left
* pointing at the first character of the pattern [the last character that
* was matched].
@@ -128,7 +128,7 @@ static regmatch_t re_match[RE_NMATCH];
int
re_queryrepl(int f, int n)
{
- int rcnt = 0; /* replacements made so far */
+ int rcnt = 0; /* replacements made so far */
int plen, s; /* length of found string */
char news[NPAT], *rep; /* replacement string */
@@ -200,7 +200,7 @@ stopsearch:
else
ewprintf("(%d replacements done)", rcnt);
}
- return TRUE;
+ return (TRUE);
}
/*
@@ -292,8 +292,6 @@ re_doreplace(RSIZE plen, char *st, int f)
return (s);
}
-
-
/*
* This routine does the real work of a forward search. The pattern is
* sitting in the external variable "pat". If found, dot is updated, the
@@ -340,7 +338,6 @@ re_forwsrch(void)
return (FALSE);
}
-
/*
* This routine does the real work of a backward search. The pattern is sitting
* in the external variable "re_pat". If found, dot is updated, the window
@@ -399,7 +396,6 @@ re_backsrch(void)
return (FALSE);
}
-
/*
* Read a pattern.
* Stash it in the external variable "re_pat". The "pat" is
@@ -422,7 +418,7 @@ re_readpattern(char *prompt)
if (rep != NULL && *rep != '\0') {
/* New pattern given */
- (void)strlcpy(re_pat, tpat, sizeof re_pat);
+ (void)strlcpy(re_pat, tpat, sizeof(re_pat));
if (casefoldsearch)
flags = REG_EXTENDED | REG_ICASE;
else
@@ -470,9 +466,8 @@ setcasefold(int f, int n)
return (TRUE);
}
-
/*
- * Delete all lines after dot that contain a string matching regex
+ * Delete all lines after dot that contain a string matching regex.
*/
int
delmatchlines(int f, int n)
@@ -488,7 +483,7 @@ delmatchlines(int f, int n)
}
/*
- * Delete all lines after dot that don't contain a string matching regex
+ * Delete all lines after dot that don't contain a string matching regex.
*/
int
delnonmatchlines(int f, int n)
@@ -504,7 +499,7 @@ delnonmatchlines(int f, int n)
}
/*
- * This function does the work of deleting matching lines
+ * This function does the work of deleting matching lines.
*/
static int
killmatches(int cond)
@@ -547,7 +542,7 @@ killmatches(int cond)
}
/*
- * Count lines matching regex
+ * Count lines matching regex.
*/
int
cntmatchlines(int f, int n)
@@ -557,11 +552,12 @@ cntmatchlines(int f, int n)
if ((s = re_readpattern("Count lines (matching regexp)")) != TRUE)
return (s);
s = countmatches(TRUE);
+
return (s);
}
/*
- * Count lines that fail to match regex
+ * Count lines that fail to match regex.
*/
int
cntnonmatchlines(int f, int n)
@@ -570,7 +566,6 @@ cntnonmatchlines(int f, int n)
if ((s = re_readpattern("Count lines (not matching regexp)")) != TRUE)
return (s);
-
s = countmatches(FALSE);
return (s);