Deleted Added
full compact
locate.code.c (92920) locate.code.c (209571)
1/*
2 * Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
3 * Copyright (c) 1989, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * James A. Woods.
8 *

--- 20 unchanged lines hidden (view full) ---

29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
1/*
2 * Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
3 * Copyright (c) 1989, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * James A. Woods.
8 *

--- 20 unchanged lines hidden (view full) ---

29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * $FreeBSD: head/usr.bin/locate/code/locate.code.c 92920 2002-03-22 01:22:50Z imp $
37 * $FreeBSD: head/usr.bin/locate/code/locate.code.c 209571 2010-06-28 12:04:55Z gavin $
38 */
39
38 */
39
40#if 0
40#ifndef lint
41static char copyright[] =
42"@(#) Copyright (c) 1989, 1993\n\
43 The Regents of the University of California. All rights reserved.\n";
44#endif /* not lint */
45
46#ifndef lint
47static char sccsid[] = "@(#)locate.code.c 8.1 (Berkeley) 6/6/93";
48#endif /* not lint */
41#ifndef lint
42static char copyright[] =
43"@(#) Copyright (c) 1989, 1993\n\
44 The Regents of the University of California. All rights reserved.\n";
45#endif /* not lint */
46
47#ifndef lint
48static char sccsid[] = "@(#)locate.code.c 8.1 (Berkeley) 6/6/93";
49#endif /* not lint */
50#endif
49
50/*
51 * PURPOSE: sorted list compressor (works with a modified 'find'
52 * to encode/decode a filename database)
53 *
54 * USAGE: bigram < list > bigrams
55 * process bigrams (see updatedb) > common_bigrams
56 * code common_bigrams < list > squozen_list

--- 60 unchanged lines hidden (view full) ---

117typedef int bg_t;
118int bgindex(char *);
119#endif /* LOOKUP */
120
121
122void usage(void);
123
124int
51
52/*
53 * PURPOSE: sorted list compressor (works with a modified 'find'
54 * to encode/decode a filename database)
55 *
56 * USAGE: bigram < list > bigrams
57 * process bigrams (see updatedb) > common_bigrams
58 * code common_bigrams < list > squozen_list

--- 60 unchanged lines hidden (view full) ---

119typedef int bg_t;
120int bgindex(char *);
121#endif /* LOOKUP */
122
123
124void usage(void);
125
126int
125main(argc, argv)
126 int argc;
127 char *argv[];
127main(int argc, char *argv[])
128{
128{
129 register u_char *cp, *oldpath, *path;
129 u_char *cp, *oldpath, *path;
130 int ch, code, count, diffcount, oldcount;
130 int ch, code, count, diffcount, oldcount;
131 u_int i, j;
131 FILE *fp;
132 FILE *fp;
132 register int i, j;
133
134 while ((ch = getopt(argc, argv, "")) != -1)
135 switch(ch) {
136 default:
137 usage();
138 }
139 argc -= optind;
140 argv += optind;

--- 110 unchanged lines hidden (view full) ---

251 /* Non-zero status if there were errors */
252 if (fflush(stdout) != 0 || ferror(stdout))
253 exit(1);
254 exit(0);
255}
256
257#ifndef LOOKUP
258int
133
134 while ((ch = getopt(argc, argv, "")) != -1)
135 switch(ch) {
136 default:
137 usage();
138 }
139 argc -= optind;
140 argv += optind;

--- 110 unchanged lines hidden (view full) ---

251 /* Non-zero status if there were errors */
252 if (fflush(stdout) != 0 || ferror(stdout))
253 exit(1);
254 exit(0);
255}
256
257#ifndef LOOKUP
258int
259bgindex(bg) /* Return location of bg in bigrams or -1. */
260 char *bg;
259bgindex(char *bg) /* Return location of bg in bigrams or -1. */
261{
260{
262 register char bg0, bg1, *p;
261 char bg0, bg1, *p;
263
264 bg0 = bg[0];
265 bg1 = bg[1];
266 for (p = bigrams; *p != NULL; p++)
267 if (*p++ == bg0 && *p == bg1)
268 break;
269 return (*p == NULL ? -1 : (--p - bigrams));
270}
271#endif /* !LOOKUP */
272
273void
262
263 bg0 = bg[0];
264 bg1 = bg[1];
265 for (p = bigrams; *p != NULL; p++)
266 if (*p++ == bg0 && *p == bg1)
267 break;
268 return (*p == NULL ? -1 : (--p - bigrams));
269}
270#endif /* !LOOKUP */
271
272void
274usage()
273usage(void)
275{
276 (void)fprintf(stderr,
277 "usage: locate.code common_bigrams < list > squozen_list\n");
278 exit(1);
279}
274{
275 (void)fprintf(stderr,
276 "usage: locate.code common_bigrams < list > squozen_list\n");
277 exit(1);
278}