libpkgconf: PKG_BUFSIZE becomes PKGCONF_BUFSIZE, remove unused PKG_MIN/PKG_MAX.

pull/81/head
William Pitcock 2015-09-06 11:29:56 -05:00
parent ca1b02659a
commit 571d9c756c
6 changed files with 15 additions and 18 deletions

View File

@ -87,8 +87,8 @@ pkgconf_dependency_parse_str(pkgconf_list_t *deplist_head, const char *depends)
{ {
parse_state_t state = OUTSIDE_MODULE; parse_state_t state = OUTSIDE_MODULE;
pkgconf_pkg_comparator_t compare = PKG_ANY; pkgconf_pkg_comparator_t compare = PKG_ANY;
char cmpname[PKG_BUFSIZE]; char cmpname[PKGCONF_BUFSIZE];
char buf[PKG_BUFSIZE]; char buf[PKGCONF_BUFSIZE];
size_t package_sz = 0, version_sz = 0; size_t package_sz = 0, version_sz = 0;
char *start = buf; char *start = buf;
char *ptr = buf; char *ptr = buf;

View File

@ -18,7 +18,7 @@
static inline char * static inline char *
pkgconf_fragment_copy_munged(const char *source, unsigned int flags) pkgconf_fragment_copy_munged(const char *source, unsigned int flags)
{ {
char mungebuf[PKG_BUFSIZE]; char mungebuf[PKGCONF_BUFSIZE];
char *sysroot_dir; char *sysroot_dir;
if (!(flags & PKGF_MUNGE_SYSROOT_PREFIX)) if (!(flags & PKGF_MUNGE_SYSROOT_PREFIX))

View File

@ -21,7 +21,7 @@
#include <libpkgconf/iter.h> #include <libpkgconf/iter.h>
#include <libpkgconf/bsdstubs.h> #include <libpkgconf/bsdstubs.h>
#define PKG_BUFSIZE (65535) #define PKGCONF_BUFSIZE (65535)
typedef enum { typedef enum {
PKG_ANY = 0, PKG_ANY = 0,
@ -49,9 +49,6 @@ typedef struct pkgconf_fragment_ pkgconf_fragment_t;
#define PKGCONF_FOREACH_LIST_ENTRY_REVERSE(tail, value) \ #define PKGCONF_FOREACH_LIST_ENTRY_REVERSE(tail, value) \
for ((value) = (tail); (value) != NULL; (value) = (value)->prev) for ((value) = (tail); (value) != NULL; (value) = (value)->prev)
#define PKG_MIN(a,b) (((a) < (b)) ? (a) : (b))
#define PKG_MAX(a,b) (((a) > (b)) ? (a) : (b))
struct pkgconf_fragment_ { struct pkgconf_fragment_ {
pkgconf_node_t iter; pkgconf_node_t iter;

View File

@ -130,7 +130,7 @@ get_pkgconfig_path(void)
static const char * static const char *
pkg_get_parent_dir(pkgconf_pkg_t *pkg) pkg_get_parent_dir(pkgconf_pkg_t *pkg)
{ {
static char buf[PKG_BUFSIZE]; static char buf[PKGCONF_BUFSIZE];
char *pathbuf; char *pathbuf;
strlcpy(buf, pkg->filename, sizeof buf); strlcpy(buf, pkg->filename, sizeof buf);
@ -174,7 +174,7 @@ pkgconf_pkg_t *
pkgconf_pkg_new_from_file(const char *filename, FILE *f, unsigned int flags) pkgconf_pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
{ {
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
char readbuf[PKG_BUFSIZE]; char readbuf[PKGCONF_BUFSIZE];
char *idptr; char *idptr;
pkg = calloc(sizeof(pkgconf_pkg_t), 1); pkg = calloc(sizeof(pkgconf_pkg_t), 1);
@ -192,7 +192,7 @@ pkgconf_pkg_new_from_file(const char *filename, FILE *f, unsigned int flags)
if (idptr) if (idptr)
*idptr = '\0'; *idptr = '\0';
while (pkgconf_fgetline(readbuf, PKG_BUFSIZE, f) != NULL) while (pkgconf_fgetline(readbuf, PKGCONF_BUFSIZE, f) != NULL)
{ {
char op, *p, *key, *value; char op, *p, *key, *value;
@ -347,7 +347,7 @@ pkgconf_pkg_scan_dir(const char *path, pkgconf_pkg_iteration_func_t func)
for (dirent = readdir(dir); dirent != NULL; dirent = readdir(dir)) for (dirent = readdir(dir); dirent != NULL; dirent = readdir(dir))
{ {
static char filebuf[PKG_BUFSIZE]; static char filebuf[PKGCONF_BUFSIZE];
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
FILE *f; FILE *f;
struct stat st; struct stat st;
@ -492,7 +492,7 @@ int
pkgconf_compare_version(const char *a, const char *b) pkgconf_compare_version(const char *a, const char *b)
{ {
char oldch1, oldch2; char oldch1, oldch2;
char buf1[PKG_BUFSIZE], buf2[PKG_BUFSIZE]; char buf1[PKGCONF_BUFSIZE], buf2[PKGCONF_BUFSIZE];
char *str1, *str2; char *str1, *str2;
char *one, *two; char *one, *two;
int ret; int ret;

View File

@ -97,17 +97,17 @@ pkgconf_tuple_find(pkgconf_list_t *list, const char *key)
char * char *
pkgconf_tuple_parse(pkgconf_list_t *vars, const char *value) pkgconf_tuple_parse(pkgconf_list_t *vars, const char *value)
{ {
char buf[PKG_BUFSIZE]; char buf[PKGCONF_BUFSIZE];
const char *ptr; const char *ptr;
char *bptr = buf; char *bptr = buf;
for (ptr = value; *ptr != '\0' && bptr - buf < PKG_BUFSIZE; ptr++) for (ptr = value; *ptr != '\0' && bptr - buf < PKGCONF_BUFSIZE; ptr++)
{ {
if (*ptr != '$' || (*ptr == '$' && *(ptr + 1) != '{')) if (*ptr != '$' || (*ptr == '$' && *(ptr + 1) != '{'))
*bptr++ = *ptr; *bptr++ = *ptr;
else if (*(ptr + 1) == '{') else if (*(ptr + 1) == '{')
{ {
static char varname[PKG_BUFSIZE]; static char varname[PKGCONF_BUFSIZE];
char *vptr = varname; char *vptr = varname;
const char *pptr; const char *pptr;
char *kv, *parsekv; char *kv, *parsekv;
@ -132,7 +132,7 @@ pkgconf_tuple_parse(pkgconf_list_t *vars, const char *value)
{ {
parsekv = pkgconf_tuple_parse(vars, kv); parsekv = pkgconf_tuple_parse(vars, kv);
strncpy(bptr, parsekv, PKG_BUFSIZE - (bptr - buf)); strncpy(bptr, parsekv, PKGCONF_BUFSIZE - (bptr - buf));
bptr += strlen(parsekv); bptr += strlen(parsekv);
free(parsekv); free(parsekv);

4
main.c
View File

@ -294,7 +294,7 @@ apply_variables(pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int f
typedef struct { typedef struct {
const char *variable; const char *variable;
char buf[PKG_BUFSIZE]; char buf[PKGCONF_BUFSIZE];
} var_request_t; } var_request_t;
static void static void
@ -855,7 +855,7 @@ main(int argc, char *argv[])
} }
else else
{ {
char packagebuf[PKG_BUFSIZE]; char packagebuf[PKGCONF_BUFSIZE];
snprintf(packagebuf, sizeof packagebuf, "%s %s %s", package, argv[pkg_optind + 1], argv[pkg_optind + 2]); snprintf(packagebuf, sizeof packagebuf, "%s %s %s", package, argv[pkg_optind + 1], argv[pkg_optind + 2]);
pkg_optind += 3; pkg_optind += 3;