Hi Alex, yes, it is the _PC_NAME_MAX issue which is only valid for pathconf().
Attached is the little patch to fix it. Since MinGW is based on gcc-4.6, C99 should be available. As the Wiki states (well, the entry is 3 years old...), printf() is the main issue. But there may be some other functions that don't behave C99 compliant. Sound not like a compiler, but a library issue. Maybe some functions have to be provided by Wget. If we just had a list of issues/functions... Regards, Tim Am Montag, 13. Mai 2013 schrieb Bykov Aleksey: > Greetings, Tim Rühsen. > Possible that i'm understood wrong, but according to > http://www.mingw.org/wiki/C99 MinGW doesn't support C99 at all. So i'm not > sure about cross-compile. > May be after implementation of C99 code it can be compiled only through > CygWin (don't remember exactly, but two years ago Wget compiled at CygWin > required on pure Windows only several libraries as dependencies. If need, > i'll try to check this at week). > > P.S. Currently Wget compiled without any problem in Windows MinGW and > resulting binary work in pure Windows without any dependencies. > > P.P.S. What "minor compile issue in url.c"? I get only error with > undefined PC_NAME_MAX (just add it to compiler flags)? > > P.P.P.S. Sorry for bad English. > > Best regards, Alex. > > > Thanks for the hint. I just installed Debians MinGW packages and it > > workedlike a charm (except a minor compile issue in url.c). > > > > For anyone who wants to try: > > $ make distclean > > $ ./configure --host=i686-w64-mingw32 --without-ssl --disable-ipv6 > > $ make > > $ wine src/wget.exe http://www.example.com > > > > I have no real Windows installation around to test wget.exe. > > But assuming, it works: Is there any need to stick at c89 code ? > > Or in other words: do we still have to support native Windows > > compilation withMSVC (couldn't these people install and use mingw) ? > > > > Regards, Tim >
From d540fd5dbd3644936a8ad1a384516abba10de268 Mon Sep 17 00:00:00 2001 From: Tim Ruehsen <tim.rueh...@gmx.de> Date: Thu, 9 May 2013 19:53:36 +0200 Subject: [PATCH 1/3] src/utils.c cleanup --- src/ChangeLog | 6 ++++++ src/utils.c | 66 ++++++++++++++++++++------------------------------------- 2 files changed, 29 insertions(+), 43 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f4fa342..84a9645 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2013-05-09 Tim Ruehsen <tim.rueh...@gmx.de> + + * utils.c: use standard string functions instead of self-written + code in acceptable(), match_tail(), suffix(), has_wildcards_p(). + Avoid some warnings in test code. + 2013-05-05 mancha <manc...@hush.com> (tiny change) * gnutls.c (ssl_connect_wget): Don't abort on non-fatal alerts diff --git a/src/utils.c b/src/utils.c index faae62e..f7baed6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -900,15 +900,14 @@ static bool in_acclist (const char *const *, const char *, bool); bool acceptable (const char *s) { - int l = strlen (s); + const char *p; if (opt.output_document && strcmp (s, opt.output_document) == 0) return true; - while (l && s[l] != '/') - --l; - if (s[l] == '/') - s += (l + 1); + if ((p = strrchr(s, '/'))) + s = p + 1; + if (opt.accepts) { if (opt.rejects) @@ -919,6 +918,7 @@ acceptable (const char *s) } else if (opt.rejects) return !in_acclist ((const char *const *)opt.rejects, s, true); + return true; } @@ -1018,29 +1018,15 @@ accdir (const char *directory) bool match_tail (const char *string, const char *tail, bool fold_case) { - int i, j; + int pos = strlen (string) - strlen(tail); - /* We want this to be fast, so we code two loops, one with - case-folding, one without. */ + if (pos < 0) + return false; /* tail is longer than string */ if (!fold_case) - { - for (i = strlen (string), j = strlen (tail); i >= 0 && j >= 0; i--, j--) - if (string[i] != tail[j]) - break; - } - else - { - for (i = strlen (string), j = strlen (tail); i >= 0 && j >= 0; i--, j--) - if (c_tolower (string[i]) != c_tolower (tail[j])) - break; - } - - /* If the tail was exhausted, the match was succesful. */ - if (j == -1) - return true; + return strcmp (string + pos, tail); else - return false; + return strcasecmp (string + pos, tail); } /* Checks whether string S matches each element of ACCEPTS. A list @@ -1089,15 +1075,12 @@ in_acclist (const char *const *accepts, const char *s, bool backward) char * suffix (const char *str) { - int i; + char *p; - for (i = strlen (str); i && str[i] != '/' && str[i] != '.'; i--) - ; + if ((p = strrchr(str, '.')) && !strchr(p + 1, '/')) + return p + 1; - if (str[i++] == '.') - return (char *)str + i; - else - return NULL; + return NULL; } /* Return true if S contains globbing wildcards (`*', `?', `[' or @@ -1106,10 +1089,7 @@ suffix (const char *str) bool has_wildcards_p (const char *s) { - for (; *s; s++) - if (*s == '*' || *s == '?' || *s == '[' || *s == ']') - return true; - return false; + return !!strpbrk(s, "*?[]"); } /* Return true if FNAME ends with a typical HTML suffix. The @@ -2553,16 +2533,16 @@ get_max_length (const char *path, int length, int name) const char * test_subdir_p() { - int i; - struct { - char *d1; - char *d2; + static struct { + const char *d1; + const char *d2; bool result; } test_array[] = { { "/somedir", "/somedir", true }, { "/somedir", "/somedir/d2", true }, { "/somedir/d1", "/somedir", false }, }; + unsigned i; for (i = 0; i < countof(test_array); ++i) { @@ -2578,10 +2558,9 @@ test_subdir_p() const char * test_dir_matches_p() { - int i; - struct { - char *dirlist[3]; - char *dir; + static struct { + const char *dirlist[3]; + const char *dir; bool result; } test_array[] = { { { "/somedir", "/someotherdir", NULL }, "somedir", true }, @@ -2600,6 +2579,7 @@ test_dir_matches_p() { { "/Tmp/has", NULL, NULL }, "/Tmp/has space", false }, { { "/Tmp/has", NULL, NULL }, "/Tmp/has,comma", false }, }; + unsigned i; for (i = 0; i < countof(test_array); ++i) { -- 1.7.10.4