Deleted Added
full compact
match.c (93520) match.c (96392)
1/*
2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

14 * Maxim Sobolev
15 * 24 February 2001
16 *
17 * Routines used to query installed packages.
18 *
19 */
20
21#include <sys/cdefs.h>
1/*
2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

14 * Maxim Sobolev
15 * 24 February 2001
16 *
17 * Routines used to query installed packages.
18 *
19 */
20
21#include <sys/cdefs.h>
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/lib/match.c 93520 2002-04-01 09:39:07Z obrien $");
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/lib/match.c 96392 2002-05-11 04:17:55Z alfred $");
23
24#include "lib.h"
25#include <err.h>
26#include <fnmatch.h>
27#include <fts.h>
28#include <regex.h>
29
30/*

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

61 static struct store *store = NULL;
62 FTS *ftsp;
63 FTSENT *f;
64 Boolean *lmatched;
65
66 if (store == NULL) {
67 store = malloc(sizeof *store);
68 if (store == NULL) {
23
24#include "lib.h"
25#include <err.h>
26#include <fnmatch.h>
27#include <fts.h>
28#include <regex.h>
29
30/*

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

61 static struct store *store = NULL;
62 FTS *ftsp;
63 FTSENT *f;
64 Boolean *lmatched;
65
66 if (store == NULL) {
67 store = malloc(sizeof *store);
68 if (store == NULL) {
69 warnx("%s(): malloc() failed", __FUNCTION__);
69 warnx("%s(): malloc() failed", __func__);
70 if (retval != NULL)
71 *retval = 1;
72 return NULL;
73 }
74 store->currlen = 0;
75 store->store = NULL;
76 } else
77 if (store->store != NULL)

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

90 /* Not reached */
91 }
92
93 /* Count number of patterns */
94 if (patterns != NULL) {
95 for (len = 0; patterns[len]; len++) {}
96 lmatched = alloca(sizeof(*lmatched) * len);
97 if (lmatched == NULL) {
70 if (retval != NULL)
71 *retval = 1;
72 return NULL;
73 }
74 store->currlen = 0;
75 store->store = NULL;
76 } else
77 if (store->store != NULL)

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

90 /* Not reached */
91 }
92
93 /* Count number of patterns */
94 if (patterns != NULL) {
95 for (len = 0; patterns[len]; len++) {}
96 lmatched = alloca(sizeof(*lmatched) * len);
97 if (lmatched == NULL) {
98 warnx("%s(): alloca() failed", __FUNCTION__);
98 warnx("%s(): alloca() failed", __func__);
99 if (retval != NULL)
100 *retval = 1;
101 return NULL;
102 }
103 } else
104 len = 0;
105
106 for (i = 0; i < len; i++)

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

198storeappend(struct store *store, const char *item)
199{
200 if (store->used + 2 > store->currlen) {
201 store->currlen += 16;
202 store->store = reallocf(store->store,
203 store->currlen * sizeof(*(store->store)));
204 if (store->store == NULL) {
205 store->currlen = 0;
99 if (retval != NULL)
100 *retval = 1;
101 return NULL;
102 }
103 } else
104 len = 0;
105
106 for (i = 0; i < len; i++)

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

198storeappend(struct store *store, const char *item)
199{
200 if (store->used + 2 > store->currlen) {
201 store->currlen += 16;
202 store->store = reallocf(store->store,
203 store->currlen * sizeof(*(store->store)));
204 if (store->store == NULL) {
205 store->currlen = 0;
206 warnx("%s(): reallocf() failed", __FUNCTION__);
206 warnx("%s(): reallocf() failed", __func__);
207 return 1;
208 }
209 }
210
211 asprintf(&(store->store[store->used]), "%s", item);
212 if (store->store[store->used] == NULL) {
207 return 1;
208 }
209 }
210
211 asprintf(&(store->store[store->used]), "%s", item);
212 if (store->store[store->used] == NULL) {
213 warnx("%s(): malloc() failed", __FUNCTION__);
213 warnx("%s(): malloc() failed", __func__);
214 return 1;
215 }
216 store->used++;
217 store->store[store->used] = NULL;
218
219 return 0;
220}
221
222static int
223fname_cmp(const FTSENT **a, const FTSENT **b)
224{
225 return strcmp((*a)->fts_name, (*b)->fts_name);
226}
214 return 1;
215 }
216 store->used++;
217 store->store[store->used] = NULL;
218
219 return 0;
220}
221
222static int
223fname_cmp(const FTSENT **a, const FTSENT **b)
224{
225 return strcmp((*a)->fts_name, (*b)->fts_name);
226}