public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* lftp 4.7.2 build fails in Cygwin
@ 2016-05-26 18:21 Andrew Schulman
  2016-05-27 16:33 ` Hans-Bernhard Bröker
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Schulman @ 2016-05-26 18:21 UTC (permalink / raw)
  To: cygwin

Cygwin 2.5.1 x86_64
g++ 5.3.0

In Cygwin, build of lftp 4.7.2 fails in two places:

(1)

/home/andrex/dev/cygwin/lftp/lftp-4.7.2-1.x86_64/src/lftp-4.7.2/src/xmalloc.h:31:38:
error: expected ';', ',' or ')' before '=' token
 char *xstrdup(const char *s,int spare=0);
                                      ^

g++ seems not to like the default value 'spare=0' in the function declaration.
The function definition (in xmalloc.cc) doesn't include the default value:

char *xstrdup(const char *s,int spare)
{
   if(!s)
      return (char*)xmalloc(spare);
#ifdef MEM_DEBUG
   printf("xstrdup \"%s\"\n",s);
#endif
   size_t len=strlen(s)+1;
   char *mem=(char*)xmalloc(len+spare);
   memcpy(mem,s,len);
   return mem;
}

I tried removing the default value from the declaration in xmalloc.h, or adding
it into the definition in xmalloc.cc.  But the build still failed either way.

Finally I just removed the 'spare' parameter from the function, since a look
through the source code shows that it's never used.  The patch for that is
below.  

But I don't know why Cygwin's g++ (5.3.0) chokes on this. The same construction
was present in 4.6.5, which compiled fine in Cygwin.

(2)

/home/andrex/dev/cygwin/lftp/lftp-4.7.2-1.x86_64/src/lftp-4.7.2/src/xmalloc.h:32:21:
error: expected ';', ',' or ')' before '&' token
 char *xstrset(char *&mem,const char *s);
                     ^
/home/andrex/dev/cygwin/lftp/lftp-4.7.2-1.x86_64/src/lftp-4.7.2/src/xmalloc.h:33:21:
error: expected ';', ',' or ')' before '&' token
 char *xstrset(char *&mem,const char *s,size_t n);
                     ^

Here g++ doesn't like *&mem. Again I don't know why g++ chokes on this, since
the same construction was present in 4.6.5, which compiled fine in Cygwin.

Does anyone know the right solution for these problems? Some compiler switches
I'm missing?

Thanks,
Andrew

===

diff -urN lftp-4.7.1.orig/src/xmalloc.cc lftp-4.7.1/src/xmalloc.cc
--- lftp-4.7.1.orig/src/xmalloc.cc  2015-11-25 05:27:17.000000000 -0500
+++ lftp-4.7.1/src/xmalloc.cc   2016-05-03 18:09:15.709557300 -0400
@@ -83,15 +83,15 @@
    free(p);
 }

-char *xstrdup(const char *s,int spare)
+char *xstrdup(const char *s)
 {
    if(!s)
-      return (char*)xmalloc(spare);
+     return 0;
 #ifdef MEM_DEBUG
    printf("xstrdup \"%s\"\n",s);
 #endif
    size_t len=strlen(s)+1;
-   char *mem=(char*)xmalloc(len+spare);
+   char *mem=(char*)xmalloc(len);
    memcpy(mem,s,len);
    return mem;
 }
diff -urN lftp-4.7.1.orig/src/xmalloc.h lftp-4.7.1/src/xmalloc.h
--- lftp-4.7.1.orig/src/xmalloc.h   2015-11-25 05:27:18.000000000 -0500
+++ lftp-4.7.1/src/xmalloc.h    2016-05-03 18:06:28.969612500 -0400
@@ -28,7 +28,7 @@

 void *xmalloc(size_t);
 void *xrealloc(void *,size_t);
-char *xstrdup(const char *s,int spare=0);
+char *xstrdup(const char *s);
 char *xstrset(char *&mem,const char *s);
 char *xstrset(char *&mem,const char *s,size_t n);
 #define alloca_strdup(s) alloca_strdup2((s),0)


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: lftp 4.7.2 build fails in Cygwin
  2016-05-26 18:21 lftp 4.7.2 build fails in Cygwin Andrew Schulman
@ 2016-05-27 16:33 ` Hans-Bernhard Bröker
  2016-05-27 18:00   ` Andrew Schulman
  0 siblings, 1 reply; 3+ messages in thread
From: Hans-Bernhard Bröker @ 2016-05-27 16:33 UTC (permalink / raw)
  To: cygwin

Am 26.05.2016 um 19:20 schrieb Andrew Schulman:
> Cygwin 2.5.1 x86_64
> g++ 5.3.0
>
> In Cygwin, build of lftp 4.7.2 fails in two places:
>
> (1)
>
> /home/andrex/dev/cygwin/lftp/lftp-4.7.2-1.x86_64/src/lftp-4.7.2/src/xmalloc.h:31:38:
> error: expected ';', ',' or ')' before '=' token
>  char *xstrdup(const char *s,int spare=0);
>                                       ^
>
> g++ seems not to like the default value 'spare=0' in the function declaration.

I'm convinced g++ actually likes that just fine.  The problem is that 
this header is being pulled in by a plain C source file: lftp_rl.c.  But 
C does no have default arguments; those only exist in C++.

The underlying reason appearst to be that there is a conflict between 
src/History.h and /usr/include/readline/history.h.

This file wants to include readline's history.h, but "thanks" to 
Windows's harebrained handling of filename cases, gets src/History.h 
instead.  Which is a C++ header file, and new with 4.7.2.

> (2)
>
> /home/andrex/dev/cygwin/lftp/lftp-4.7.2-1.x86_64/src/lftp-4.7.2/src/xmalloc.h:32:21:
> error: expected ';', ',' or ')' before '&' token
>  char *xstrset(char *&mem,const char *s);

Same problem, same cause: that is not legal C code, so the C compiler is 
correct in rejecting it.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: lftp 4.7.2 build fails in Cygwin
  2016-05-27 16:33 ` Hans-Bernhard Bröker
