[libcxx-commits] [PATCH] D112958: [libcxx][NFC] tidy up money_get::__do_get's sign parsing
Daniel McIntosh via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Nov 3 08:50:46 PDT 2021
DanielMcIntosh-IBM updated this revision to Diff 384472.
DanielMcIntosh-IBM added a comment.
Add comment further explaining the behaviour of __neg
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112958/new/
https://reviews.llvm.org/D112958
Files:
libcxx/include/locale
Index: libcxx/include/locale
===================================================================
--- libcxx/include/locale
+++ libcxx/include/locale
@@ -2963,51 +2963,31 @@
}
break;
case money_base::sign:
- if (__psn.size() + __nsn.size() > 0)
+ if (__psn.size() > 0 && *__b == __psn[0])
{
- if (__psn.size() == 0 || __nsn.size() == 0)
- { // sign is optional
- if (__psn.size() > 0)
- { // __nsn.size() == 0
- if (*__b == __psn[0])
- {
- ++__b;
- if (__psn.size() > 1)
- __trailing_sign = &__psn;
- }
- else
- __neg = true;
- }
- else if (*__b == __nsn[0]) // __nsn.size() > 0 && __psn.size() == 0
- {
- ++__b;
- __neg = true;
- if (__nsn.size() > 1)
- __trailing_sign = &__nsn;
- }
- }
- else // sign is required
- {
- if (*__b == __psn[0])
- {
- ++__b;
- if (__psn.size() > 1)
- __trailing_sign = &__psn;
- }
- else if (*__b == __nsn[0])
- {
- ++__b;
- __neg = true;
- if (__nsn.size() > 1)
- __trailing_sign = &__nsn;
- }
- else
- {
- __err |= ios_base::failbit;
- return false;
- }
- }
+ ++__b;
+ __neg = false;
+ if (__psn.size() > 1)
+ __trailing_sign = &__psn;
+ break;
+ }
+ if (__nsn.size() > 0 && *__b == __nsn[0])
+ {
+ ++__b;
+ __neg = true;
+ if (__nsn.size() > 1)
+ __trailing_sign = &__nsn;
+ break;
+ }
+ if (__psn.size() > 0 && __nsn.size() > 0)
+ { // sign is required
+ __err |= ios_base::failbit;
+ return false;
}
+ if (__psn.size() == 0 && __nsn.size() == 0)
+ // locale has no way of specifying a sign. Use the initial value of __neg as a default
+ break;
+ __neg = (__nsn.size() == 0);
break;
case money_base::symbol:
{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112958.384472.patch
Type: text/x-patch
Size: 2866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211103/89560291/attachment.bin>
More information about the libcxx-commits
mailing list