Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.97k stars 560 forks source link

locale.c: Fix conditional compilation #16605

Closed p5pRT closed 6 years ago

p5pRT commented 6 years ago

Migrated from rt.perl.org#133321 (status was 'resolved')

Searchable as RT133321$

p5pRT commented 6 years ago

From @fperrad

Created by @fperrad

With Perl 5.28.0\, there are some mismatches between blocks and conditional compilation in the Perl__is_cur_LC_category_utf8() function. The compilation of miniperl could fails like this​: ``` locale.c​: In function `Perl__is_cur_LC_category_utf8`​: locale.c​:5481​:1​: error​: expected declaration or statement at end of input } ^ ```

The attached patch fixes the issue.

Perl Info ``` Flags: category=core severity=high Site configuration information for perl 5.28.0: Summary of my perl5 (revision 5 version 28 subversion 0) configuration: Platform: osname=linux osvers=4.16.7 archname=arm-linux uname='Buildroot 2018.05-gdab1a6ee4' config_args='--target=arm-buildroot-linux-uclibcgnueabihf --target-tools-prefix=/home/user/build/qarm/host/bin/arm-buildroot-linux-uclibcgnueabihf- --prefix=/usr -Dld=/home/user/build/qarm/host/bin/arm-buildroot-linux-uclibcgnueabihf-gcc -Dccflags=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -Dldflags= -lm -Dmydomain= -Dmyhostname=noname -Dmyuname=Buildroot 2018.05-gdab1a6ee4 -Dosname=linux -Dosvers=4.16.7 -Dperladmin=root --keeplog --mode=target --target=arm-buildroot-linux-uclibcgnueabihf --targetarch=arm-buildroot-linux-uclibcgnueabihf' hint=default useposix=true d_sigaction=define useithreads=undef usemultiplicity=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n default_inc_excludes_dot=undef bincompat5005=undef Compiler: cc='/home/user/build/qarm/host/bin/arm-buildroot-linux-uclibcgnueabihf-gcc' ccflags ='-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os ' optimize='-fwrapv -fno-strict-aliasing' cppflags='' ccversion='6.4.0' gccversion='6.4.0' gccosandvers='' intsize=4 longsize=4 ptrsize=4 doublesize=8 byteorder=1234 doublekind=3 d_longlong=define longlongsize=8 d_longdbl=define longdblsize=8 longdblkind=0 ivtype='long' ivsize=4 nvtype='double' nvsize=8 Off_t='off_t' lseeksize=8 alignbytes=8 prototype=define Linker and Libraries: ld='/home/user/build/qarm/host/bin/arm-buildroot-linux-uclibcgnueabihf-gcc' ldflags =' -lm' libpth=/lib /usr/lib /usr/local/lib libs=-lm -lcrypt -lpthread -ldl perllibs=-lm -lcrypt -ldl libc= so=so useshrplib=false libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs dlext=so d_dlsymun=undef ccdlflags='-Wl,-E' cccdlflags='-fPIC -Wno-unused-function' lddlflags='-shared' @INC for perl 5.28.0: /usr/lib/perl5/site_perl/5.28.0/arm-linux /usr/lib/perl5/site_perl/5.28.0 /usr/lib/perl5/5.28.0/arm-linux /usr/lib/perl5/5.28.0 Environment for perl 5.28.0: HOME=/root LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/bin:/sbin:/usr/bin:/usr/sbin PERL_BADLANG (unset) SHELL=/bin/sh ```
p5pRT commented 6 years ago

From @fperrad

0001-locale.c-Fix-conditional-compilation.patch ```diff From: Francois Perrad Date: Mon, 2 Jul 2018 00:17:44 +0200 Subject: [PATCH] locale.c: Fix conditional compilation With Perl 5.28.0, there are some mismatches between blocks and conditional compilation in the Perl__is_cur_LC_category_utf8() function. The compilation of miniperl could fails like this: ``` locale.c: In function `Perl__is_cur_LC_category_utf8`: locale.c:5481:1: error: expected declaration or statement at end of input } ^ ``` Signed-off-by: Francois Perrad --- locale.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/locale.c b/locale.c index 7653340477..1a865d93b0 100644 --- a/locale.c +++ b/locale.c @@ -4625,11 +4625,12 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category) && wc == (wchar_t) UNICODE_REPLACEMENT); } +# endif + restore_switched_locale(LC_CTYPE, original_ctype_locale); goto finish_and_return; } -# endif # else /* Here, we must have a C89 compiler that doesn't have mbtowc(). Next @@ -4861,9 +4862,9 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category) is_utf8 = TRUE; goto finish_and_return; } - } # endif + } # endif /* Other common encodings are the ISO 8859 series, which aren't UTF-8. But -- 2.17.1 ```
p5pRT commented 6 years ago

From @khwilliamson

On Sun\, 01 Jul 2018 21​:46​:51 -0700\, fperrad wrote​:

This is a bug report for perl from francois.perrad@​gadz.org\, generated with the help of perlbug 1.41 running under perl 5.28.0.

