Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/locate/code the first args is expected to be the big...



details:   https://anonhg.NetBSD.org/src/rev/b3791d2739d1
branches:  trunk
changeset: 483910:b3791d2739d1
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Mar 20 19:18:34 2000 +0000

description:
the first args is expected to be the bigrams array, instead of name of
file holding it

diffstat:

 usr.bin/locate/code/locate.code.c |  17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diffs (55 lines):

diff -r e309ec59d7ab -r b3791d2739d1 usr.bin/locate/code/locate.code.c
--- a/usr.bin/locate/code/locate.code.c Mon Mar 20 19:17:35 2000 +0000
+++ b/usr.bin/locate/code/locate.code.c Mon Mar 20 19:18:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locate.code.c,v 1.6 1997/10/19 04:11:54 lukem Exp $    */
+/*     $NetBSD: locate.code.c,v 1.7 2000/03/20 19:18:34 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)locate.code.c      8.4 (Berkeley) 5/4/95";
 #endif
-__RCSID("$NetBSD: locate.code.c,v 1.6 1997/10/19 04:11:54 lukem Exp $");
+__RCSID("$NetBSD: locate.code.c,v 1.7 2000/03/20 19:18:34 jdolecek Exp $");
 #endif /* not lint */
 
 /*
@@ -99,7 +99,7 @@
 
 char buf1[MAXPATHLEN] = " ";   
 char buf2[MAXPATHLEN];
-char bigrams[BGBUFSIZE + 1] = { 0 };
+char *bigrams;
 
 int    bgindex __P((char *));
 int    main __P((int, char **));
@@ -112,7 +112,6 @@
 {
        char *cp, *oldpath, *path;
        int ch, code, count, diffcount, oldcount;
-       FILE *fp;
 
        while ((ch = getopt(argc, argv, "")) != -1)
                switch(ch) {
@@ -126,14 +125,14 @@
        if (argc != 1)
                usage();
 
-       if ((fp = fopen(argv[0], "r")) == NULL)
-               err(1, "%s", argv[0]);
+       bigrams = argv[0];
 
        /* First copy bigram array to stdout. */
-       (void)fgets(bigrams, BGBUFSIZE + 1, fp);
-       if (fwrite(bigrams, 1, BGBUFSIZE, stdout) != BGBUFSIZE)
+       count = strlen(bigrams);
+       if (fwrite(bigrams, 1, count, stdout) != count)
                err(1, "stdout");
-       (void)fclose(fp);
+       for(count = BGBUFSIZE - count; count > 0; count--)
+               fputc('\0', stdout);
 
        oldpath = buf1;
        path = buf2;



Home | Main Index | Thread Index | Old Index