[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#622365: Fix FTBFS of tofrodos for GNU/Hurd



On Tue, 2011-04-12 at 17:59 +0200, Svante Signell wrote:
> On Tue, 2011-04-12 at 17:39 +0200, Samuel Thibault wrote:
> > Svante Signell, le Tue 12 Apr 2011 16:33:14 +0200, a écrit :
> > >  			if (verbose) {
> > >  				emsg( VERBOSE_SYMLINKSRC, filename, realfilepath );
> > >  			}
> > >  			return openandconvert( realfilepath );
> > >  		}
> > 
> > You needs to free realfilepath in that case too, so split the return
> > openandconvert() call into an openandconvert call, then free(), then
> > return.
> 
> Ok, new patch will follow shortly.

Attached! Hope the code is better now. It builds and runs OK for me.

diff -ur ./tofrodos-1.7.8.debian.1/src/config.h tofrodos-1.7.8.debian.1.new/src/config.h
--- tofrodos-1.7.8.debian.1/src/config.h	2011-04-12 19:02:08.000000000 +0200
+++ tofrodos-1.7.8.debian.1.new/src/config.h	2011-04-12 19:09:44.000000000 +0200
@@ -102,7 +102,7 @@
 #endif
 #endif
 
-#if defined(__FreeBSD__) || defined(__OpenBSD__)	/* seems to work like Linux... */
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__)	/* seems to work like Linux... */
 #if !defined(LINUX)
 #define	LINUX
 #endif
diff -ur tofrodos-1.7.8.debian.1/src/tofrodos.c tofrodos-1.7.8.debian.1.new/src/tofrodos.c
--- tofrodos-1.7.8.debian.1/src/tofrodos.c	2008-04-08 06:57:05.000000000 +0200
+++ tofrodos-1.7.8.debian.1.new/src/tofrodos.c	2011-04-12 18:33:46.000000000 +0200
@@ -14,7 +14,9 @@
 #include <stdlib.h>	/* EXIT_SUCCESS, mkstemp() in some systems */
 #include <string.h>	/* strrchr(), strlen(), strcpy(), strcat() */
 #include <sys/stat.h>	/* stat() */
-
+#ifdef __GNU__
+#include <limits.h>
+#endif
 #if defined(UNIX)
 #if defined(MAXPATHLEN_HEADER)
 #include MAXPATHLEN_HEADER
@@ -443,8 +445,12 @@
 static int openandconvert_preamble ( char * filename )
 {
 	struct stat statbuf ;
-	char		realfilepath[MAXPATHLEN+1] ;
 	int			len ;
+#ifndef __GNU__
+	char		realfilepath[MAXPATHLEN+1] ;
+#else
+	char		*realfilepath ;
+#endif
 
 	/* get the file information */
 	if (lstat( filename, &statbuf )) {
@@ -461,19 +467,36 @@
 		/* eg, #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK) */
 		/* or something like that. */
 
+#ifndef __GNU__
 		if ((len = readlink( filename, realfilepath, (sizeof(realfilepath) - 1) )) != -1) {
 			/* got to null terminate the string - there is always space because */
 			/* we passed readlink() the size of the buffer less 1. */
 			realfilepath[len] = '\0' ;
+#else
+			realfilepath = realpath (filename, NULL);
+			if ((realfilepath) != NULL) {
+#endif
 			if (verbose) {
 				emsg( VERBOSE_SYMLINKSRC, filename, realfilepath );
 			}
+#ifndef __GNU__
 			return openandconvert( realfilepath );
+#else
+			len = openandconvert( realfilepath );
+			free (realfilepath);
+			return len;
+#endif
 		}
 		emsg( EMSG_SYMLINK, filename );
+#ifdef __GNU__
+		free (realfilepath);
+#endif
 		return -1 ;
 	}
 	/* If we reach here, "filename" is not a symbolic link */
+#ifdef __GNU__
+	free (realfilepath);
+#endif
 	return openandconvert( filename );
 }
 #endif

Reply to: