Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
windows:mingw:win64
mingw64-libsatsolver
satsolver-mingw.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File satsolver-mingw.diff of Package mingw64-libsatsolver
--- applayer/CMakeLists.txt +++ applayer/CMakeLists.txt @@ -12,7 +12,7 @@ SET(libappsatsolver_HEADERS job.h applayer.h covenant.h decision.h dependency.h kinds.h problem.h relation.h solution.h step.h request.h ruleinfo.h xrepokey.h xsolvable.h) -SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Werror" ) +SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" ) INSTALL( FILES ${libappsatsolver_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/satsolver" ) INSTALL(TARGETS appsatsolver LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) --- CMakeLists.txt +++ CMakeLists.txt @@ -131,15 +126,14 @@ MESSAGE(STATUS "Looking modules in ${CMAKE_MODULE_PATH}") -set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall" ) +set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" ) set ( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -g -O3" ) set ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -O0" ) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(ext) ADD_SUBDIRECTORY(tools) ADD_SUBDIRECTORY(applayer) -ADD_SUBDIRECTORY(examples) ADD_SUBDIRECTORY(doc) FIND_PACKAGE(SWIG) --- ext/CMakeLists.txt +++ ext/CMakeLists.txt @@ -12,7 +12,5 @@ repo_susetags.h repo_updateinfoxml.h repo_write.h repo_zyppdb.h tools_util.h repo_deb.h) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - INSTALL(FILES ${libsatsolverext_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/satsolver") INSTALL(TARGETS satsolverext LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) --- src/CMakeLists.txt +++ src/CMakeLists.txt @@ -15,7 +15,5 @@ strpool.h dirpool.h knownid.h transaction.h rules.h problems.h chksum.h md5.h sha1.h sha2.h ${CMAKE_BINARY_DIR}/src/satversion.h) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - INSTALL(FILES ${libsatsolver_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/satsolver") INSTALL(TARGETS satsolver LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) --- src/poolvendor.c +++ src/poolvendor.c @@ -9,18 +9,389 @@ #include <stdlib.h> #include <string.h> -/* we need FNM_CASEFOLD */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include <fnmatch.h> #include "pool.h" #include "poolid.h" #include "poolvendor.h" #include "util.h" +/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GTK+ Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + */ + +/* + * Stripped down, converted to UTF-8 and test cases added + * + * Owen Taylor, 13 December 2002; + */ + +/* + * UTF-8 and GLib stuff removed for use in other code on Windows only + * using system codepage filenames, i.e. multi-byte strings. + * + * Tor Lillqvist 2009-12-01 + */ + +#include <stdlib.h> +#include <wchar.h> +#include <mbstring.h> + +#define IS_DIR_SEPARATOR(c) ((c)=='/' || (c)=='\\') + +static wchar_t +get_char (const char **str) +{ + wchar_t c; + int nbytes; + + nbytes = mbtowc (&c, *str, MB_CUR_MAX); + + if (nbytes > 0) + *str += nbytes; + else + { + /* Just skip ahead a byte at a time on errors... */ + (*str)++; + c = 0; + } + + c = towlower (c); + + return c; +} + +static const char * +strdirsep (const char *p) +{ + const char *slash = (const char *) _mbschr ((const unsigned char *) p, '/'); + const char *backslash = (const char *) _mbschr ((const unsigned char *) p, '\\'); + + if (slash == NULL || + (backslash != NULL && backslash < slash)) + return backslash; + + return slash; +} + +/* Match STRING against the filename pattern PATTERN, returning zero if + it matches, nonzero if not. */ + +/* Match STRING against the filename pattern PATTERN, returning zero if + * it matches, nonzero if not. + * + * This is special-cased as if this combinations of flags: + * + * FNM_FILE_NAME - always set + * FNM_LEADING_DIR - never set + * FNM_CASEFOLD - always set as this is for Windows + */ + +#define FNM_CASEFOLD 0 + +static int +fnmatch_intern (const char *pattern, + const char *string, + int component_start, + int no_leading_period) +{ + const char *p = pattern, *n = string; + + while (*p) + { + const char *last_n = n; + + wchar_t c = get_char (&p); + wchar_t nc = get_char (&n); + + switch (c) + { + case '?': + if (nc == '\0') + return 0; + else if (IS_DIR_SEPARATOR (nc)) + return 0; + else if (nc == '.' && component_start && no_leading_period) + return 0; + break; + case '*': + if (nc == '.' && component_start && no_leading_period) + return 0; + + { + const char *last_p = p; + + for (last_p = p, c = get_char (&p); + c == '?' || c == '*'; + last_p = p, c = get_char (&p)) + { + if (c == '?') + { + if (nc == '\0') + return 0; + else if (IS_DIR_SEPARATOR(nc)) + return 0; + else + { + last_n = n; nc = get_char (&n); + } + } + } + + /* If the pattern ends with wildcards, we have a + * guaranteed match unless there is a dir separator + * in the remainder of the string. + */ + if (c == '\0') + { + if (strdirsep (last_n) != NULL) + return 0; + else + return 1; + } + + for (p = last_p; nc != '\0';) + { + if ((c == '[' || nc == c) && + fnmatch_intern (p, last_n, component_start, no_leading_period)) + return 1; + + component_start = IS_DIR_SEPARATOR (nc); + last_n = n; + nc = get_char (&n); + } + + return 0; + } + + case '[': + { + /* Nonzero if the sense of the character class is inverted. */ + int not; + + if (nc == '\0' || IS_DIR_SEPARATOR (nc)) + return 0; + + if (nc == '.' && component_start && no_leading_period) + return 0; + + not = (*p == '!' || *p == '^'); + if (not) + ++p; + + c = get_char (&p); + for (;;) + { + register wchar_t cstart = c, cend = c; + if (c == '\0') + /* [ (unterminated) loses. */ + return 0; + + c = get_char (&p); + + if (c == '-' && *p != ']') + { + cend = get_char (&p); + if (cend == '\0') + return 0; + + c = get_char (&p); + } + + if (nc >= cstart && nc <= cend) + goto matched; + + if (c == ']') + break; + } + if (!not) + return 0; + break; + + matched:; + /* Skip the rest of the [...] that already matched. */ + /* XXX 1003.2d11 is unclear if was_escaped is right. */ + while (c != ']') + { + if (c == '\0') + /* [... (unterminated) loses. */ + return 0; + + c = get_char (&p); + } + if (not) + return 0; + } + break; + + case '/': + case '\\': + if (!IS_DIR_SEPARATOR (nc)) + return 0; + break; + + default: + if (c != nc) + return 0; + } + + component_start = IS_DIR_SEPARATOR (nc); + } + + if (*n == '\0') + return 1; + + return 0; +} + +static int +fnmatch (const char *pattern, + const char *string, + int no_leading_period) +{ + return fnmatch_intern (pattern, string, 1, no_leading_period); +} + +#ifdef FNMATCH_TEST_CASES + +#include <stdio.h> + +#define TEST(pat, str, no_leading_period, result) \ + do { \ + int rc = fnmatch ((pat), (str), (no_leading_period)); \ + if (rc != result) \ + fprintf (stderr, "Wrong result from fnmatch (\"%s\", \"%s\", %d): %d, should be %d\n", \ + (pat), (str), (no_leading_period), rc, result); \ + } while (0) + +int main (int argc, char **argv) +{ + TEST ("[a-]", "-", 1, 1); + + TEST ("a", "a", 1, 1); + TEST ("a", "b", 1, 0); + + TEST ("a", "A", 1, 1); + TEST ("A", "a", 1, 1); + + /* Test what ? matches */ + TEST ("?", "a", 1, 1); + TEST ("?", ".", 1, 0); + TEST ("a?", "a.", 1, 1); + TEST ("a/?", "a/b", 1, 1); + TEST ("a\\?", "a\\b", 1, 1); + TEST ("a/?", "a\\b", 1, 1); + TEST ("a\\?", "a/b", 1, 1); + TEST ("a/?", "a/.", 1, 0); + TEST ("a\\?", "a\\.", 1, 0); + TEST ("a\\?", "a/.", 1, 0); + TEST ("a/?", "a\\.", 1, 0); + TEST ("?", "/", 1, 0); + TEST ("?", "\\", 1, 0); + + /* Test what * matches */ + TEST ("*", "a", 1, 1); + TEST ("*", ".", 1, 0); + TEST ("a*", "a.", 1, 1); + TEST ("a/*", "a/b", 1, 1); + TEST ("a\\*", "a\\b", 1, 1); + TEST ("a\\*", "a/b", 1, 1); + TEST ("a/*", "a\\b", 1, 1); + TEST ("a/*", "a/.", 1, 0); + TEST ("a\\*", "a\\.", 1, 0); + TEST ("a\\*", "a/.", 1, 0); + TEST ("a/*", "a\\.", 1, 0); + TEST ("*", "/", 1, 0); + TEST ("*", "\\", 1, 0); + + /* Range tests */ + TEST ("[ab]", "a", 1, 1); + TEST ("[AB]", "a", 1, 1); + TEST ("[ab]", "A", 1, 1); + TEST ("[ab]", "c", 1, 0); + TEST ("[^ab]", "a", 1, 0); + TEST ("[^AB]", "a", 1, 0); + TEST ("[^ab]", "A", 1, 0); + TEST ("[!ab]", "a", 1, 0); + TEST ("[^ab]", "c", 1, 1); + TEST ("[!ab]", "c", 1, 1); + TEST ("[a-c]", "b", 1, 1); + TEST ("[a-c]", "B", 1, 1); + TEST ("[A-C]", "b", 1, 1); + TEST ("[a-c]", "d", 1, 0); + TEST ("[a-]", "-", 1, 1); + TEST ("[]]", "]", 1, 1); + TEST ("[^]]", "a", 1, 1); + TEST ("[!]]", "a", 1, 1); + + /* Various unclosed ranges */ + TEST ("[ab", "a", 1, 0); + TEST ("[a-", "a", 1, 0); + TEST ("[ab", "c", 1, 0); + TEST ("[a-", "c", 1, 0); + TEST ("[^]", "a", 1, 0); + + /* Ranges and special no-wildcard matches */ + TEST ("[.]", ".", 1, 0); + TEST ("a[.]", "a.", 1, 1); + TEST ("a/[.]", "a/.", 1, 0); + TEST ("a\\[.]", "a\\.", 1, 0); + TEST ("a/[.]", "a\\.", 1, 0); + TEST ("[/]", "/", 1, 0); + TEST ("[/]", "\\", 1, 0); + TEST ("[^/]", "a", 1, 1); + + /* Basic tests of * (and combinations of * and ?) */ + TEST ("a*b", "ab", 1, 1); + TEST ("a*B", "Ab", 1, 1); + TEST ("A*b", "aB", 1, 1); + TEST ("a*b", "axb", 1, 1); + TEST ("a*b", "axxb", 1, 1); + TEST ("a*b", "axXB", 1, 1); + TEST ("a**b", "ab", 1, 1); + TEST ("a**b", "axb", 1, 1); + TEST ("a**b", "axxb", 1, 1); + TEST ("a*?*b", "ab", 1, 0); + TEST ("a*?*b", "axb", 1, 1); + TEST ("a*?*b", "axxb", 1, 1); + + /* Test of *[range] */ + TEST ("a*[cd]", "ac", 1, 1); + TEST ("a*[cd]", "axc", 1, 1); + TEST ("a*[cd]", "axx", 1, 0); + + TEST ("a/[.]", "a/.", 1, 0); + TEST ("a\\[.]", "a\\.", 1, 0); + TEST ("a\\[.]", "a/.", 1, 0); + TEST ("a/[.]", "a\\.", 1, 0); + TEST ("a*[.]", "a/.", 1, 0); + TEST ("a*[.]", "a\\.", 1, 0); + + return 0; +} + +#endif /* FNMATCH_TEST_CASES */ + const char *vendors[] = { "!openSUSE Build Service*", "SUSE*", --- src/repo.c +++ src/repo.c @@ -9,9 +9,7 @@ * */ -#define _GNU_SOURCE #include <string.h> -#include <fnmatch.h> #include <stdio.h> #include <stdlib.h> --- src/repodata.c +++ src/repodata.c @@ -9,9 +9,7 @@ * different sets of keys and different sets of solvables */ -#define _GNU_SOURCE #include <string.h> -#include <fnmatch.h> #include <stdio.h> #include <stdlib.h> @@ -34,6 +34,413 @@ #include "repopack.h" #include "repopage.h" +/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GTK+ Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GTK+ at ftp://ftp.gtk.org/pub/gtk/. + */ + +/* + * Stripped down, converted to UTF-8 and test cases added + * + * Owen Taylor, 13 December 2002; + */ + +/* + * UTF-8 and GLib stuff removed for use in other code on Windows only + * using system codepage filenames, i.e. multi-byte strings. + * + * Tor Lillqvist 2009-12-01 + */ + +#include <stdlib.h> +#include <wchar.h> +#include <mbstring.h> + +#define IS_DIR_SEPARATOR(c) ((c)=='/' || (c)=='\\') + +static wchar_t +get_char (const char **str) +{ + wchar_t c; + int nbytes; + + nbytes = mbtowc (&c, *str, MB_CUR_MAX); + + if (nbytes > 0) + *str += nbytes; + else + { + /* Just skip ahead a byte at a time on errors... */ + (*str)++; + c = 0; + } + + c = towlower (c); + + return c; +} + +static const char * +strdirsep (const char *p) +{ + const char *slash = (const char *) _mbschr ((const unsigned char *) p, '/'); + const char *backslash = (const char *) _mbschr ((const unsigned char *) p, '\\'); + + if (slash == NULL || + (backslash != NULL && backslash < slash)) + return backslash; + + return slash; +} + +/* Match STRING against the filename pattern PATTERN, returning zero if + it matches, nonzero if not. */ + +/* Match STRING against the filename pattern PATTERN, returning zero if + * it matches, nonzero if not. + * + * This is special-cased as if this combinations of flags: + * + * FNM_FILE_NAME - always set + * FNM_LEADING_DIR - never set + * FNM_CASEFOLD - always set as this is for Windows + */ + +#define FNM_CASEFOLD 0 + +static int +fnmatch_intern (const char *pattern, + const char *string, + int component_start, + int no_leading_period) +{ + const char *p = pattern, *n = string; + + while (*p) + { + const char *last_n = n; + + wchar_t c = get_char (&p); + wchar_t nc = get_char (&n); + + switch (c) + { + case '?': + if (nc == '\0') + return 0; + else if (IS_DIR_SEPARATOR (nc)) + return 0; + else if (nc == '.' && component_start && no_leading_period) + return 0; + break; + case '*': + if (nc == '.' && component_start && no_leading_period) + return 0; + + { + const char *last_p = p; + + for (last_p = p, c = get_char (&p); + c == '?' || c == '*'; + last_p = p, c = get_char (&p)) + { + if (c == '?') + { + if (nc == '\0') + return 0; + else if (IS_DIR_SEPARATOR(nc)) + return 0; + else + { + last_n = n; nc = get_char (&n); + } + } + } + + /* If the pattern ends with wildcards, we have a + * guaranteed match unless there is a dir separator + * in the remainder of the string. + */ + if (c == '\0') + { + if (strdirsep (last_n) != NULL) + return 0; + else + return 1; + } + + for (p = last_p; nc != '\0';) + { + if ((c == '[' || nc == c) && + fnmatch_intern (p, last_n, component_start, no_leading_period)) + return 1; + + component_start = IS_DIR_SEPARATOR (nc); + last_n = n; + nc = get_char (&n); + } + + return 0; + } + + case '[': + { + /* Nonzero if the sense of the character class is inverted. */ + int not; + + if (nc == '\0' || IS_DIR_SEPARATOR (nc)) + return 0; + + if (nc == '.' && component_start && no_leading_period) + return 0; + + not = (*p == '!' || *p == '^'); + if (not) + ++p; + + c = get_char (&p); + for (;;) + { + register wchar_t cstart = c, cend = c; + if (c == '\0') + /* [ (unterminated) loses. */ + return 0; + + c = get_char (&p); + + if (c == '-' && *p != ']') + { + cend = get_char (&p); + if (cend == '\0') + return 0; + + c = get_char (&p); + } + + if (nc >= cstart && nc <= cend) + goto matched; + + if (c == ']') + break; + } + if (!not) + return 0; + break; + + matched:; + /* Skip the rest of the [...] that already matched. */ + /* XXX 1003.2d11 is unclear if was_escaped is right. */ + while (c != ']') + { + if (c == '\0') + /* [... (unterminated) loses. */ + return 0; + + c = get_char (&p); + } + if (not) + return 0; + } + break; + + case '/': + case '\\': + if (!IS_DIR_SEPARATOR (nc)) + return 0; + break; + + default: + if (c != nc) + return 0; + } + + component_start = IS_DIR_SEPARATOR (nc); + } + + if (*n == '\0') + return 1; + + return 0; +} + +static int +fnmatch (const char *pattern, + const char *string, + int no_leading_period) +{ + return fnmatch_intern (pattern, string, 1, no_leading_period); +} + +#ifdef FNMATCH_TEST_CASES + +#include <stdio.h> + +#define TEST(pat, str, no_leading_period, result) \ + do { \ + int rc = fnmatch ((pat), (str), (no_leading_period)); \ + if (rc != result) \ + fprintf (stderr, "Wrong result from fnmatch (\"%s\", \"%s\", %d): %d, should be %d\n", \ + (pat), (str), (no_leading_period), rc, result); \ + } while (0) + +int main (int argc, char **argv) +{ + TEST ("[a-]", "-", 1, 1); + + TEST ("a", "a", 1, 1); + TEST ("a", "b", 1, 0); + + TEST ("a", "A", 1, 1); + TEST ("A", "a", 1, 1); + + /* Test what ? matches */ + TEST ("?", "a", 1, 1); + TEST ("?", ".", 1, 0); + TEST ("a?", "a.", 1, 1); + TEST ("a/?", "a/b", 1, 1); + TEST ("a\\?", "a\\b", 1, 1); + TEST ("a/?", "a\\b", 1, 1); + TEST ("a\\?", "a/b", 1, 1); + TEST ("a/?", "a/.", 1, 0); + TEST ("a\\?", "a\\.", 1, 0); + TEST ("a\\?", "a/.", 1, 0); + TEST ("a/?", "a\\.", 1, 0); + TEST ("?", "/", 1, 0); + TEST ("?", "\\", 1, 0); + + /* Test what * matches */ + TEST ("*", "a", 1, 1); + TEST ("*", ".", 1, 0); + TEST ("a*", "a.", 1, 1); + TEST ("a/*", "a/b", 1, 1); + TEST ("a\\*", "a\\b", 1, 1); + TEST ("a\\*", "a/b", 1, 1); + TEST ("a/*", "a\\b", 1, 1); + TEST ("a/*", "a/.", 1, 0); + TEST ("a\\*", "a\\.", 1, 0); + TEST ("a\\*", "a/.", 1, 0); + TEST ("a/*", "a\\.", 1, 0); + TEST ("*", "/", 1, 0); + TEST ("*", "\\", 1, 0); + + /* Range tests */ + TEST ("[ab]", "a", 1, 1); + TEST ("[AB]", "a", 1, 1); + TEST ("[ab]", "A", 1, 1); + TEST ("[ab]", "c", 1, 0); + TEST ("[^ab]", "a", 1, 0); + TEST ("[^AB]", "a", 1, 0); + TEST ("[^ab]", "A", 1, 0); + TEST ("[!ab]", "a", 1, 0); + TEST ("[^ab]", "c", 1, 1); + TEST ("[!ab]", "c", 1, 1); + TEST ("[a-c]", "b", 1, 1); + TEST ("[a-c]", "B", 1, 1); + TEST ("[A-C]", "b", 1, 1); + TEST ("[a-c]", "d", 1, 0); + TEST ("[a-]", "-", 1, 1); + TEST ("[]]", "]", 1, 1); + TEST ("[^]]", "a", 1, 1); + TEST ("[!]]", "a", 1, 1); + + /* Various unclosed ranges */ + TEST ("[ab", "a", 1, 0); + TEST ("[a-", "a", 1, 0); + TEST ("[ab", "c", 1, 0); + TEST ("[a-", "c", 1, 0); + TEST ("[^]", "a", 1, 0); + + /* Ranges and special no-wildcard matches */ + TEST ("[.]", ".", 1, 0); + TEST ("a[.]", "a.", 1, 1); + TEST ("a/[.]", "a/.", 1, 0); + TEST ("a\\[.]", "a\\.", 1, 0); + TEST ("a/[.]", "a\\.", 1, 0); + TEST ("[/]", "/", 1, 0); + TEST ("[/]", "\\", 1, 0); + TEST ("[^/]", "a", 1, 1); + + /* Basic tests of * (and combinations of * and ?) */ + TEST ("a*b", "ab", 1, 1); + TEST ("a*B", "Ab", 1, 1); + TEST ("A*b", "aB", 1, 1); + TEST ("a*b", "axb", 1, 1); + TEST ("a*b", "axxb", 1, 1); + TEST ("a*b", "axXB", 1, 1); + TEST ("a**b", "ab", 1, 1); + TEST ("a**b", "axb", 1, 1); + TEST ("a**b", "axxb", 1, 1); + TEST ("a*?*b", "ab", 1, 0); + TEST ("a*?*b", "axb", 1, 1); + TEST ("a*?*b", "axxb", 1, 1); + + /* Test of *[range] */ + TEST ("a*[cd]", "ac", 1, 1); + TEST ("a*[cd]", "axc", 1, 1); + TEST ("a*[cd]", "axx", 1, 0); + + TEST ("a/[.]", "a/.", 1, 0); + TEST ("a\\[.]", "a\\.", 1, 0); + TEST ("a\\[.]", "a/.", 1, 0); + TEST ("a/[.]", "a\\.", 1, 0); + TEST ("a*[.]", "a/.", 1, 0); + TEST ("a*[.]", "a\\.", 1, 0); + + return 0; +} + +#endif /* FNMATCH_TEST_CASES */ + +static const char * +strchrnul (const char *s, int c) +{ + const char *match = strchr(s, c); + if (match != NULL) + return match; + return s + strlen (s); +} + +static const char * +strcasestr (const char *haystack, const char *needle) +{ + char *h = strdup (haystack); + char *n = strdup (needle); + const char *retval; + char *r; + + _strlwr (h); + _strlwr (n); + r = strstr (h, n); + if (r == NULL) + retval = NULL; + else + retval = haystack + (r - h); + free (h); + free (n); + + return retval; +} + extern unsigned int compress_buf (const unsigned char *in, unsigned int in_len, unsigned char *out, unsigned int out_len); extern unsigned int unchecked_decompress_buf (const unsigned char *in, --- src/repopage.c +++ src/repopage.c @@ -9,19 +9,32 @@ #include <unistd.h> #include <assert.h> #include <time.h> +#include <stdint.h> #include "repo.h" #include "repopage.h" #define BLOCK_SIZE (65536*1) #if BLOCK_SIZE <= 65536 -typedef __uint16_t Ref; +typedef uint16_t Ref; #else -typedef __uint32_t Ref; +typedef uint32_t Ref; #endif +static ssize_t +pread(int fd, void *buf, size_t count, off_t offset) +{ + ssize_t nbytes; + off_t oldpos = lseek (fd, SEEK_SET, offset); + if (oldpos == -1) + return -1; + nbytes = read (fd, buf, count); + lseek (fd, SEEK_SET, oldpos); + return nbytes; +} + /* The format is tailored for fast decompression (i.e. only byte based), and skewed to ASCII content (highest bit often not set): --- src/sha1.c +++ src/sha1.c @@ -9,9 +9,11 @@ #include <stdio.h> #include <string.h> -#include <endian.h> #include "sha1.h" +#define __BIG_ENDIAN 'B' +#define __LITTLE_ENDIAN 'l' +#define __BYTE_ORDER __LITTLE_ENDIAN static void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]); --- src/sha2.c +++ src/sha2.c @@ -9,14 +9,14 @@ #include <string.h> /* memcpy()/memset() or bcopy()/bzero() */ /* #include <assert.h> */ /* assert() */ #include <stdio.h> -#include <sysexits.h> -#include <sys/uio.h> #include <unistd.h> #include <inttypes.h> -#include <endian.h> #include "sha2.h" +#define __BIG_ENDIAN 'B' +#define __LITTLE_ENDIAN 'l' +#define __BYTE_ORDER __LITTLE_ENDIAN /* * ASSERT NOTE: --- src/util.c +++ src/util.c @@ -98,6 +98,202 @@ return r - subtract; } +#define I_AM_QSORT_R + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)qsort.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +#ifdef I_AM_QSORT_R +typedef int cmp_t(void *, const void *, const void *); +#else +typedef int cmp_t(const void *, const void *); +#endif +static inline char *med3(char *, char *, char *, cmp_t *, void *); +static inline void swapfunc(char *, char *, int, int); + +#define min(a, b) (a) < (b) ? a : b + +/* + * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". + */ +#define swapcode(TYPE, parmi, parmj, n) { \ + long i = (n) / sizeof (TYPE); \ + TYPE *pi = (TYPE *) (parmi); \ + TYPE *pj = (TYPE *) (parmj); \ + do { \ + TYPE t = *pi; \ + *pi++ = *pj; \ + *pj++ = t; \ + } while (--i > 0); \ +} + +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ + es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; + +static inline void +swapfunc(a, b, n, swaptype) + char *a, *b; + int n, swaptype; +{ + if(swaptype <= 1) + swapcode(long, a, b, n) + else + swapcode(char, a, b, n) +} + +#define swap(a, b) \ + if (swaptype == 0) { \ + long t = *(long *)(a); \ + *(long *)(a) = *(long *)(b); \ + *(long *)(b) = t; \ + } else \ + swapfunc(a, b, es, swaptype) + +#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) + +#ifdef I_AM_QSORT_R +#define CMP(t, x, y) (cmp((t), (x), (y))) +#else +#define CMP(t, x, y) (cmp((x), (y))) +#endif + +static inline char * +med3(char *a, char *b, char *c, cmp_t *cmp, void *thunk +#ifndef I_AM_QSORT_R +__unused +#endif +) +{ + return CMP(thunk, a, b) < 0 ? + (CMP(thunk, b, c) < 0 ? b : (CMP(thunk, a, c) < 0 ? c : a )) + :(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c )); +} + +#ifdef I_AM_QSORT_R +static void +qsort_r(void *a, size_t n, size_t es, cmp_t *cmp, void *thunk) +#else +#define thunk NULL +void +qsort(void *a, size_t n, size_t es, cmp_t *cmp) +#endif +{ + char *pa, *pb, *pc, *pd, *pl, *pm, *pn; + size_t d, r; + int cmp_result; + int swaptype, swap_cnt; + +loop: SWAPINIT(a, es); + swap_cnt = 0; + if (n < 7) { + for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) + for (pl = pm; + pl > (char *)a && CMP(thunk, pl - es, pl) > 0; + pl -= es) + swap(pl, pl - es); + return; + } + pm = (char *)a + (n / 2) * es; + if (n > 7) { + pl = a; + pn = (char *)a + (n - 1) * es; + if (n > 40) { + d = (n / 8) * es; + pl = med3(pl, pl + d, pl + 2 * d, cmp, thunk); + pm = med3(pm - d, pm, pm + d, cmp, thunk); + pn = med3(pn - 2 * d, pn - d, pn, cmp, thunk); + } + pm = med3(pl, pm, pn, cmp, thunk); + } + swap(a, pm); + pa = pb = (char *)a + es; + + pc = pd = (char *)a + (n - 1) * es; + for (;;) { + while (pb <= pc && (cmp_result = CMP(thunk, pb, a)) <= 0) { + if (cmp_result == 0) { + swap_cnt = 1; + swap(pa, pb); + pa += es; + } + pb += es; + } + while (pb <= pc && (cmp_result = CMP(thunk, pc, a)) >= 0) { + if (cmp_result == 0) { + swap_cnt = 1; + swap(pc, pd); + pd -= es; + } + pc -= es; + } + if (pb > pc) + break; + swap(pb, pc); + swap_cnt = 1; + pb += es; + pc -= es; + } + if (swap_cnt == 0) { /* Switch to insertion sort */ + for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) + for (pl = pm; + pl > (char *)a && CMP(thunk, pl - es, pl) > 0; + pl -= es) + swap(pl, pl - es); + return; + } + + pn = (char *)a + n * es; + r = min(pa - (char *)a, pb - pa); + vecswap(a, pb - r, r); + r = min(pd - pc, pn - pd - es); + vecswap(pb, pn - r, r); + if ((r = pb - pa) > es) +#ifdef I_AM_QSORT_R + qsort_r(a, r / es, es, cmp, thunk); +#else + qsort(a, r / es, es, cmp); +#endif + if ((r = pd - pc) > es) { + /* Iterate rather than recurse to save stack space */ + a = pn - r; + n = r / es; + goto loop; + } +/* qsort(pn - r, r / es, es, cmp);*/ +} + /* bsd's qsort_r has different arguments, so we define our own version in case we need to do some clever mapping --- ext/repo_rpmdb.c +++ ext/repo_rpmdb.c @@ -31,13 +31,11 @@ #include <rpm/rpmdb.h> #ifndef DB_CREATE -# ifdef FEDORA -# include <db4/db.h> +# include <db.h> -# else -# include <rpm/db.h> -# endif #endif +#define S_ISLNK(m) 0 + #include "pool.h" #include "repo.h" #include "hash.h" @@ -2478,6 +2478,8 @@ } +#ifndef _WIN32 + static char * r64dec1(char *p, unsigned int *vp, int *eofp) { @@ -3058,3 +3058,5 @@ if (!(flags & REPO_NO_INTERNALIZE)) repodata_internalize(data); } + +#endif --- tools/CMakeLists.txt +++ tools/CMakeLists.txt @@ -5,57 +5,39 @@ ADD_LIBRARY(toolstuff STATIC common_write.c) ADD_EXECUTABLE(rpmdb2solv rpmdb2solv.c) -TARGET_LINK_LIBRARIES(rpmdb2solv toolstuff satsolverext satsolver ${RPMDB_LIBRARY} ${EXPAT_LIBRARY}) +TARGET_LINK_LIBRARIES(rpmdb2solv toolstuff satsolverext satsolver ${RPMDB_LIBRARY} ${EXPAT_LIBRARY} -ldb -lgnurx) ADD_EXECUTABLE(rpms2solv rpms2solv.c) -TARGET_LINK_LIBRARIES(rpms2solv toolstuff satsolverext satsolver ${RPMDB_LIBRARY}) +TARGET_LINK_LIBRARIES(rpms2solv toolstuff satsolverext satsolver ${RPMDB_LIBRARY} -ldb -lgnurx) -ADD_EXECUTABLE(rpmmd2solv rpmmd2solv.c) -TARGET_LINK_LIBRARIES(rpmmd2solv toolstuff satsolverext satsolver ${EXPAT_LIBRARY} ${ZLIB_LIBRARY}) - ADD_EXECUTABLE(helix2solv helix2solv.c) -TARGET_LINK_LIBRARIES(helix2solv toolstuff satsolverext satsolver ${EXPAT_LIBRARY}) +TARGET_LINK_LIBRARIES(helix2solv toolstuff satsolverext satsolver ${EXPAT_LIBRARY} -lgnurx) -ADD_EXECUTABLE(susetags2solv susetags2solv.c) -TARGET_LINK_LIBRARIES(susetags2solv toolstuff satsolverext satsolver ${ZLIB_LIBRARY}) - ADD_EXECUTABLE(updateinfoxml2solv updateinfoxml2solv.c) -TARGET_LINK_LIBRARIES(updateinfoxml2solv toolstuff satsolverext satsolver ${EXPAT_LIBRARY}) +TARGET_LINK_LIBRARIES(updateinfoxml2solv toolstuff satsolverext satsolver ${EXPAT_LIBRARY} -lgnurx) ADD_EXECUTABLE(deltainfoxml2solv deltainfoxml2solv.c) -TARGET_LINK_LIBRARIES(deltainfoxml2solv toolstuff satsolverext satsolver ${EXPAT_LIBRARY}) +TARGET_LINK_LIBRARIES(deltainfoxml2solv toolstuff satsolverext satsolver ${EXPAT_LIBRARY} -lgnurx) ADD_EXECUTABLE(repomdxml2solv repomdxml2solv.c) -TARGET_LINK_LIBRARIES(repomdxml2solv toolstuff satsolverext satsolver ${EXPAT_LIBRARY}) +TARGET_LINK_LIBRARIES(repomdxml2solv toolstuff satsolverext satsolver ${EXPAT_LIBRARY} -ldb -lgnurx) -ADD_EXECUTABLE(installcheck installcheck.c) -TARGET_LINK_LIBRARIES(installcheck satsolverext satsolver ${EXPAT_LIBRARY} ${ZLIB_LIBRARY}) - -ADD_EXECUTABLE(patchcheck patchcheck.c) -TARGET_LINK_LIBRARIES(patchcheck satsolverext satsolver ${EXPAT_LIBRARY} ${ZLIB_LIBRARY}) - ADD_EXECUTABLE(dumpsolv dumpsolv.c ) -TARGET_LINK_LIBRARIES(dumpsolv satsolver) +TARGET_LINK_LIBRARIES(dumpsolv satsolver -lgnurx) ADD_EXECUTABLE(mergesolv mergesolv.c ) -TARGET_LINK_LIBRARIES(mergesolv toolstuff satsolverext satsolver) +TARGET_LINK_LIBRARIES(mergesolv toolstuff satsolverext satsolver -lgnurx) ADD_EXECUTABLE(findfileconflicts findfileconflicts.c) -TARGET_LINK_LIBRARIES(findfileconflicts satsolverext satsolver ${RPMDB_LIBRARY}) +TARGET_LINK_LIBRARIES(findfileconflicts satsolverext satsolver ${RPMDB_LIBRARY} -ldb -lgnurx) install(TARGETS mergesolv dumpsolv - susetags2solv helix2solv - rpmmd2solv rpmdb2solv rpms2solv updateinfoxml2solv deltainfoxml2solv repomdxml2solv DESTINATION ${BIN_INSTALL_DIR}) - -install(PROGRAMS - repo2solv.sh - DESTINATION ${BIN_INSTALL_DIR}) --- tools/common_write.c +++ tools/common_write.c @@ -252,7 +252,7 @@ for (i = 0; i < nlanguages; i++) { sprintf(fn, "%s.%s.solv", basename, languages[i]); - if (!(fp = fopen(fn, "w"))) + if (!(fp = fopen(fn, "wb"))) { perror(fn); exit(1); @@ -265,7 +265,7 @@ if (has_DU) { sprintf(fn, "%s.DU.solv", basename); - if (!(fp = fopen(fn, "w"))) + if (!(fp = fopen(fn, "wb"))) { perror(fn); exit(1); @@ -278,18 +278,18 @@ if (has_FL) { sprintf(fn, "%s.FL.solv", basename); - if (!(fp = fopen(fn, "w"))) + if (!(fp = fopen(fn, "wb"))) { perror(fn); exit(1); } write_info(repo, fp, keyfilter_FL, 0, info, fn); fclose(fp); kd.haveexternal = 1; } /* write everything else */ sprintf(fn, "%s.solv", basename); - if (!(fp = fopen(fn, "w"))) + if (!(fp = fopen(fn, "wb"))) { perror(fn); exit(1); @@ -308,7 +308,7 @@ if (attrname) { test_separate = 1; - FILE *fp = fopen(attrname, "w"); + FILE *fp = fopen(attrname, "wb"); write_info(repo, fp, keyfilter_attr, 0, info, attrname); fclose(fp); kd.haveexternal = 1; --- tools/dumpsolv.c +++ tools/dumpsolv.c @@ -187,7 +187,7 @@ if (!location || !with_attr) return 0; fprintf (stderr, "Loading SOLV file %s\n", location); - fp = fopen (location, "r"); + fp = fopen (location, "rb"); if (!fp) { perror(location); @@ -269,7 +269,7 @@ } else { - if (freopen (argv[0], "r", stdin) == 0) + if (freopen (argv[0], "rb", stdin) == 0) { perror(argv[0]); exit(1); --- tools/rpmdb2solv.c +++ tools/rpmdb2solv.c @@ -96,7 +96,7 @@ usage(1); } - if (outfile && !freopen(outfile, "w", stdout)) + if (outfile && !freopen(outfile, "wb", stdout)) { perror(outfile); exit(1); @@ -113,7 +113,7 @@ if (refname) { FILE *fp; - if ((fp = fopen(refname, "r")) == NULL) + if ((fp = fopen(refname, "rb")) == NULL) { perror(refname); } --- applayer/tests/CMakeLists.txt +++ applayer/tests/CMakeLists.txt @@ -7,4 +7,4 @@ SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror" ) ADD_EXECUTABLE( applayer applayer.c ) -TARGET_LINK_LIBRARIES( applayer appsatsolver satsolver ) +TARGET_LINK_LIBRARIES( applayer appsatsolver satsolver -lgnurx)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor