From: Herbert Xu <herbert@gondor.apana.org.au>
To: DASH Mailing List <dash@vger.kernel.org>
Subject: [v3 PATCH 02/13] shell: Use strcoll instead of strcmp where applicable
Date: Sun, 05 May 2024 17:14:28 +0800 [thread overview]
Message-ID: <3455da09a3e822b0ac3e29e644dffa1c78a8cbef.1714900377.git.herbert@gondor.apana.org.au> (raw)
In-Reply-To: <cover.1714900377.git.herbert@gondor.apana.org.au>
Use strcoll instead of strcmp so that the locale is taken into
account when sorting strings during pathname expansion, and for
the built-in test(1) string comparison operators.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
src/bltin/test.c | 8 ++++----
src/expand.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/bltin/test.c b/src/bltin/test.c
index fd8a43b..2db4d0f 100644
--- a/src/bltin/test.c
+++ b/src/bltin/test.c
@@ -353,13 +353,13 @@ binop(void)
/* NOTREACHED */
#endif
case STREQ:
- return strcmp(opnd1, opnd2) == 0;
+ return strcoll(opnd1, opnd2) == 0;
case STRNE:
- return strcmp(opnd1, opnd2) != 0;
+ return strcoll(opnd1, opnd2) != 0;
case STRLT:
- return strcmp(opnd1, opnd2) < 0;
+ return strcoll(opnd1, opnd2) < 0;
case STRGT:
- return strcmp(opnd1, opnd2) > 0;
+ return strcoll(opnd1, opnd2) > 0;
case INTEQ:
return getn(opnd1) == getn(opnd2);
case INTNE:
diff --git a/src/expand.c b/src/expand.c
index 0db2b29..9ac981e 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -1476,7 +1476,7 @@ msort(struct strlist *list, int len)
p = msort(p, len - half); /* sort second half */
lpp = &list;
for (;;) {
- if (strcmp(p->text, q->text) < 0) {
+ if (strcoll(p->text, q->text) < 0) {
*lpp = p;
lpp = &p->next;
if ((p = *lpp) == NULL) {
--
2.39.2
next prev parent reply other threads:[~2024-05-05 9:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-05 9:14 [v3 PATCH 00/13] Add multi-byte support Herbert Xu
2024-05-05 9:14 ` [v3 PATCH 01/13] shell: Call setlocale Herbert Xu
2024-05-05 9:14 ` Herbert Xu [this message]
2024-05-05 9:14 ` [v3 PATCH 03/13] expand: Count multi-byte characters for VSLENGTH Herbert Xu
2024-05-05 9:14 ` [v3 PATCH 04/13] expand: Process multi-byte characters in subevalvar Herbert Xu
2024-05-05 9:14 ` [v3 PATCH 05/13] expand: Process multi-byte characters in expmeta Herbert Xu
2024-05-05 9:14 ` [v3 PATCH 06/13] expand: Support multi-byte characters during field splitting Herbert Xu
2024-05-05 9:14 ` [v3 PATCH 07/13] input: Allow MB_LEN_MAX calls to pungetc Herbert Xu
2024-05-05 9:14 ` [v3 PATCH 08/13] input: Add pgetc_eoa Herbert Xu
2024-05-05 9:14 ` [v3 PATCH 09/13] parser: Add support for multi-byte characters Herbert Xu
2024-05-05 9:15 ` [v3 PATCH 10/13] input: Always push in setinputfile Herbert Xu
2024-05-05 9:15 ` [v3 PATCH 11/13] memalloc: Use void * instead of pointer Herbert Xu
2024-05-05 9:15 ` [v3 PATCH 12/13] builtin: Use pgetc in read(1) Herbert Xu
2024-05-05 9:15 ` [v3 PATCH 13/13] builtin: Process multi-byte characters " Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3455da09a3e822b0ac3e29e644dffa1c78a8cbef.1714900377.git.herbert@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=dash@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).