everything: do not shadow POSIX BUFSIZ definition

pull/29/head
William Pitcock 2012-07-21 14:38:13 -05:00
parent f4d84620a1
commit b0cdca488e
5 changed files with 10 additions and 12 deletions

View File

@ -104,7 +104,7 @@ pkg_dependency_parse_str(pkg_dependency_t *deplist_head, const char *depends)
parse_state_t state = OUTSIDE_MODULE; parse_state_t state = OUTSIDE_MODULE;
pkg_dependency_t *deplist = NULL; pkg_dependency_t *deplist = NULL;
pkg_comparator_t compare = PKG_ANY; pkg_comparator_t compare = PKG_ANY;
char buf[BUFSIZ]; char buf[PKG_BUFSIZE];
char *start = buf; char *start = buf;
char *ptr = buf; char *ptr = buf;
char *vstart = NULL; char *vstart = NULL;

2
main.c
View File

@ -700,7 +700,7 @@ main(int argc, char *argv[])
} }
else else
{ {
char packagebuf[BUFSIZ]; char packagebuf[PKG_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;

6
pkg.c
View File

@ -127,12 +127,12 @@ pkg_t *
pkg_new_from_file(const char *filename, FILE *f) pkg_new_from_file(const char *filename, FILE *f)
{ {
pkg_t *pkg; pkg_t *pkg;
char readbuf[BUFSIZ]; char readbuf[PKG_BUFSIZE];
pkg = calloc(sizeof(pkg_t), 1); pkg = calloc(sizeof(pkg_t), 1);
pkg->filename = strdup(filename); pkg->filename = strdup(filename);
while (pkg_fgetline(readbuf, BUFSIZ, f) != NULL) while (pkg_fgetline(readbuf, PKG_BUFSIZE, f) != NULL)
{ {
char op, *p, *key = NULL, *value = NULL; char op, *p, *key = NULL, *value = NULL;
@ -366,7 +366,7 @@ int
pkg_compare_version(const char *a, const char *b) pkg_compare_version(const char *a, const char *b)
{ {
char oldch1, oldch2; char oldch1, oldch2;
char buf1[BUFSIZ], buf2[BUFSIZ]; char buf1[PKG_BUFSIZE], buf2[PKG_BUFSIZE];
char *str1, *str2; char *str1, *str2;
char *one, *two; char *one, *two;
int ret; int ret;

4
pkg.h
View File

@ -19,9 +19,7 @@
#include "config.h" #include "config.h"
#include "stdinc.h" #include "stdinc.h"
#ifndef BUFSIZ #define PKG_BUFSIZE (65535)
#define BUFSIZ 65535
#endif
/* we are compatible with 0.27 of pkg-config */ /* we are compatible with 0.27 of pkg-config */
#define PKG_PKGCONFIG_VERSION_EQUIV "0.27" #define PKG_PKGCONFIG_VERSION_EQUIV "0.27"

View File

@ -96,17 +96,17 @@ pkg_tuple_find(pkg_tuple_t *head, const char *key)
char * char *
pkg_tuple_parse(pkg_tuple_t *vars, const char *value) pkg_tuple_parse(pkg_tuple_t *vars, const char *value)
{ {
char buf[BUFSIZ]; char buf[PKG_BUFSIZE];
const char *ptr; const char *ptr;
char *bptr = buf; char *bptr = buf;
for (ptr = value; *ptr != '\0' && bptr - buf < BUFSIZ; ptr++) for (ptr = value; *ptr != '\0' && bptr - buf < PKG_BUFSIZE; ptr++)
{ {
if (*ptr != '$') if (*ptr != '$')
*bptr++ = *ptr; *bptr++ = *ptr;
else if (*(ptr + 1) == '{') else if (*(ptr + 1) == '{')
{ {
static char varname[BUFSIZ]; static char varname[PKG_BUFSIZE];
char *vptr = varname; char *vptr = varname;
const char *pptr; const char *pptr;
char *kv, *parsekv; char *kv, *parsekv;
@ -131,7 +131,7 @@ pkg_tuple_parse(pkg_tuple_t *vars, const char *value)
{ {
parsekv = pkg_tuple_parse(vars, kv); parsekv = pkg_tuple_parse(vars, kv);
strncpy(bptr, parsekv, BUFSIZ - (bptr - buf)); strncpy(bptr, parsekv, PKG_BUFSIZE - (bptr - buf));
bptr += strlen(parsekv); bptr += strlen(parsekv);
free(parsekv); free(parsekv);