Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POSIX::setlocale fails on system without locales (Android) #442

Merged
merged 2 commits into from Jan 16, 2014

Conversation

dex4er
Copy link
Contributor

@dex4er dex4er commented Jan 11, 2014

I'm getting an error on Android. This system has poor support for locales, so the Perl is usually compiled with -Ui_locale flag.

t/Plack-Middleware/simple_logger.t ................. 1/? 
#   Failed test at t/Plack-Middleware/simple_logger.t line 24.
#                   'Your vendor has not defined POSIX macro LC_ALL, used at /storage/sdcard0/home/.cpanm/work/1389472371.9142/Plack-1.0030/blib/lib/Plack/Middleware/SimpleLogger.pm line 32
# '
#     doesn't match '(?^:This is info)'
# Looks like you failed 1 test of 2.
t/Plack-Middleware/simple_logger.t ................. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests 

It is built cleanly with this patch.

Unfortunately, Plack still doesn't work well on Android because there is some other problem which test units didn't detect:

$ plackup -e 'sub {[200, [$^O], []]}' -E test
Use of uninitialized value $v in concatenation (.) or string at /data/perl/lib/site_perl/5.18.2/HTTP/Server/PSGI.pm line 204.

returns

$ telnet htc-one-s 5000
Trying 192.168.1.84...
Connected to htc-one-s.
Escape character is '^]'.
GET / HTTP/1.0

HTTP/1.0 200 OK
Date: Sat, 11 Jan 2014 21:05:53 GMT
Server: HTTP::Server::PSGI
linux: Content-Length
0: 

Connection closed by foreign host.

I'll provide proper patch if I track this problem.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) when pulling 59877cf on dex4er:porting/no_locale into b17e171 on plack:master.

@dex4er
Copy link
Contributor Author

dex4er commented Jan 11, 2014

Oh god, I'm stupid :)

$ plackup -e 'sub {[200, [], [$^O]]}'

and

$ GET http://htc-one-s:5000/
linux

It means that Plack DOES work on Android correctly :)

@dex4er
Copy link
Contributor Author

dex4er commented Jan 12, 2014

Another attempt to fix this issue is to check $Config{d_setocale} and call POSIX::setlocale if it is true.

See https://rt.cpan.org/Public/Bug/Display.html?id=92051 for details.

@miyagawa
Copy link
Member

I understand and support the intent of the patch, but am not sure if i support the three uses of eval when theoretically only one is necessary.

@dex4er
Copy link
Contributor Author

dex4er commented Jan 16, 2014

There can be more clean way. I'll provide proper fixes real soon.

@dex4er
Copy link
Contributor Author

dex4er commented Jan 16, 2014

More safe handling of missing locales applied. Regards.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.23%) when pulling 7908e03 on dex4er:porting/no_locale into b17e171 on plack:master.

miyagawa added a commit that referenced this pull request Jan 16, 2014
POSIX::setlocale fails on system without locales (Android)
@miyagawa miyagawa merged commit c5a3896 into plack:master Jan 16, 2014
@dex4er
Copy link
Contributor Author

dex4er commented Jan 16, 2014

Thank you!

If you want to play with Perl on Android, there is a small howto: https://github.com/dex4er/perl5-android/wiki

@dex4er dex4er deleted the porting/no_locale branch January 16, 2014 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants