Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[perl #71762] vianame() returns a chr instead of an ord when called like U+xxxx

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


perlbug-followup at perl

Dec 30, 2009, 5:10 PM

Post #1 of 3 (321 views)
Permalink
[perl #71762] vianame() returns a chr instead of an ord when called like U+xxxx

# New Ticket Created by karl williamson
# Please include the string: [perl #71762]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=71762 >


This is a bug report for perl from khw [at] khw-desktop,
generated with the help of perlbug 1.39 running under perl 5.11.3.


-----------------------------------------------------------------
The function vianame() in charnames.pm is supposed to return the ordinal
of the name it is called with. But when called with a name like U+0041,
it doesn't, it returns the chr instead.
-----------------------------------------------------------------
---
Flags:
category=library
severity=medium
module=charnames
---
Site configuration information for perl 5.11.3:

Configured by khw at Tue Dec 29 12:45:43 MST 2009.

Summary of my perl5 (revision 5 version 11 subversion 3) configuration:
Commit id: 9f815e241cf04d04fc645970753438216a0ed024
Platform:
osname=linux, osvers=2.6.27-16-generic, archname=i686-linux
uname='linux khw-desktop 2.6.27-16-generic #1 smp tue dec 1
17:56:54 utc 2009 i686 gnulinux '
config_args='-s -d -Dprefix=/home/khw/fastbleadperl -Dusedevel'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.3.2', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.8.90.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.8.90'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'

Locally applied patches:


---
@INC for perl 5.11.3:
/home/khw/fastbleadperl/lib/site_perl/5.11.3/i686-linux
/home/khw/fastbleadperl/lib/site_perl/5.11.3
/home/khw/fastbleadperl/lib/5.11.3/i686-linux
/home/khw/fastbleadperl/lib/5.11.3
.

---
Environment for perl 5.11.3:
HOME=/home/khw
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)

PATH=/home/khw/bin:/home/khw/print/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/games:/opt/real/RealPlayer:/home/khw/cxoffice/bin
PERL_BADLANG (unset)
SHELL=/bin/ksh


demerphq at gmail

Dec 31, 2009, 5:07 AM

Post #2 of 3 (295 views)
Permalink
Re: [perl #71762] vianame() returns a chr instead of an ord when called like U+xxxx [In reply to]

2009/12/31 karl williamson <perlbug-followup [at] perl>:
> # New Ticket Created by  karl williamson
> # Please include the string:  [perl #71762]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=71762 >
>
>
> This is a bug report for perl from khw [at] khw-desktop,
> generated with the help of perlbug 1.39 running under perl 5.11.3.
>
>
> -----------------------------------------------------------------
> The function vianame() in charnames.pm is supposed to return the ordinal
> of the name it is called with.  But when called with a name like U+0041,
> it doesn't, it returns the chr instead.
> -----------------------------------------------------------------
> ---

This is actually documented somewhere, i remember being really
surprised about it when i encountered it.

Yves


--
perl -Mre=debug -e "/just|another|perl|hacker/"


public at khwilliamson

Jan 2, 2010, 11:36 AM

Post #3 of 3 (283 views)
Permalink
Re: [perl #71762] vianame() returns a chr instead of an ord when called like U+xxxx [In reply to]

demerphq wrote:
> 2009/12/31 karl williamson <perlbug-followup [at] perl>:
>> # New Ticket Created by karl williamson
>> # Please include the string: [perl #71762]
>> # in the subject line of all future correspondence about this issue.
>> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=71762 >
>>
>>
>> This is a bug report for perl from khw [at] khw-desktop,
>> generated with the help of perlbug 1.39 running under perl 5.11.3.
>>
>>
>> -----------------------------------------------------------------
>> The function vianame() in charnames.pm is supposed to return the ordinal
>> of the name it is called with. But when called with a name like U+0041,
>> it doesn't, it returns the chr instead.
>> -----------------------------------------------------------------
>> ---
>
> This is actually documented somewhere, i remember being really
> surprised about it when i encountered it.
>
> Yves
>
>

I looked for the documentation of it and didn't find it. Perhaps you're
thinking of my email about this subject some months ago. Here is the
relevant portion with your response:

> -------- Original Message --------
> Subject: Re: vianame returns either chr or ord
> Date: Tue, 1 Sep 2009 14:42:00 +0200
> From: demerphq <demerphq [at] gmail>
> To: karl williamson <public [at] khwilliamson>
> CC: Perl5 Porters <perl5-porters [at] perl>, Jarkko Hietaniemi
<jhi [at] iki>
> References: <4A9C93F3.7050309 [at] khwilliamson>
>
> 2009/9/1 karl williamson <public [at] khwilliamson>:
> > If charnames::vianame is called with a name of the form U+XXXX, it
> > converts
> > the result with chr before returning. With any other name it
returns the
> > ordinal number. This seems like a bug to me, but I want to make
> > sure I'm
> > not missing something.
>
> It looks like it was deliberate, although possibly accidental. See below.
>
> > [snip]
>
> A little digging reveals the "return a char
> for U+" was introduced with the first time vianame() started handling
> U+:
>
>
http://perl5.git.perl.org/perl.git/commitdiff/dbc0d4f2f139c3775c592bb9d20ada906e3aa68e?hp=f76b0f6998c929fc8d564ca3ed8728a19879ebc7
>
> which makes some sense as it was added to support \N{U+...} processing.
>
> Yves

So the question becomes should the function be bimodal? I don't think
so, hence the bug report. The module's documentation says it returns
an ord, so either the documentation is wrong or the implementation is
wrong. On principal, I don't like bimodal functions, so it seems to me
that the documentation is right and the implementation wrong.

Does anyone think that the code shouldn't be changed?

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.