bug-gnulib
[Top][All Lists]
Advanced

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

regex - sizeof datatype and stupid comments


From: Jerker Bäck
Subject: regex - sizeof datatype and stupid comments
Date: Sun, 8 Jul 2007 19:01:03 +0200

Quoting regex.h from recent CVS:

#ifdef _REGEX_LARGE_OFFSETS
...
typedef ssize_t regoff_t;
typedef size_t __re_idx_t;
typedef size_t __re_size_t;
typedef size_t __re_long_size_t;

#else

typedef int regoff_t;
typedef int __re_idx_t;
typedef unsigned int __re_size_t;
typedef unsigned long int __re_long_size_t;

#endif

/* The following two types have to be signed and unsigned integer type
   wide enough to hold a value of a pointer.  For most ANSI compilers
   ptrdiff_t and size_t should be likely OK.  Still size of these two
   types is 2 for Microsoft C.  Ugh... */
typedef long int s_reg_t;
typedef unsigned long int active_reg_t;
...
typedef unsigned long int reg_syntax_t;


The comment for MSC is correct for 16bit MS compilers, the latest, version
1.52c was released in October 1993. At that time 32bit compilers had been
out for some time and 1.52c is actually a 32bit cross-compiler for 16bit
intended to be run from the first Windows NT release. It is still used for
DOS and 16bit device drivers. In all other cases (including AMD64 and IA64
compilers), the size of long is 4 (32bit datatype - LLP64 model).

Ugh... ????
So, when you think about it, this comment backfires big time. What did the
commenter trying to do? Compile 32bit with a 16bit compiler? Or is the
comment based on assumptions taken just out of the blue? An eager compiler
brand warrior riding out for his quest and making his statement for the
battle, trying to intimidating the people and his enemy? The words sloppy
and crude comes to my mind. I usually enjoy funny comments in code, but
incorrect, stupid ones are just annoying.

64bit datatype issues - LP64 vis-à-vis LLP64
As I understand, the current code assumes LP64 model and that the compiler
treats a long datatype as 64bit with a 64bit compile. Or? The problem for me
is that I need a LP64 model (x86_64 Interix), but my compiler (AMD64 MSC 8)
treats the long type as 32bit (LLP64 model). All this is taken care of in my
system headers but depend of a correct compatible syntax. So, before I could
compile any package using GNULIB, I need to replace all long types to a
compatible type e.g. intptr_t.

In regex.h - would it not be better and more portable with:

typedef intptr_t s_reg_t;
typedef uintptr_t active_reg_t;
typedef uintptr_t reg_syntax_t;


regards Erik, Sweden







reply via email to

[Prev in Thread] Current Thread [Next in Thread]