Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/locate/bigram Do not count the end of a line in the ...



details:   https://anonhg.NetBSD.org/src/rev/651aa742948c
branches:  trunk
changeset: 485813:651aa742948c
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Sat May 06 10:26:45 2000 +0000

description:
Do not count the end of a line in the bigram table.  Newlines are stripped
before coding anyway, and the bigram output was screwing up (and often
pessimising) the table.

diffstat:

 usr.bin/locate/bigram/locate.bigram.c |  17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diffs (38 lines):

diff -r 46dcc746226a -r 651aa742948c usr.bin/locate/bigram/locate.bigram.c
--- a/usr.bin/locate/bigram/locate.bigram.c     Sat May 06 10:02:06 2000 +0000
+++ b/usr.bin/locate/bigram/locate.bigram.c     Sat May 06 10:26:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locate.bigram.c,v 1.8 2000/03/22 21:45:02 simonb Exp $ */
+/*     $NetBSD: locate.bigram.c,v 1.9 2000/05/06 10:26:45 mycroft Exp $        */
 
 /*
  * Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)locate.bigram.c    8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: locate.bigram.c,v 1.8 2000/03/22 21:45:02 simonb Exp $");
+__RCSID("$NetBSD: locate.bigram.c,v 1.9 2000/05/06 10:26:45 mycroft Exp $");
 #endif /* not lint */
 
 /*
@@ -79,17 +79,8 @@
 add_bigram(i1, i2)
        u_char i1, i2;
 {
-       if (i1 == '\n') {
-               bigrams[0].count++;
-               i1 = 0;
-       }
-       if (i2 == '\n') {
-               bigrams[0].count++;
-               i2 = i1;
-               i1 = 0;
-       }
-
-       bigrams[(i1<<8)+i2].count++;
+       if (i1 != '\n' && i2 != '\n')
+               bigrams[(i1<<8)+i2].count++;
 }
 
 static int



Home | Main Index | Thread Index | Old Index