summaryrefslogtreecommitdiffstats
path: root/usr.bin/grep/grep.c
diff options
context:
space:
mode:
authorgabor <gabor@FreeBSD.org>2011-10-11 22:27:23 +0000
committergabor <gabor@FreeBSD.org>2011-10-11 22:27:23 +0000
commitafe335edb5ec5cb5b15074c5f300c5055f76f73b (patch)
tree6864876fce7349bb828446411f1b587ad7e18e64 /usr.bin/grep/grep.c
parent2a4bf1ea8bf0f83e7562db32f157e58bef2cf214 (diff)
downloadFreeBSD-src-afe335edb5ec5cb5b15074c5f300c5055f76f73b.zip
FreeBSD-src-afe335edb5ec5cb5b15074c5f300c5055f76f73b.tar.gz
- Use getprogname() instead of __progname
- Allow disabling bzip2 support with WITHOUT_BZIP2 - Fix handling patterns that start with a dot - Remove superfluous semicolon Approved by: delphij (mentor)
Diffstat (limited to 'usr.bin/grep/grep.c')
-rw-r--r--usr.bin/grep/grep.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c
index e0f1d71..288df90 100644
--- a/usr.bin/grep/grep.c
+++ b/usr.bin/grep/grep.c
@@ -150,15 +150,13 @@ bool prev; /* flag whether or not the previous line matched */
int tail; /* lines left to print */
bool notfound; /* file not found */
-extern char *__progname;
-
/*
* Prints usage information and returns 2.
*/
static void
usage(void)
{
- fprintf(stderr, getstr(4), __progname);
+ fprintf(stderr, getstr(4), getprogname());
fprintf(stderr, "%s", getstr(5));
fprintf(stderr, "%s", getstr(5));
fprintf(stderr, "%s", getstr(6));
@@ -332,7 +330,8 @@ int
main(int argc, char *argv[])
{
char **aargv, **eargv, *eopts;
- char *pn, *ep;
+ char *ep;
+ const char *pn;
unsigned long long l;
unsigned int aargc, eargc, i;
int c, lastc, needpattern, newarg, prevoptind;
@@ -346,7 +345,7 @@ main(int argc, char *argv[])
/* Check what is the program name of the binary. In this
way we can have all the funcionalities in one binary
without the need of scripting and using ugly hacks. */
- pn = __progname;
+ pn = getprogname();
if (pn[0] == 'b' && pn[1] == 'z') {
filebehave = FILE_BZIP;
pn += 2;
@@ -508,6 +507,10 @@ main(int argc, char *argv[])
cflags |= REG_ICASE;
break;
case 'J':
+#ifdef WITHOUT_BZIP2
+ errno = EOPNOTSUPP;
+ err(2, "bzip2 support was disabled at compile-time");
+#endif
filebehave = FILE_BZIP;
break;
case 'L':
@@ -568,7 +571,7 @@ main(int argc, char *argv[])
filebehave = FILE_MMAP;
break;
case 'V':
- printf(getstr(9), __progname, VERSION);
+ printf(getstr(9), getprogname(), VERSION);
exit(0);
case 'v':
vflag = true;
OpenPOWER on IntegriCloud