@ 2016-05-27 18:00   ` Andrew Schulman
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Schulman @ 2016-05-27 18:00 UTC (permalink / raw)
  To: cygwin

> Am 26.05.2016 um 19:20 schrieb Andrew Schulman:
> > Cygwin 2.5.1 x86_64
> > g++ 5.3.0
> >
> > In Cygwin, build of lftp 4.7.2 fails in two places:
> >
> > (1)
> >
> > /home/andrex/dev/cygwin/lftp/lftp-4.7.2-1.x86_64/src/lftp-4.7.2/src/xmalloc.h:31:38:
> > error: expected ';', ',' or ')' before '=' token
> >  char *xstrdup(const char *s,int spare=0);
> >                                       ^
> >
> > g++ seems not to like the default value 'spare=0' in the function declaration.
> 
> I'm convinced g++ actually likes that just fine.  The problem is that 
> this header is being pulled in by a plain C source file: lftp_rl.c.  But 
> C does no have default arguments; those only exist in C++.
> 
> The underlying reason appearst to be that there is a conflict between 
> src/History.h and /usr/include/readline/history.h.
> 
> This file wants to include readline's history.h, but "thanks" to 
> Windows's harebrained handling of filename cases, gets src/History.h 
> instead.  Which is a C++ header file, and new with 4.7.2.

Thanks, Hans-Bernard! You nailed it. I wasn't close to figuring that out. The
patch below solves the problem.  Andrew

diff -urN lftp-4.7.2.orig/src/lftp_rl.c lftp-4.7.2/src/lftp_rl.c
--- lftp-4.7.2.orig/src/lftp_rl.c   2016-02-20 08:57:53.000000000 -0500
+++ lftp-4.7.2/src/lftp_rl.c    2016-05-27 05:23:06.893807600 -0400
@@ -20,7 +20,7 @@
 #include <config.h>
 #include <stdio.h>
 #include <readline.h>
-#include <history.h>
+#include <readline/history.h>
 #include <stdlib.h>
 #include <string.h>
 #include "lftp_rl.h"


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-27  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-26 18:21 lftp 4.7.2 build fails in Cygwin Andrew Schulman
2016-05-27 16:33 ` Hans-Bernhard Bröker
2016-05-27 18:00   ` Andrew Schulman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).