Bug 723299

Summary: [FEDORA:C++:READLINE] isxdigit should not be defined as a macro in readline
Product: [Fedora] Fedora Reporter: Travis Gummels <tgummels>
Component: readlineAssignee: Lukáš Nykrýn <lnykryn>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: mlichvar, syeghiay
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 722942 Environment:
Last Closed: 2011-08-31 07:56:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Travis Gummels 2011-07-19 16:34:13 UTC
+++ This bug was initially created as a clone of Bug #722942 +++

Description of problem:

The problem is that readline shouldn't be defining isxdigit as a macro ever. That is wrong in C++ because it is a template function. If you look at ctype.h you see the correct declaration which is excluded from C++ with: 

#if !defined __NO_CTYPE && !defined __cplusplus
<snip>
# define isxdigit(c)    __isctype((c), _ISxdigit)

This is a bug in readline.

Version-Release number of selected component (if applicable):
CURRENTRELEASE

How reproducible:
100%

Steps to Reproduce:
$ cat test.C 
#include <string> 
#include <readline/readline.h> 
#include <iostream> 

using namespace std; 

int main() { 
cout<<"Hi There "<<isxdigit(19)<<endl; return 0; 
} 


$ g++ test.C


Actual results: (lin numbers/versions different between RHEL 6 and Fedora but result should be same)

In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ios:47,

                 from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ostream:44,

                 from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iostream:44,

                 from test.C:3:

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/localefwd.h:90:35: error: macro "isxdigit" passed 2 arguments, but takes just 1

In file included from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/basic_ios.h:44,

                 from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ios:50,

                 from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ostream:44,

                 from /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/iostream:44,

                 from test.C:3:

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/locale_facets.h:4609:45: error: macro "isxdigit" passed 2 arguments, but takes just 1

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/localefwd.h:90: error: 'std::isxdigit' declared as an 'inline' variable

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/localefwd.h:90: error: template declaration of 'bool std::isxdigit'

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/locale_facets.h:4609: error: invalid function declaration

Expected results:

No garbage.

Additional info:

A simple fix in readline would be to add 

!defined __cplusplus to the declaration in chardefs.h

    75  #if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
    76  #  define isxdigit(c)   (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
    77  #endif

so that line 75 ends up being:

    75  #if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) && !defined (__cplusplus) 
    76  #  define isxdigit(c)   (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
    77  #endif

Comment 1 Fedora Admin XMLRPC Client 2011-08-08 08:15:12 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 2 Lukáš Nykrýn 2011-08-31 07:56:51 UTC
fixed commited to git -> http://lists.fedoraproject.org/pipermail/scm-commits/2011-August/654445.html -> closed