yodl: FTBFS on hurd-i386 (for review)

2012-08-25 Thread Svante Signell
Source: yodl
Version: 3.00.0-6
Severity: Important
Usertags: hurd
User: debian-hurd@lists.debian.org

Hi, the attached patch enables yodl to build on GNU/Hurd again. The
patch includes usage of features specified by POSIX 2008! 

Thanks!

To the list: OK to submit?

diff -ur yodl-3.00.0/src/lexer/lchdir.c yodl-3.00.0.new/src/lexer/lchdir.c
--- yodl-3.00.0/src/lexer/lchdir.c	2010-11-08 17:09:36.0 +0100
+++ yodl-3.00.0.new/src/lexer/lchdir.c	2012-08-22 15:52:06.0 +0200
@@ -7,12 +7,22 @@
 {
 // fprintf(stderr, "CHANGING WD\n");
  
+#if (_POSIX_VERSION >= 200809L)
+char *resolved = NULL;
+bool cdOK = false;
+resolved =  realpath(media_filename(lp->d_media_ptr), NULL);
+if (resolved != NULL) cdOK = true;
+#else
 char resolved[PATH_MAX];
 bool cdOK =  realpath(media_filename(lp->d_media_ptr), resolved) != NULL;
+#endif
 if (cdOK)
 {
 *(strrchr(resolved, '/') + 1) = 0;
 cdOK = chdir(resolved) == 0;
+#if (_POSIX_VERSION >= 200809L)
+free(resolved);
+#endif
 }
 if (!cdOK)
 {
diff -ur yodl-3.00.0/src/new/newgetcwd.c yodl-3.00.0.new/src/new/newgetcwd.c
--- yodl-3.00.0/src/new/newgetcwd.c	2010-11-08 15:50:47.0 +0100
+++ yodl-3.00.0.new/src/new/newgetcwd.c	2012-08-24 15:02:44.0 +0200
@@ -2,11 +2,18 @@
 
 char *new_getcwd()
 {
+#if (_POSIX_VERSION >= 200809L)
+char *cwd =  NULL;
+
+cwd = getcwd(NULL, 0);
+if (cwd == NULL && message_show(MSG_ALERT))
+message("Can't determine current working directory");
+#else
 char *cwd =  n_malloc(PATH_MAX + 1);
 
 if (!getcwd(cwd, PATH_MAX) && message_show(MSG_ALERT))
 message("Can't determine current working directory");
-
+#endif
 size_t length = strlen(cwd);
 if (cwd[length - 1] != '/')
 {


Re: yodl: FTBFS on hurd-i386 (for review)

2012-08-25 Thread Samuel Thibault
Svante Signell, le Sat 25 Aug 2012 10:34:34 +0200, a écrit :
> To the list: OK to submit?

It seems ok.

Samuel


-- 
To UNSUBSCRIBE, email to debian-hurd-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/20120825085303.gy7...@type.wlan.youpi.perso.aquilenet.fr



Bug#685858: yodl: FTBFS on hurd-i386

2012-08-25 Thread Svante Signell
Source: yodl
Version: 3.00.0-6
Severity: Important
Usertags: hurd
User: debian-hurd@lists.debian.org

Hi, the attached patch enables yodl to build on GNU/Hurd again. The
patch includes usage of features specified by POSIX 2008! 

Thanks!



diff -ur yodl-3.00.0/src/lexer/lchdir.c yodl-3.00.0.new/src/lexer/lchdir.c
--- yodl-3.00.0/src/lexer/lchdir.c	2010-11-08 17:09:36.0 +0100
+++ yodl-3.00.0.new/src/lexer/lchdir.c	2012-08-22 15:52:06.0 +0200
@@ -7,12 +7,22 @@
 {
 // fprintf(stderr, "CHANGING WD\n");
  
+#if (_POSIX_VERSION >= 200809L)
+char *resolved = NULL;
+bool cdOK = false;
+resolved =  realpath(media_filename(lp->d_media_ptr), NULL);
+if (resolved != NULL) cdOK = true;
+#else
 char resolved[PATH_MAX];
 bool cdOK =  realpath(media_filename(lp->d_media_ptr), resolved) != NULL;
+#endif
 if (cdOK)
 {
 *(strrchr(resolved, '/') + 1) = 0;
 cdOK = chdir(resolved) == 0;
+#if (_POSIX_VERSION >= 200809L)
+free(resolved);
+#endif
 }
 if (!cdOK)
 {
diff -ur yodl-3.00.0/src/new/newgetcwd.c yodl-3.00.0.new/src/new/newgetcwd.c
--- yodl-3.00.0/src/new/newgetcwd.c	2010-11-08 15:50:47.0 +0100
+++ yodl-3.00.0.new/src/new/newgetcwd.c	2012-08-24 15:02:44.0 +0200
@@ -2,11 +2,18 @@
 
 char *new_getcwd()
 {
+#if (_POSIX_VERSION >= 200809L)
+char *cwd =  NULL;
+
+cwd = getcwd(NULL, 0);
+if (cwd == NULL && message_show(MSG_ALERT))
+message("Can't determine current working directory");
+#else
 char *cwd =  n_malloc(PATH_MAX + 1);
 
 if (!getcwd(cwd, PATH_MAX) && message_show(MSG_ALERT))
 message("Can't determine current working directory");
-
+#endif
 size_t length = strlen(cwd);
 if (cwd[length - 1] != '/')
 {


Re: libpst: FTBFS on hurd-i386 (for review)

2012-08-25 Thread Svante Signell
On Sun, 2012-07-29 at 05:23 +0200, Guillem Jover wrote:
> Hi!
> 
> On Wed, 2012-06-27 at 20:43:15 +0200, Svante Signell wrote:
> > Source: libpst
> > Version: 0.6.54-3

Version: 0.6.53-4

> > Severity: important
> > Tags: patch
> > User: debian-hurd@lists.debian.org
> > Usertags: hurd
> 
> > Hi, libpst does not build for GNU/Hurd due to PATH_MAX issues. Attached
> > are three small patches to enable a successful build.
> 
> I only see two, is there one missing?

You are right, the first patch consists of two parts I combined into
one.

> > libpst.c.patch checks for the availability of get_current_dir_name and
> > user that function if available.
> > pst2dii.cpp.in.patch avoids usage of PATH_MAX by dynamically allocating
> > string buffers as needed. pst2dii will be built if  imagemagick
> > (providing /usr/bin/convert)  and libgd2-noxpm-dev | libgd2-xpm-dev
> > (providing gd.h and libgd) are installed, so a dependency on these needs
> > to be added to debian/rules if building that executable.
> 
> I'm guessing you mean debian/control (maybe some flags need to be
> enabled in debian/rules too though).

debian/control of course!

> > For patch2:
> > Q1) I'm not sure if x=realloc(x,len) is OK. Better solution?
> 
> It's ok, but see above.

I assume you mean below?

> > Q2) Should I include an updated debian/rules too (or remove patch 2
> > completely)?
> 
> If patch2 is pst2dii.cpp.in.patch, then I think it's good to include
> that and the other needed changes.

In version 0.6.53-4 the dependency is added already to the control file
so pst2dii is built.

> > --- a/src/libpst.c  2011-12-25 00:19:11.0 +0100
> > +++ b/src/libpst.c  2012-06-27 09:59:41.0 +0200
> > @@ -289,6 +289,17 @@
> >  static char*pst_wide_to_single(char *wt, size_t size);
> >  
> >  
> > +char *pst_getcwd(void) {
> 
> If the function is not being used anywhere else, just make it static.
> Otherwise this can produce warnings as there will be a missing prototype
> in the headers.

Done!

> > --- a/src/pst2dii.cpp.in2011-12-25 00:19:11.0 +0100
> > +++ b/src/pst2dii.cpp.in2012-06-27 11:08:02.0 +0200
> > @@ -344,8 +344,10 @@
> >  {
> >  if (png_open) {
> >  png_open = false;
> > -char fn[PATH_MAX];
> > -snprintf(fn, sizeof(fn), "page%d.png", ++page_sequence);
> > +char *fn = NULL;
> > +   int len = 4 + 4 + 4;
> > +   fn = (char*)pst_malloc(len) + 1;
> 
> Switch these two lines from tabs to spaces. I think you want
> “pst_malloc(len + 1)” instead of “pst_malloc(len) + 1”. Also why only 4
> for the decimal from page_sequence? is that delimited somewhere else?
> And you might as well assign directly to fn, instead of first
> initializing it to NULL and immediately overwriting it.

Done. Yes the 4 bytes should be increased to 11 to hold the longest
string for an int -2^31.

> > +snprintf(fn, len, "page%d.png", ++page_sequence);
> >  FILE *pngout = fopen(fn, "wb");
> >  if (pngout) {
> >  gdImagePng(image, pngout);
> > @@ -354,6 +356,7 @@
> >  gdImageDestroy(image); // free memory
> >  png_names.push_back(fn);
> >  conversion += string(" ") + fn;
> > +   free(fn);
>
> Switch from tab to spaces.

Done!

> >  }
> >  }
> >  
> > @@ -366,8 +369,12 @@
> >  conversion= string(convert);
> >  png_names.clear();
> >  open_png();
> > -snprintf(pdf_name, sizeof(pdf_name), "dii%06d", ++email_sequence);
> > +int len = 3 + 7;
> > +pdf_name = (char*)pst_malloc(len) + 1;
> 
> pst_malloc(len + 1)

Yes, of course.

> > +snprintf(pdf_name, len, "dii%06d", ++email_sequence);
> >  fprintf(dii_file, "\n@T %s\n", pdf_name);
> > +len = strlen(output_directory) + 3 + 7;
> 
> I think you mean something like:
> 
> len = strlen(output_directory) + 1 + 3 + 6 + 4;
> 
> > +pdf_name = (char *)pst_realloc(pdf_name,len) + 1;
> 
> Yeah, I guess you could just allocate once, but to avoid confusion
> you'd better add a comment mentioning why the bigger size, etc.

Used this version.

New patch attached.
diff -ur libpst-0.6.54/configure.in libpst-0.6.54.new/configure.in
--- libpst-0.6.54/configure.in	2012-08-25 18:59:16.0 +0200
+++ libpst-0.6.54.new/configure.in	2012-06-27 10:05:54.0 +0200
@@ -185,7 +185,7 @@
 fi
 AC_FUNC_STRFTIME
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([chdir getcwd memchr memmove memset regcomp strcasecmp strncasecmp strchr strdup strerror strpbrk strrchr strstr strtol])
+AC_CHECK_FUNCS([chdir getcwd memchr memmove memset regcomp strcasecmp strncasecmp strchr strdup strerror strpbrk strrchr strstr strtol get_current_dir_name])
 AM_ICONV
 if test "$am_cv_func_iconv" != "yes"; then
 AC_MSG_ERROR([libpst requires iconv which is missing])
diff -ur libpst-0.6.54/src/libpst.c libpst-0.6.54.new/src/libpst.c
--- libpst-0.6.54/src/libpst.c	2011-12-25 00:19:11.0 +0100
+++ libpst-0.6.54.new/src/libpst.c	2012-08-25 19:07:30.0 +0200
@@ -289,6 +289,17 @@
 sta