diff options
Diffstat (limited to 'libpkgconf')
-rw-r--r-- | libpkgconf/argvsplit.c | 2 | ||||
-rw-r--r-- | libpkgconf/config.h.meson | 89 | ||||
-rw-r--r-- | libpkgconf/dependency.c | 6 | ||||
-rw-r--r-- | libpkgconf/fileio.c | 2 | ||||
-rw-r--r-- | libpkgconf/fragment.c | 13 | ||||
-rw-r--r-- | libpkgconf/libpkgconf.h | 7 | ||||
-rw-r--r-- | libpkgconf/meson.build | 12 | ||||
-rw-r--r-- | libpkgconf/parser.c | 7 | ||||
-rw-r--r-- | libpkgconf/personality.c | 15 | ||||
-rw-r--r-- | libpkgconf/pkg.c | 24 | ||||
-rw-r--r-- | libpkgconf/tuple.c | 11 |
11 files changed, 166 insertions, 22 deletions
diff --git a/libpkgconf/argvsplit.c b/libpkgconf/argvsplit.c index 02ce1a3..aaba858 100644 --- a/libpkgconf/argvsplit.c +++ b/libpkgconf/argvsplit.c @@ -118,9 +118,11 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv) } else switch(*src_iter) { +#ifndef _WIN32 case '\\': escaped = true; break; +#endif case '\"': case '\'': diff --git a/libpkgconf/config.h.meson b/libpkgconf/config.h.meson new file mode 100644 index 0000000..d1236c7 --- /dev/null +++ b/libpkgconf/config.h.meson @@ -0,0 +1,89 @@ +/* libpkgconf/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `cygwin_conv_path' function. */ +#mesondefine HAVE_CYGWIN_CONV_PATH + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#mesondefine HAVE_DLFCN_H + +/* Define to 1 if you have the <inttypes.h> header file. */ +#mesondefine HAVE_INTTYPES_H + +/* Define to 1 if you have the <memory.h> header file. */ +#mesondefine HAVE_MEMORY_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#mesondefine HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#mesondefine HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#mesondefine HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#mesondefine HAVE_STRING_H + +/* Define to 1 if you have the `strlcat' function. */ +#mesondefine HAVE_STRLCAT + +/* Define to 1 if you have the `strlcpy' function. */ +#mesondefine HAVE_STRLCPY + +/* Define to 1 if you have the `strndup' function. */ +#mesondefine HAVE_STRNDUP + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#mesondefine HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#mesondefine HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#mesondefine HAVE_UNISTD_H + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#mesondefine LT_OBJDIR + +/* Name of package */ +#mesondefine PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#mesondefine PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#mesondefine PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#mesondefine PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#mesondefine PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#mesondefine PACKAGE_URL + +/* Define to the version of this package. */ +#mesondefine PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#mesondefine STDC_HEADERS + +/* Version number of package */ +#mesondefine VERSION + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#mesondefine _FILE_OFFSET_BITS + +/* Define for large files, on AIX-style hosts. */ +#mesondefine _LARGE_FILES + +#mesondefine PKG_DEFAULT_PATH +#mesondefine SYSTEM_INCLUDEDIR +#mesondefine SYSTEM_LIBDIR +#mesondefine PERSONALITY_PATH diff --git a/libpkgconf/dependency.c b/libpkgconf/dependency.c index b3722b1..d5cdf3c 100644 --- a/libpkgconf/dependency.c +++ b/libpkgconf/dependency.c @@ -237,6 +237,7 @@ pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *dep char *vstart = NULL; char *package = NULL, *version = NULL; char *cnameptr = cmpname; + char *cnameend = cmpname + PKGCONF_ITEM_SIZE - 1; memset(cmpname, '\0', sizeof cmpname); @@ -304,7 +305,8 @@ pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *dep if (PKGCONF_IS_OPERATOR_CHAR(*ptr)) { state = INSIDE_OPERATOR; - *cnameptr++ = *ptr; + if (cnameptr < cnameend) + *cnameptr++ = *ptr; } break; @@ -315,7 +317,7 @@ pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *dep state = AFTER_OPERATOR; compare = pkgconf_pkg_comparator_lookup_by_name(cmpname); } - else + else if (cnameptr < cnameend) *cnameptr++ = *ptr; break; diff --git a/libpkgconf/fileio.c b/libpkgconf/fileio.c index b64205d..22281f2 100644 --- a/libpkgconf/fileio.c +++ b/libpkgconf/fileio.c @@ -20,7 +20,7 @@ char * pkgconf_fgetline(char *line, size_t size, FILE *stream) { char *s = line; - char *end = line + size - 1; + char *end = line + size - 2; bool quoted = false; int c = '\0', c2; diff --git a/libpkgconf/fragment.c b/libpkgconf/fragment.c index b431694..80d9ba2 100644 --- a/libpkgconf/fragment.c +++ b/libpkgconf/fragment.c @@ -137,7 +137,7 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const if (*string == '\0') return; - if (!pkgconf_fragment_is_special(string)) + if (strlen(string) > 1 && !pkgconf_fragment_is_special(string)) { frag = calloc(sizeof(pkgconf_fragment_t), 1); @@ -150,7 +150,8 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const { char mungebuf[PKGCONF_ITEM_SIZE]; - if (list->tail != NULL && list->tail->data != NULL) + if (list->tail != NULL && list->tail->data != NULL && + !(client->flags & PKGCONF_PKG_PKGF_DONT_MERGE_SPECIAL_FRAGMENTS)) { pkgconf_fragment_t *parent = list->tail->data; @@ -432,7 +433,11 @@ fragment_quote(const pkgconf_fragment_t *frag) (*src > ')' && *src < '+') || (*src > ':' && *src < '=') || (*src > '=' && *src < '@') || - (*src > 'Z' && *src < '^') || + (*src > 'Z' && *src < '\\') || +#ifndef _WIN32 + (*src == '\\') || +#endif + (*src > '\\' && *src < '^') || (*src == '`') || (*src > 'z' && *src < '~') || (*src > '~'))) @@ -442,8 +447,10 @@ fragment_quote(const pkgconf_fragment_t *frag) if ((ptrdiff_t)(dst - out) + 2 > outlen) { + ptrdiff_t offset = dst - out; outlen *= 2; out = realloc(out, outlen); + dst = out + offset; } } diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 44a9e7f..ca448eb 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -78,8 +78,8 @@ typedef struct pkgconf_cross_personality_ pkgconf_cross_personality_t; #define PKGCONF_FOREACH_LIST_ENTRY_REVERSE(tail, value) \ for ((value) = (tail); (value) != NULL; (value) = (value)->prev) -#define LIBPKGCONF_VERSION 10603 -#define LIBPKGCONF_VERSION_STR "1.6.3" +#define LIBPKGCONF_VERSION 10700 +#define LIBPKGCONF_VERSION_STR "1.7.0" struct pkgconf_fragment_ { pkgconf_node_t iter; @@ -202,6 +202,8 @@ struct pkgconf_cross_personality_ { pkgconf_list_t filter_includedirs; char *sysroot_dir; + + bool want_default_static; }; /* client.c */ @@ -247,6 +249,7 @@ PKGCONF_API pkgconf_cross_personality_t *pkgconf_cross_personality_find(const ch #define PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS 0x0800 #define PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS 0x1000 #define PKGCONF_PKG_PKGF_DONT_FILTER_INTERNAL_CFLAGS 0x2000 +#define PKGCONF_PKG_PKGF_DONT_MERGE_SPECIAL_FRAGMENTS 0x4000 #define PKGCONF_PKG_DEPF_INTERNAL 0x1 diff --git a/libpkgconf/meson.build b/libpkgconf/meson.build new file mode 100644 index 0000000..64db65a --- /dev/null +++ b/libpkgconf/meson.build @@ -0,0 +1,12 @@ +configure_file(input : 'config.h.meson', + output : 'config.h', + configuration : cdata) + + +install_headers('libpkgconf.h', + 'stdinc.h', + 'iter.h', + 'bsdstubs.h', + 'libpkgconf-api.h', + subdir : 'libpkgconf') + diff --git a/libpkgconf/parser.c b/libpkgconf/parser.c index 17aa697..7ac9362 100644 --- a/libpkgconf/parser.c +++ b/libpkgconf/parser.c @@ -66,8 +66,11 @@ pkgconf_parser_parse(FILE *f, void *data, const pkgconf_parser_operand_func_t *o } op = *p; - *p = '\0'; - p++; + if (*p != '\0') + { + *p = '\0'; + p++; + } while (*p && isspace((unsigned int)*p)) p++; diff --git a/libpkgconf/personality.c b/libpkgconf/personality.c index bbbbbf9..ab9ef74 100644 --- a/libpkgconf/personality.c +++ b/libpkgconf/personality.c @@ -120,6 +120,16 @@ typedef struct { } personality_keyword_pair_t; static void +personality_bool_func(pkgconf_cross_personality_t *p, const char *keyword, const size_t lineno, const ptrdiff_t offset, char *value) +{ + (void) keyword; + (void) lineno; + + bool *dest = (bool *)((char *) p + offset); + *dest = strcasecmp(value, "true") || strcasecmp(value, "yes") || *value == '1'; +} + +static void personality_copy_func(pkgconf_cross_personality_t *p, const char *keyword, const size_t lineno, const ptrdiff_t offset, char *value) { (void) keyword; @@ -146,6 +156,7 @@ static const personality_keyword_pair_t personality_keyword_pairs[] = { {"SystemIncludePaths", personality_fragment_func, offsetof(pkgconf_cross_personality_t, filter_includedirs)}, {"SystemLibraryPaths", personality_fragment_func, offsetof(pkgconf_cross_personality_t, filter_libdirs)}, {"Triplet", personality_copy_func, offsetof(pkgconf_cross_personality_t, name)}, + {"WantDefaultStatic", personality_bool_func, offsetof(pkgconf_cross_personality_t, want_default_static)}, }; static int @@ -168,7 +179,7 @@ personality_keyword_set(pkgconf_cross_personality_t *p, const size_t lineno, con pair->func(p, keyword, lineno, pair->offset, value); } -static const pkgconf_parser_operand_func_t personality_parser_ops[] = { +static const pkgconf_parser_operand_func_t personality_parser_ops[256] = { [':'] = (pkgconf_parser_operand_func_t) personality_keyword_set }; @@ -248,6 +259,6 @@ pkgconf_cross_personality_find(const char *triplet) finish: pkgconf_path_free(&plist); - return out; + return out != NULL ? out : pkgconf_cross_personality_default(); } #endif diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index d91ccde..214f544 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -99,7 +99,7 @@ pkgconf_pkg_parser_version_func(const pkgconf_client_t *client, pkgconf_pkg_t *p /* cut at any detected whitespace */ p = pkgconf_tuple_parse(client, &pkg->vars, value); - len = strcspn(p, " \t\r\n"); + len = strcspn(p, " \t"); if (len) { i = p + (ptrdiff_t) len; @@ -381,13 +381,19 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * /* make module id */ if ((idptr = strrchr(pkg->filename, PKG_DIR_SEP_S)) != NULL) idptr++; -#ifdef _WIN32 - else if ((idptr = strrchr(pkg->filename, '/')) != NULL) - idptr++; -#endif else idptr = pkg->filename; +#ifdef _WIN32 + /* On Windows, both \ and / are allowed in paths, so we have to chop both. + * strrchr() took us to the last \ in that case, so we just have to see if + * it is followed by a /. If so, lop it off. + */ + char *mungeptr; + if ((mungeptr = strrchr(idptr, '/')) != NULL) + idptr = mungeptr++; +#endif + pkg->id = strdup(idptr); idptr = strrchr(pkg->id, '.'); if (idptr) @@ -526,8 +532,8 @@ pkgconf_pkg_try_specific_path(pkgconf_client_t *client, const char *path, const PKGCONF_TRACE(client, "trying path: %s for %s", path, name); - snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, path, name); - snprintf(uninst_locbuf, sizeof uninst_locbuf, "%s/%s-uninstalled" PKG_CONFIG_EXT, path, name); + snprintf(locbuf, sizeof locbuf, "%s%c%s" PKG_CONFIG_EXT, path, PKG_DIR_SEP_S, name); + snprintf(uninst_locbuf, sizeof uninst_locbuf, "%s%c%s-uninstalled" PKG_CONFIG_EXT, path, PKG_DIR_SEP_S, name); if (!(client->flags & PKGCONF_PKG_PKGF_NO_UNINSTALLED) && (f = fopen(uninst_locbuf, "r")) != NULL) { @@ -860,8 +866,8 @@ pkgconf_compare_version(const char *a, const char *b) } ret = strcmp(one, two); - if (ret) - return ret; + if (ret != 0) + return ret < 0 ? -1 : 1; *str1 = oldch1; *str2 = oldch2; diff --git a/libpkgconf/tuple.c b/libpkgconf/tuple.c index f505abd..0d9946d 100644 --- a/libpkgconf/tuple.c +++ b/libpkgconf/tuple.c @@ -264,6 +264,7 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const else if (*(ptr + 1) == '{') { char varname[PKGCONF_ITEM_SIZE]; + char *vend = varname + PKGCONF_ITEM_SIZE - 1; char *vptr = varname; const char *pptr; char *kv, *parsekv; @@ -273,7 +274,15 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const for (pptr = ptr + 2; *pptr != '\0'; pptr++) { if (*pptr != '}') - *vptr++ = *pptr; + { + if (vptr < vend) + *vptr++ = *pptr; + else + { + *vptr = '\0'; + break; + } + } else { *vptr = '\0'; |