diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-26 06:40:12 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-26 06:40:12 +0000 |
commit | d7d6f05a8b3e0de03ce06e397e3bd59451e705a3 (patch) | |
tree | a5be483962b1c5f69f5a9a14048d7a49b8e30280 /usr.bin/what/what.c | |
parent | f78c2ff8497d138d7dcd5ffdd1762b8506ac023a (diff) |
handle $OpenBSD$ rcsid... using uname too!
Diffstat (limited to 'usr.bin/what/what.c')
-rw-r--r-- | usr.bin/what/what.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/usr.bin/what/what.c b/usr.bin/what/what.c index 98c8122d4c4..03d47176078 100644 --- a/usr.bin/what/what.c +++ b/usr.bin/what/what.c @@ -1,4 +1,4 @@ -/* $OpenBSD: what.c,v 1.2 1996/06/26 05:42:52 deraadt Exp $ */ +/* $OpenBSD: what.c,v 1.3 1996/06/26 06:40:11 deraadt Exp $ */ /* $NetBSD: what.c,v 1.4 1994/12/20 16:01:03 jtc Exp $ */ /* @@ -44,12 +44,15 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)what.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: what.c,v 1.2 1996/06/26 05:42:52 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: what.c,v 1.3 1996/06/26 06:40:11 deraadt Exp $"; #endif /* not lint */ +#include <sys/types.h> +#include <sys/utsname.h> #include <stdio.h> +#include <ctype.h> -void search __P((void)); +void search __P((char *)); /* * what @@ -60,26 +63,45 @@ main(argc, argv) int argc; char **argv; { + struct utsname utsn; + char match[256]; + + if (uname(&utsn) == -1) + err(1, "uname"); + strncpy(match, utsn.sysname, sizeof match); + if (!*++argv) - search(); + search(match); else do { if (!freopen(*argv, "r", stdin)) { perror(*argv); exit(1); } printf("%s\n", *argv); - search(); + search(match); } while(*++argv); exit(0); } void -search() +search(match) + char *match; { register int c; + int i; while ((c = getchar()) != EOF) { -loop: if (c != '@') +loop: if (c == '$') { + for (i = 0; match[i]; i++) + if ((c = getchar()) != match[i]) + goto loop; + printf("$%s", match); + while (isprint(c = getchar())) + putchar(c); + putchar('\n'); + goto loop; + } + if (c != '@') continue; if ((c = getchar()) != '(') goto loop; |