Deleted Added
full compact
util.c (23012) util.c (27574)
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 * $Id$
37 * $Id: util.c,v 1.4 1997/02/22 19:55:50 peter Exp $
38 */
39
40
41#include <stdlib.h>
42#include <string.h>
43#include <err.h>
44#include <sys/param.h>
45#include <stdio.h>

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

62check_bigram_char(ch)
63 int ch;
64{
65 /* legal bigram: 0, ASCII_MIN ... ASCII_MAX */
66 if (ch == 0 ||
67 (ch >= ASCII_MIN && ch <= ASCII_MAX))
68 return(ch);
69
38 */
39
40
41#include <stdlib.h>
42#include <string.h>
43#include <err.h>
44#include <sys/param.h>
45#include <stdio.h>

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

62check_bigram_char(ch)
63 int ch;
64{
65 /* legal bigram: 0, ASCII_MIN ... ASCII_MAX */
66 if (ch == 0 ||
67 (ch >= ASCII_MIN && ch <= ASCII_MAX))
68 return(ch);
69
70 (void)fprintf(stderr, "locate database header corrupt, bigram ");
71 (void)fprintf(stderr, "char outside 0, %d-%d: %d\n",
72 ASCII_MIN, ASCII_MAX, ch);
70 errx(1,
71 "locate database header corrupt, bigram char outside 0, %d-%d: %d",
72 ASCII_MIN, ASCII_MAX, ch);
73 exit(1);
74}
75
76/* split a colon separated string into a char vector
77 *
78 * "bla:foo" -> {"foo", "bla"}
79 * "bla:" -> {"foo", dot}
80 * "bla" -> {"bla"}

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

94 if (dbv == NULL) {
95 if ((dbv = malloc(sizeof(char **))) == NULL)
96 err(1, "malloc");
97 *dbv = NULL;
98 }
99
100 /* empty string */
101 if (*path == '\0') {
73 exit(1);
74}
75
76/* split a colon separated string into a char vector
77 *
78 * "bla:foo" -> {"foo", "bla"}
79 * "bla:" -> {"foo", dot}
80 * "bla" -> {"bla"}

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

94 if (dbv == NULL) {
95 if ((dbv = malloc(sizeof(char **))) == NULL)
96 err(1, "malloc");
97 *dbv = NULL;
98 }
99
100 /* empty string */
101 if (*path == '\0') {
102 (void)fprintf(stderr, "empty database name, ignored\n");
102 warnx("empty database name, ignored");
103 return(dbv);
104 }
105
106 /* length of string vector */
107 for(vlen = 0, pv = dbv; *pv != NULL; pv++, vlen++);
108
109 for (ch = c = path; ; ch++) {
110 if (*ch == ':' ||

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

235
236 for (i = 0; i < INTSIZE; i++)
237 buf[i] = *p++;
238
239 i = *(int *)buf;
240
241 if (i > MAXPATHLEN || i < -(MAXPATHLEN)) {
242 i = ntohl(i);
103 return(dbv);
104 }
105
106 /* length of string vector */
107 for(vlen = 0, pv = dbv; *pv != NULL; pv++, vlen++);
108
109 for (ch = c = path; ; ch++) {
110 if (*ch == ':' ||

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

235
236 for (i = 0; i < INTSIZE; i++)
237 buf[i] = *p++;
238
239 i = *(int *)buf;
240
241 if (i > MAXPATHLEN || i < -(MAXPATHLEN)) {
242 i = ntohl(i);
243 if (i > MAXPATHLEN || i < -(MAXPATHLEN)) {
244 (void)fprintf(stderr,
245 "integer out of +-MAXPATHLEN (%d): %d\n",
246 MAXPATHLEN, i);
247 exit(1);
248 }
243 if (i > MAXPATHLEN || i < -(MAXPATHLEN))
244 errx(1, "integer out of +-MAXPATHLEN (%d): %d", MAXPATHLEN, i);
249 }
250 return(i);
251}
252
253/*
254 * Read integer from stream.
255 *
256 * Convert network byte order to host byte order if neccessary.

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

263 FILE *fp;
264{
265 register int word;
266
267 word = getw(fp);
268
269 if (word > MAXPATHLEN || word < -(MAXPATHLEN)) {
270 word = ntohl(word);
245 }
246 return(i);
247}
248
249/*
250 * Read integer from stream.
251 *
252 * Convert network byte order to host byte order if neccessary.

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

259 FILE *fp;
260{
261 register int word;
262
263 word = getw(fp);
264
265 if (word > MAXPATHLEN || word < -(MAXPATHLEN)) {
266 word = ntohl(word);
271 if (word > MAXPATHLEN || word < -(MAXPATHLEN)) {
272 (void)fprintf(stderr,
273 "integer out of +-MAXPATHLEN (%d): %d\n",
274 MAXPATHLEN, word);
275 exit(1);
276 }
267 if (word > MAXPATHLEN || word < -(MAXPATHLEN))
268 errx(1, "integer out of +-MAXPATHLEN (%d): %d", MAXPATHLEN, word);
277 }
278 return(word);
279}
269 }
270 return(word);
271}