----------------------------------------------------------------- [Please describe your issue here]

With Perl 5.28.0\, there are some mismatches between blocks and conditional compilation in the Perl__is_cur_LC_category_utf8() function. The compilation of miniperl could fails like this​: ``` locale.c​: In function `Perl__is_cur_LC_category_utf8`​: locale.c​:5481​:1​: error​: expected declaration or statement at end of input } ^ ```

Could you try this on blead and let us know? There have been a bunch of changes to address things like this\, and I think the problem may be moot.

The attached patch fixes the issue.

[Please do not change anything below this line] ----------------------------------------------------------------- --- Flags​: category=core severity=high --- Site configuration information for perl 5.28.0​:

Summary of my perl5 (revision 5 version 28 subversion 0) configuration​:

Platform​: osname=linux osvers=4.16.7 archname=arm-linux uname='Buildroot 2018.05-gdab1a6ee4' config_args='--target=arm-buildroot-linux-uclibcgnueabihf --target-tools-prefix=/home/user/build/qarm/host/bin/arm-buildroot- linux-uclibcgnueabihf- --prefix=/usr -Dld=/home/user/build/qarm/host/bin/arm-buildroot-linux- uclibcgnueabihf-gcc -Dccflags=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -Dldflags= -lm -Dmydomain= -Dmyhostname=noname -Dmyuname=Buildroot 2018.05-gdab1a6ee4 -Dosname=linux -Dosvers=4.16.7 -Dperladmin=root --keeplog --mode=target --target=arm-buildroot-linux-uclibcgnueabihf --targetarch=arm-buildroot-linux-uclibcgnueabihf' hint=default useposix=true d_sigaction=define useithreads=undef usemultiplicity=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n default_inc_excludes_dot=undef bincompat5005=undef Compiler​:

cc='/home/user/build/qarm/host/bin/arm-buildroot-linux- uclibcgnueabihf-gcc' ccflags ='-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os ' optimize='-fwrapv -fno-strict-aliasing' cppflags='' ccversion='6.4.0' gccversion='6.4.0' gccosandvers='' intsize=4 longsize=4 ptrsize=4 doublesize=8 byteorder=1234 doublekind=3 d_longlong=define longlongsize=8 d_longdbl=define longdblsize=8 longdblkind=0 ivtype='long' ivsize=4 nvtype='double' nvsize=8 Off_t='off_t' lseeksize=8 alignbytes=8 prototype=define Linker and Libraries​:

ld='/home/user/build/qarm/host/bin/arm-buildroot-linux- uclibcgnueabihf-gcc' ldflags =' -lm' libpth=/lib /usr/lib /usr/local/lib libs=-lm -lcrypt -lpthread -ldl perllibs=-lm -lcrypt -ldl libc= so=so useshrplib=false libperl=libperl.a gnulibc_version='' Dynamic Linking​: dlsrc=dl_dlopen.xs dlext=so d_dlsymun=undef ccdlflags='-Wl\,-E' cccdlflags='-fPIC -Wno-unused-function' lddlflags='-shared'

--- @​INC for perl 5.28.0​: /usr/lib/perl5/site_perl/5.28.0/arm-linux /usr/lib/perl5/site_perl/5.28.0 /usr/lib/perl5/5.28.0/arm-linux /usr/lib/perl5/5.28.0

--- Environment for perl 5.28.0​: HOME=/root LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/bin​:/sbin​:/usr/bin​:/usr/sbin PERL_BADLANG (unset) SHELL=/bin/sh

-- Karl Williamson

p5pRT commented 6 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 6 years ago

From @fperrad

On Sat\, 07 Jul 2018 14​:49​:26 -0700\, khw wrote​:

On Sun\, 01 Jul 2018 21​:46​:51 -0700\, fperrad wrote​:

This is a bug report for perl from francois.perrad@​gadz.org\, generated with the help of perlbug 1.41 running under perl 5.28.0.

----------------------------------------------------------------- [Please describe your issue here]

With Perl 5.28.0\, there are some mismatches between blocks and conditional compilation in the Perl__is_cur_LC_category_utf8() function. The compilation of miniperl could fails like this​: ``` locale.c​: In function `Perl__is_cur_LC_category_utf8`​: locale.c​:5481​:1​: error​: expected declaration or statement at end of input } ^ ```

Could you try this on blead and let us know? There have been a bunch of changes to address things like this\, and I think the problem may be moot.

The issue is still here on blead (7e7bdfd). The issue is not present in 5.26 branch.

It occurs with a toolchain using uClibc 1.0.30\, but everything is OK when using glibc or musl.

Any editor with collapse/expand block capability will show you that blocks and conditional compilation are not properly balanced in the function `Perl__is_cur_LC_category_utf8`.

François

The attached patch fixes the issue.

p5pRT commented 6 years ago

From @khwilliamson

Thanks for finding and submitting a patch for this. Now pushed to blead as 17dd77cd74f0a69332c091f816162e34abff30c5 -- Karl Williamson

p5pRT commented 6 years ago

@khwilliamson - Status changed from 'open' to 'resolved'