Issue Details (XML | Word | Printable)

Key: STDCXX-520
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Unassigned
Reporter: Farid Zaripov
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

codecvt1.cpp example exits with exitcode=1

Created: 12/Aug/07 08:53 PM   Updated: 02/Dec/08 03:05 AM
Return to search
Component/s: Examples
Affects Version/s: 4.1.3, 4.2.0
Fix Version/s: 4.2.2

Time Tracking:
Original Estimate: 4h
Original Estimate - 4h
Remaining Estimate: 4h
Remaining Estimate - 4h
Time Spent: Not Specified
Remaining Estimate - 4h

Environment: All

Severity: Incorrect Behavior


 Description  « Hide
codecvt1.cpp example exits with exitcode=1 because of no requested locales are installed.

The thread in mailing-list: http://www.mail-archive.com/stdcxx-dev@incubator.apache.org/msg03703.html
----------------------
codecvt1 should probably be disabled for now (until we figure
out how to get it to work) and it should also be renamed to
something more descriptive. Testing three hardwired encodings
doesn't seem like a good idea for a simple example, so maybe
we could split it up into codecvt-sjis.cpp, codecvt-eucjp,
and codecvt-utf8.cpp.
----------------------



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Martin Sebor added a comment - 22/Aug/07 02:34 PM
Assigned to Farid.

Martin Sebor added a comment - 22/Aug/07 02:34 PM
Scheduled for 4.2.

Martin Sebor added a comment - 22/Aug/07 02:36 PM
Changed from Improvement to a Bug – examples should never fail.

Farid Zaripov added a comment - 11/Sep/07 12:14 PM - edited
The example doesn't fail (crash or something). It's just return 1 to indicate that used locales not available.

Added output of the error message thus: http://svn.apache.org/viewvc?rev=574560&view=rev

Changed type back to improvement and scheduled for 4.2.1.


Farid Zaripov added a comment - 29/Jan/08 01:01 PM - edited
We cannot split this example into 3 examples, because there also present conversion test between EUC-JP and UTF-8 encodings through the internal representation.

Martin Sebor added a comment - 11/Mar/08 10:52 PM
Guesstimating the amount of work.

Martin Sebor added a comment - 11/Mar/08 11:01 PM
The example shows how to convert character strings representing Japanese (i.e., ja_JP) weekday names between the UTF-8, Shift_JIS, and EUC-JP encodings.

When invoked with no arguments or special variables in the environment it abends like so:

$ ./codecvt1 
ja_JP.UTF-8 -> INT -> ja_JP.UTF-8
  Size comparison of buffers yields equal
  Content comparison of buffers yields equal
Caught an exception: /home/sebor/stdcxx/src/locale_combine.cpp:644: std::locale::locale(const char*): bad locale name: "ja_JP.Shift_JIS"

But when invoked with the RWSTD_LOCALE_ROOT environment variable set to point to the root of a directory tree containing the three locales above, i.e., ja_JP.UTF-8, ja_JP.Shift_JIS, and ja_JP.EUC-JP, it produces the expected output:

$ make -C../bin ja_JP.UTF-8 ja_JP.Shift_JIS ja_JP.EUC-JP && RWSTD_LOCALE_ROOT=../nls ./codecvt1 
make: Entering directory `/build/sebor/stdcxx-gcc-4.1.2-15D/bin'
./localedef -w -c -f /home/sebor/stdcxx/etc/nls/charmaps/UTF-8 -i /home/sebor/stdcxx/etc/nls/src/ja_JP /build/sebor/stdcxx-gcc-4.1.2-15D/nls/ja_JP.UTF-8
./localedef -w -c -f /home/sebor/stdcxx/etc/nls/charmaps/Shift_JIS -i /home/sebor/stdcxx/etc/nls/src/ja_JP /build/sebor/stdcxx-gcc-4.1.2-15D/nls/ja_JP.Shift_JIS
./localedef -w -c -f /home/sebor/stdcxx/etc/nls/charmaps/EUC-JP -i /home/sebor/stdcxx/etc/nls/src/ja_JP /build/sebor/stdcxx-gcc-4.1.2-15D/nls/ja_JP.EUC-JP
make: Leaving directory `/build/sebor/stdcxx-gcc-4.1.2-15D/bin'
ja_JP.UTF-8 -> INT -> ja_JP.UTF-8
  Size comparison of buffers yields equal
  Content comparison of buffers yields equal
ja_JP.Shift_JIS -> INT -> ja_JP.Shift_JIS
  Size comparison of buffers yields equal
  Content comparison of buffers yields equal
ja_JP.EUC-JP -> INT -> ja_JP.EUC-JP
  Size comparison of buffers yields equal
  Content comparison of buffers yields equal

EUC-JP -> INT -> UTF-8 conversion
  Size    comparison of buffers yields  equal
  Content comparison of buffers yields equal

Martin Sebor added a comment - 11/Mar/08 11:09 PM
So it looks to me like all we need to do to make the example behave in a useful way is to make sure the three locales exist (and that they are our own locales, not just the system ones) before invoking the program, and that the RWSTD_LOCALE_ROOT environment variable is set appropriately.

We can also rename the example to something more descriptive, like jpcvt.cpp.


Martin Sebor added a comment - 12/Mar/08 03:34 AM
Added 4.2.0 to Affects Version/s.

Martin Sebor added a comment - 25/Apr/08 12:32 AM
Deferred to 4.2.2.