[PATCH 2] Fix build on HP-UX 11.11

Mikulas Patocka mikulas at artax.karlin.mff.cuni.cz
Tue Dec 11 23:30:36 UTC 2012



On Fri, 7 Dec 2012, Andrew Borodin wrote:

> On Fri, 7 Dec 2012 02:10:39 +0100 (CET) Mikulas Patocka wrote:
> > Fix build on HP-UX 11.11
> >
> > HP-UX 11.11 doesn't have strtoll, but it has strtoimax. strtoimax is
> > defined as a preprocessor macro, not as a function.
> >
> > This patch fixes build: it adds checks for two function strtoll and
> > strtoimax and uses them if detected.
> 
> Thanks for the patch! mc is being developed under Linux only, so patches to
> improve mc portability are welcome!

Hi

Unfortunatelly, I found out that my previous patch was wrong - it compiles 
on HP-UX, but it doesn't use the 64-bit strtoimax instruction.

There were these problems:
* strtoimax is defined in inttypes.h, not stdlib.h, so we must include 
inttypes.h

* strtoimax is a macro that expands to __strtoll function. __strtoll only 
exists in 32-bit libc. When building in 64-bit mode, strtoimax still 
expands to __strtoll, but __strtoll doesn't exist (I think this is a bug 
in HP-UX). So we must test for __strtoll in configure and use strtoimax 
macro only if __strtoll is present in the libc. On 64-bit build we can use 
strtol instead of strtoll, because strtol is already 64-bit.

* on HP-UX inttypes.h includes ctype.h through other dependencies, ctype.h 
defines macros for various functions and these macros clash with entries 
of "struct str_class" - so we must undefine the macros before defining 
str_class.

So please, apply this on the top of my previous patch.

Mikulas

Index: mc-4.8.6/configure.ac
===================================================================
--- mc-4.8.6.orig/configure.ac
+++ mc-4.8.6/configure.ac
@@ -192,6 +192,7 @@ dnl ####################################
 AC_CHECK_FUNCS([\
 	strtoll \
 	strtoimax \
+	__strtoll \
 	atoll \
 	isascii \
 	statfs sysconf \
Index: mc-4.8.6/lib/global.h
===================================================================
--- mc-4.8.6.orig/lib/global.h
+++ mc-4.8.6/lib/global.h
@@ -56,9 +56,11 @@
 #endif
 
 /* HP-UX 11.11 doesn't have strtoll. But it has strtoimax defined as a macro */
-#include <stdlib.h>
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
 #ifndef HAVE_STRTOLL
-#if defined(HAVE_STRTOIMAX) || defined(strtoimax)
+#if defined(HAVE_STRTOIMAX) || (defined(strtoimax) && defined(HAVE___STRTOLL))
 #define strtoll strtoimax
 #else
 #define strtoll strtol
Index: mc-4.8.6/lib/strutil.h
===================================================================
--- mc-4.8.6.orig/lib/strutil.h
+++ mc-4.8.6/lib/strutil.h
@@ -88,6 +88,28 @@ typedef enum
 
 /*** structures declarations (and typedefs of structures)*****************************************/
 
+#ifdef isspace
+#undef isspace
+#endif
+#ifdef ispunct
+#undef ispunct
+#endif
+#ifdef isalnum
+#undef isalnum
+#endif
+#ifdef isdigit
+#undef isdigit
+#endif
+#ifdef isprint
+#undef isprint
+#endif
+#ifdef toupper
+#undef toupper
+#endif
+#ifdef tolower
+#undef tolower
+#endif
+
 /* all functions in str_class must be defined for every encoding */
 struct str_class
 {



More information about the mc-devel mailing list