Fix pretty printers for versioned namespace

François Dumont frs.dumont@gmail.com
Wed Nov 1 18:04:00 GMT 2017


On 30/10/2017 19:15, Jonathan Wakely wrote:
>
>>> @@ -1227,7 +1227,12 @@ class Printer(object):
>>>    def add_version(self, base, name, function):
>>>        self.add(base + name, function)
>>>        if _versioned_namespace:
>>> -            self.add(base + _versioned_namespace + name, function)
>>> +            vbase = re.sub('^std::', 'std::%s' % 
>>> _versioned_namespace, base)
>>> +            if vbase != base:
>>> +                self.add(vbase + name, function)
>>> +            vbase = re.sub('^__gnu_cxx::', '__gnu_cxx::%s' % 
>>> _versioned_namespace, base)
>>> +            if vbase != base:
>>> +                self.add(vbase + name, function)
>>
>> Only one re.sub is needed:
>>
>> vbase = re.sub('^(std|__gnu_cxx)::', r'\1::%s' % 
>> _versioned_namespace, base)
>
> Or using \g<0> to refer to the whole match:
>
> vbase = re.sub('^(std|__gnu_cxx)::', r'\g<0>%s' % 
> _versioned_namespace, base)
>
>> OK for trunk with that change, assuming it works. Thanks.
It worked, attached patch applied.

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: printers.patch
Type: text/x-patch
Size: 4663 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20171101/dd8e8c95/attachment.bin>


More information about the Gcc-patches mailing list