[all-commits] [llvm/llvm-project] 2d54bf: [libcxx] [test] Fix the monetary locale negative_s...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Fri Feb 25 13:48:55 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2d54bf3bc75174b85e437eb94bc4d9de311a7e21
      https://github.com/llvm/llvm-project/commit/2d54bf3bc75174b85e437eb94bc4d9de311a7e21
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-02-25 (Fri, 25 Feb 2022)

  Changed paths:
    M libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp

  Log Message:
  -----------
  [libcxx] [test] Fix the monetary locale negative_sign test for en_US.UTF-8 on Windows

On Windows, the en_US.UTF-8 locale returns `n_sign_posn == 0`, which
means that the sign for a negative currency is parentheses around
the whole value, instead of a leading minus.

Differential Revision: https://reviews.llvm.org/D120549


  Commit: 0f5d0d4e820ea50e251fb4b6592c02635c49081e
      https://github.com/llvm/llvm-project/commit/0f5d0d4e820ea50e251fb4b6592c02635c49081e
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-02-25 (Fri, 25 Feb 2022)

  Changed paths:
    M libcxx/src/locale.cpp
    M libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp
    M libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp

  Log Message:
  -----------
  [libcxx] Fix the error checking for wctob_l, fixing locale narrow function on Windows

According to POSIX.1 (and Glibc docs, and Microsoft docs), the wctob
function returns EOF on error, not WEOF. (And wctob_l should consequently
do the same.)

The previous misconception about what this function returns on errors
seems to stem from incorrect documentation in macOS, stemming from BSD
docs with the same issue. The corresponding documentation bug in FreeBSD
was fixed in 2012 in
https://github.com/freebsd/freebsd-src/commit/945aab90991bdaeabeb6ef25112975a96c01dd4e,
but it hasn't been fixed for macOS yet.

The issue seems to only be a documentation issue; the implementation
on macOS actually does use EOF, not WEOF:
https://opensource.apple.com/source/Libc/Libc-1439.40.11/locale/FreeBSD/wctob.c.auto.html

On most Unices, EOF and WEOF are the same value, but on Windows,
EOF is -1, while WEOF is (unsigned short)0xFFFF. By fixing this,
two tests start passing on Windows.

Differential Revision: https://reviews.llvm.org/D120088


Compare: https://github.com/llvm/llvm-project/compare/2ce6bc61e876...0f5d0d4e820e


More information about the All-commits mailing list