bug-gnulib
[Top][All Lists]
Advanced

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

Re: regex & g++


From: Sam Steingold
Subject: Re: regex & g++
Date: Tue, 23 Aug 2005 20:21:52 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt)

> * Paul Eggert <address@hidden> [2005-08-23 13:35:05 -0700]:
>
> Sam Steingold <address@hidden> writes:
>
>> c++ is stricter, so if the code can be compiled with c++ it is probably
>> safer.
>
> That doesn't match my experience.  To make C code work with C++, I
> often have to introduce casts (e.g., to convert void * to char *, or
> to convert one integer type to another).  These casts reduce
> reliability, since they can mask real problems when they are done
> incorrectly.  As a general rule I therefore prefer C code to have as
> few casts as C allows.
>
> I don't use C++, so I'll need your help here.  Is there some simple
> way that we can work around this in the regex code, without having to
> make wholesale changes?  For example, can we surround all the code
> with extern "C" { ... } when compiling with C++?

I just looked at the first couple of errors:
In file included from regex.c:85:
regex_internal.c: In function `reg_errcode_t re_string_construct(re_string_t*, c
onst char*, int, char*, int, const re_dfa_t*)':
regex_internal.c:97: error: invalid conversion from `int' to `reg_errcode_t'
regex_internal.c: In function `reg_errcode_t re_string_reconstruct(re_string_t*,
 int, int)':
regex_internal.c:720: error: invalid conversion from `int' to `reg_errcode_t'

a superficial code examination shows that these are indeed bugs in
regex: build_wcs_upper_buffer should be declared to return reg_errcode_t
and not int.

I suspect this is the case elsewhere too.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.memri.org/> <http://ffii.org/> <http://www.palestinefacts.org/>
<http://truepeace.org> <http://www.mideasttruth.com/> <http://www.dhimmi.com/>
Stupidity, like virtue, is its own reward.





reply via email to

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