907 lines
27 KiB
Diff
907 lines
27 KiB
Diff
From: Karel Zak <kzak@redhat.com>
|
|
Date: Tue, 1 Apr 2025 17:45:01 +0200
|
|
Subject: treewide: avoid strcasecmp() for ASCII-only strings
|
|
|
|
Use cctype.h for locale-independent string comparison and to avoid
|
|
tricky string conversions like in tr_TR locales.
|
|
|
|
Fixes: https://github.com/util-linux/util-linux/issues/3490
|
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
(cherry picked from commit 107293a68206f24e531fd906e8114b578911bb7a)
|
|
---
|
|
lib/blkdev.c | 7 ++++---
|
|
lib/colors.c | 3 ++-
|
|
lib/logindefs.c | 7 ++++---
|
|
lib/match.c | 5 +++--
|
|
lib/sysfs.c | 3 ++-
|
|
libsmartcols/src/filter-param.c | 5 +++--
|
|
login-utils/chfn.c | 3 ++-
|
|
login-utils/lslogins.c | 3 ++-
|
|
lsfd-cmd/lsfd.c | 3 ++-
|
|
misc-utils/fincore.c | 3 ++-
|
|
misc-utils/findmnt.c | 11 ++++++-----
|
|
misc-utils/logger.c | 3 ++-
|
|
misc-utils/lsclocks.c | 3 ++-
|
|
misc-utils/lslocks.c | 3 ++-
|
|
misc-utils/uuidparse.c | 3 ++-
|
|
misc-utils/wipefs.c | 3 ++-
|
|
schedutils/ionice.c | 3 ++-
|
|
sys-utils/chmem.c | 7 ++++---
|
|
sys-utils/dmesg.c | 5 +++--
|
|
sys-utils/irq-common.c | 11 ++++++-----
|
|
sys-utils/ldattach.c | 3 ++-
|
|
sys-utils/losetup.c | 3 ++-
|
|
sys-utils/lscpu.c | 5 +++--
|
|
sys-utils/lsipc.c | 3 ++-
|
|
sys-utils/lsmem.c | 27 +++++++++++++++------------
|
|
sys-utils/lsns.c | 3 ++-
|
|
sys-utils/prlimit.c | 3 ++-
|
|
sys-utils/rfkill.c | 3 ++-
|
|
sys-utils/swapon.c | 3 ++-
|
|
sys-utils/wdctl.c | 5 +++--
|
|
sys-utils/zramctl.c | 3 ++-
|
|
term-utils/script.c | 5 +++--
|
|
tests/helpers/test_mkfds.c | 7 ++++---
|
|
33 files changed, 101 insertions(+), 66 deletions(-)
|
|
|
|
diff --git a/lib/blkdev.c b/lib/blkdev.c
|
|
index b10da99..110abcd 100644
|
|
--- a/lib/blkdev.c
|
|
+++ b/lib/blkdev.c
|
|
@@ -35,6 +35,7 @@
|
|
#include "all-io.h"
|
|
#include "blkdev.h"
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "linux_version.h"
|
|
#include "fileutils.h"
|
|
#include "nls.h"
|
|
@@ -384,14 +385,14 @@ int blkdev_lock(int fd, const char *devname, const char *lockmode)
|
|
if (!lockmode)
|
|
return 0;
|
|
|
|
- if (strcasecmp(lockmode, "yes") == 0 ||
|
|
+ if (c_strcasecmp(lockmode, "yes") == 0 ||
|
|
strcmp(lockmode, "1") == 0)
|
|
oper = LOCK_EX;
|
|
|
|
- else if (strcasecmp(lockmode, "nonblock") == 0)
|
|
+ else if (c_strcasecmp(lockmode, "nonblock") == 0)
|
|
oper = LOCK_EX | LOCK_NB;
|
|
|
|
- else if (strcasecmp(lockmode, "no") == 0 ||
|
|
+ else if (c_strcasecmp(lockmode, "no") == 0 ||
|
|
strcmp(lockmode, "0") == 0)
|
|
return 0;
|
|
else {
|
|
diff --git a/lib/colors.c b/lib/colors.c
|
|
index c9a9518..4852a87 100644
|
|
--- a/lib/colors.c
|
|
+++ b/lib/colors.c
|
|
@@ -32,6 +32,7 @@
|
|
#endif
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "colors.h"
|
|
#include "pathnames.h"
|
|
#include "strutils.h"
|
|
@@ -744,7 +745,7 @@ int colormode_from_string(const char *str)
|
|
assert(ARRAY_SIZE(modes) == __UL_NCOLORMODES);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(modes); i++) {
|
|
- if (strcasecmp(str, modes[i]) == 0)
|
|
+ if (c_strcasecmp(str, modes[i]) == 0)
|
|
return i;
|
|
}
|
|
|
|
diff --git a/lib/logindefs.c b/lib/logindefs.c
|
|
index 7b69599..4fee839 100644
|
|
--- a/lib/logindefs.c
|
|
+++ b/lib/logindefs.c
|
|
@@ -32,6 +32,7 @@
|
|
#include <pwd.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "closestream.h"
|
|
#include "logindefs.h"
|
|
#include "nls.h"
|
|
@@ -171,7 +172,7 @@ static struct item *search(const char *name)
|
|
|
|
ptr = list;
|
|
while (ptr != NULL) {
|
|
- if (strcasecmp(name, ptr->name) == 0)
|
|
+ if (c_strcasecmp(name, ptr->name) == 0)
|
|
return ptr;
|
|
ptr = ptr->next;
|
|
}
|
|
@@ -185,7 +186,7 @@ static const char *search_config(const char *name)
|
|
|
|
ptr = list;
|
|
while (ptr != NULL) {
|
|
- if (strcasecmp(name, ptr->name) == 0)
|
|
+ if (c_strcasecmp(name, ptr->name) == 0)
|
|
return ptr->path;
|
|
ptr = ptr->next;
|
|
}
|
|
@@ -196,7 +197,7 @@ static const char *search_config(const char *name)
|
|
int getlogindefs_bool(const char *name, int dflt)
|
|
{
|
|
struct item *ptr = search(name);
|
|
- return ptr && ptr->value ? (strcasecmp(ptr->value, "yes") == 0) : dflt;
|
|
+ return ptr && ptr->value ? (c_strcasecmp(ptr->value, "yes") == 0) : dflt;
|
|
}
|
|
|
|
unsigned long getlogindefs_num(const char *name, unsigned long dflt)
|
|
diff --git a/lib/match.c b/lib/match.c
|
|
index a286a19..2e0b3ce 100644
|
|
--- a/lib/match.c
|
|
+++ b/lib/match.c
|
|
@@ -8,6 +8,7 @@
|
|
#include <string.h>
|
|
|
|
#include "match.h"
|
|
+#include "cctype.h"
|
|
|
|
/*
|
|
* match_fstype:
|
|
@@ -39,10 +40,10 @@ int match_fstype(const char *type, const char *pattern)
|
|
len = strlen(type);
|
|
p = pattern;
|
|
while(1) {
|
|
- if (!strncmp(p, "no", 2) && !strncasecmp(p+2, type, len) &&
|
|
+ if (!strncmp(p, "no", 2) && !c_strncasecmp(p+2, type, len) &&
|
|
(p[len+2] == 0 || p[len+2] == ','))
|
|
return 0;
|
|
- if (strncasecmp(p, type, len) == 0 && (p[len] == 0 || p[len] == ','))
|
|
+ if (c_strncasecmp(p, type, len) == 0 && (p[len] == 0 || p[len] == ','))
|
|
return !no;
|
|
p = strchr(p,',');
|
|
if (!p)
|
|
diff --git a/lib/sysfs.c b/lib/sysfs.c
|
|
index ac9c5c3..0a016be 100644
|
|
--- a/lib/sysfs.c
|
|
+++ b/lib/sysfs.c
|
|
@@ -11,6 +11,7 @@
|
|
#include <unistd.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "pathnames.h"
|
|
#include "sysfs.h"
|
|
#include "fileutils.h"
|
|
@@ -576,7 +577,7 @@ int sysfs_blkdev_get_wholedisk( struct path_cxt *pc,
|
|
tmp = uuid;
|
|
prefix = uuid ? strsep(&tmp, "-") : NULL;
|
|
|
|
- if (prefix && strncasecmp(prefix, "part", 4) == 0)
|
|
+ if (prefix && c_strncasecmp(prefix, "part", 4) == 0)
|
|
is_part = 1;
|
|
free(uuid);
|
|
|
|
diff --git a/libsmartcols/src/filter-param.c b/libsmartcols/src/filter-param.c
|
|
index 4a67cbf..63af4c6 100644
|
|
--- a/libsmartcols/src/filter-param.c
|
|
+++ b/libsmartcols/src/filter-param.c
|
|
@@ -4,6 +4,7 @@
|
|
#include <unistd.h>
|
|
#include <regex.h>
|
|
|
|
+#include "cctype.h"
|
|
#include "rpmatch.h"
|
|
#include "smartcolsP.h"
|
|
|
|
@@ -627,8 +628,8 @@ static int string_cast(int type, struct filter_param *n)
|
|
case SCOLS_DATA_BOOLEAN:
|
|
{
|
|
bool x = str && *str
|
|
- && (strcasecmp(str, "1") == 0
|
|
- || strcasecmp(str, "true") == 0
|
|
+ && (strcmp(str, "1") == 0
|
|
+ || c_strcasecmp(str, "true") == 0
|
|
|| rpmatch(str) == RPMATCH_YES);
|
|
n->val.boolean = x;
|
|
break;
|
|
diff --git a/login-utils/chfn.c b/login-utils/chfn.c
|
|
index b82492e..7067ffa 100644
|
|
--- a/login-utils/chfn.c
|
|
+++ b/login-utils/chfn.c
|
|
@@ -33,6 +33,7 @@
|
|
#include <unistd.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "env.h"
|
|
#include "closestream.h"
|
|
#include "islocal.h"
|
|
@@ -245,7 +246,7 @@ static char *ask_new_field(struct chfn_control *ctl, const char *question,
|
|
free(buf);
|
|
return xstrdup(def_val);
|
|
}
|
|
- if (!strcasecmp(buf, "none")) {
|
|
+ if (!c_strcasecmp(buf, "none")) {
|
|
free(buf);
|
|
ctl->changed = 1;
|
|
return xstrdup("");
|
|
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
|
|
index ae7047d..88b0c4b 100644
|
|
--- a/login-utils/lslogins.c
|
|
+++ b/login-utils/lslogins.c
|
|
@@ -52,6 +52,7 @@
|
|
#endif
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "closestream.h"
|
|
#include "xalloc.h"
|
|
@@ -324,7 +325,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(coldescs); i++) {
|
|
const char *cn = coldescs[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/lsfd-cmd/lsfd.c b/lsfd-cmd/lsfd.c
|
|
index 714083e..78f0c2c 100644
|
|
--- a/lsfd-cmd/lsfd.c
|
|
+++ b/lsfd-cmd/lsfd.c
|
|
@@ -46,6 +46,7 @@
|
|
#define PF_KTHREAD 0x00200000 /* I am a kernel thread */
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "list.h"
|
|
#include "closestream.h"
|
|
#include "column-list-table.h"
|
|
@@ -611,7 +612,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/misc-utils/fincore.c b/misc-utils/fincore.c
|
|
index 25ce5aa..ea48f3e 100644
|
|
--- a/misc-utils/fincore.c
|
|
+++ b/misc-utils/fincore.c
|
|
@@ -27,6 +27,7 @@
|
|
#include <string.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "closestream.h"
|
|
#include "xalloc.h"
|
|
@@ -149,7 +150,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
|
|
index fbfb84c..46955fc 100644
|
|
--- a/misc-utils/findmnt.c
|
|
+++ b/misc-utils/findmnt.c
|
|
@@ -44,6 +44,7 @@
|
|
#include "nls.h"
|
|
#include "closestream.h"
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "strutils.h"
|
|
#include "xalloc.h"
|
|
#include "optutils.h"
|
|
@@ -344,13 +345,13 @@ static int poll_action_name_to_id(const char *name, size_t namesz)
|
|
{
|
|
int id = -1;
|
|
|
|
- if (strncasecmp(name, "move", namesz) == 0 && namesz == 4)
|
|
+ if (c_strncasecmp(name, "move", namesz) == 0 && namesz == 4)
|
|
id = MNT_TABDIFF_MOVE;
|
|
- else if (strncasecmp(name, "mount", namesz) == 0 && namesz == 5)
|
|
+ else if (c_strncasecmp(name, "mount", namesz) == 0 && namesz == 5)
|
|
id = MNT_TABDIFF_MOUNT;
|
|
- else if (strncasecmp(name, "umount", namesz) == 0 && namesz == 6)
|
|
+ else if (c_strncasecmp(name, "umount", namesz) == 0 && namesz == 6)
|
|
id = MNT_TABDIFF_UMOUNT;
|
|
- else if (strncasecmp(name, "remount", namesz) == 0 && namesz == 7)
|
|
+ else if (c_strncasecmp(name, "remount", namesz) == 0 && namesz == 7)
|
|
id = MNT_TABDIFF_REMOUNT;
|
|
else
|
|
warnx(_("unknown action: %s"), name);
|
|
@@ -396,7 +397,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = column_id_to_name(i);
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
|
|
index bcdff06..a96b005 100644
|
|
--- a/misc-utils/logger.c
|
|
+++ b/misc-utils/logger.c
|
|
@@ -56,6 +56,7 @@
|
|
|
|
#include "all-io.h"
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "closestream.h"
|
|
#include "nls.h"
|
|
#include "pathnames.h"
|
|
@@ -220,7 +221,7 @@ static int decode(const char *name, const CODE *codetab)
|
|
return -1;
|
|
}
|
|
for (c = codetab; c->c_name; c++)
|
|
- if (!strcasecmp(name, c->c_name))
|
|
+ if (!c_strcasecmp(name, c->c_name))
|
|
return (c->c_val);
|
|
|
|
return -1;
|
|
diff --git a/misc-utils/lsclocks.c b/misc-utils/lsclocks.c
|
|
index 0a87256..376bc6e 100644
|
|
--- a/misc-utils/lsclocks.c
|
|
+++ b/misc-utils/lsclocks.c
|
|
@@ -31,6 +31,7 @@
|
|
#include <linux/rtc.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "strutils.h"
|
|
#include "timeutils.h"
|
|
@@ -172,7 +173,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c
|
|
index bbf5d38..6cc7431 100644
|
|
--- a/misc-utils/lslocks.c
|
|
+++ b/misc-utils/lslocks.c
|
|
@@ -43,6 +43,7 @@
|
|
#include "xalloc.h"
|
|
#include "strutils.h"
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "list.h"
|
|
#include "closestream.h"
|
|
#include "optutils.h"
|
|
@@ -552,7 +553,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/misc-utils/uuidparse.c b/misc-utils/uuidparse.c
|
|
index 7ad1e2e..98f2aee 100644
|
|
--- a/misc-utils/uuidparse.c
|
|
+++ b/misc-utils/uuidparse.c
|
|
@@ -48,6 +48,7 @@
|
|
#include <uuid.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "closestream.h"
|
|
#include "nls.h"
|
|
#include "optutils.h"
|
|
@@ -118,7 +119,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
|
|
index 148907f..4bd2e58 100644
|
|
--- a/misc-utils/wipefs.c
|
|
+++ b/misc-utils/wipefs.c
|
|
@@ -40,6 +40,7 @@
|
|
#include "all-io.h"
|
|
#include "match.h"
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "closestream.h"
|
|
#include "optutils.h"
|
|
#include "blkdev.h"
|
|
@@ -126,7 +127,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/schedutils/ionice.c b/schedutils/ionice.c
|
|
index 6e897ec..0ac65b1 100644
|
|
--- a/schedutils/ionice.c
|
|
+++ b/schedutils/ionice.c
|
|
@@ -19,6 +19,7 @@
|
|
#include "nls.h"
|
|
#include "strutils.h"
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "closestream.h"
|
|
|
|
static int tolerant;
|
|
@@ -65,7 +66,7 @@ static int parse_ioclass(const char *str)
|
|
size_t i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(to_prio); i++)
|
|
- if (!strcasecmp(str, to_prio[i]))
|
|
+ if (!c_strcasecmp(str, to_prio[i]))
|
|
return i;
|
|
return -1;
|
|
}
|
|
diff --git a/sys-utils/chmem.c b/sys-utils/chmem.c
|
|
index 4105d19..69e04fe 100644
|
|
--- a/sys-utils/chmem.c
|
|
+++ b/sys-utils/chmem.c
|
|
@@ -25,6 +25,7 @@
|
|
#include <dirent.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "path.h"
|
|
#include "strutils.h"
|
|
@@ -84,7 +85,7 @@ static int zone_name_to_id(const char *name)
|
|
size_t i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(zone_names); i++) {
|
|
- if (!strcasecmp(name, zone_names[i]))
|
|
+ if (!c_strcasecmp(name, zone_names[i]))
|
|
return i;
|
|
}
|
|
return -1;
|
|
@@ -133,7 +134,7 @@ static int chmem_size(struct chmem_desc *desc, int enable, int zone_id)
|
|
zn = zone_names[zone_id];
|
|
if (enable && !strcasestr(line, zn))
|
|
continue;
|
|
- if (!enable && strncasecmp(line, zn, strlen(zn)) != 0)
|
|
+ if (!enable && c_strncasecmp(line, zn, strlen(zn)) != 0)
|
|
continue;
|
|
} else if (enable) {
|
|
/* By default, use zone Movable for online, if valid */
|
|
@@ -218,7 +219,7 @@ static int chmem_range(struct chmem_desc *desc, int enable, int zone_id)
|
|
warnx(_("%s enable failed: Zone mismatch"), str);
|
|
continue;
|
|
}
|
|
- if (!enable && strncasecmp(line, zn, strlen(zn)) != 0) {
|
|
+ if (!enable && c_strncasecmp(line, zn, strlen(zn)) != 0) {
|
|
warnx(_("%s disable failed: Zone mismatch"), str);
|
|
continue;
|
|
}
|
|
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
|
|
index 75ca4b6..dc9a287 100644
|
|
--- a/sys-utils/dmesg.c
|
|
+++ b/sys-utils/dmesg.c
|
|
@@ -29,6 +29,7 @@
|
|
#include <fcntl.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "colors.h"
|
|
#include "nls.h"
|
|
#include "strutils.h"
|
|
@@ -460,7 +461,7 @@ static int parse_level(const char *str, size_t len)
|
|
for (i = 0; i < ARRAY_SIZE(level_names); i++) {
|
|
const char *n = level_names[i].name;
|
|
|
|
- if (strncasecmp(str, n, len) == 0 && *(n + len) == '\0')
|
|
+ if (c_strncasecmp(str, n, len) == 0 && *(n + len) == '\0')
|
|
return i + offset;
|
|
}
|
|
}
|
|
@@ -498,7 +499,7 @@ static int parse_facility(const char *str, size_t len)
|
|
for (i = 0; i < ARRAY_SIZE(facility_names); i++) {
|
|
const char *n = facility_names[i].name;
|
|
|
|
- if (strncasecmp(str, n, len) == 0 && *(n + len) == '\0')
|
|
+ if (c_strncasecmp(str, n, len) == 0 && *(n + len) == '\0')
|
|
return i;
|
|
}
|
|
}
|
|
diff --git a/sys-utils/irq-common.c b/sys-utils/irq-common.c
|
|
index f069d8a..e546fcc 100644
|
|
--- a/sys-utils/irq-common.c
|
|
+++ b/sys-utils/irq-common.c
|
|
@@ -25,6 +25,7 @@
|
|
#include <libsmartcols.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "pathnames.h"
|
|
#include "strutils.h"
|
|
@@ -89,7 +90,7 @@ int irq_column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
@@ -407,13 +408,13 @@ static void sort_result(struct irq_output *out,
|
|
|
|
void set_sort_func_by_name(struct irq_output *out, const char *name)
|
|
{
|
|
- if (strcasecmp(name, "IRQ") == 0)
|
|
+ if (c_strcasecmp(name, "IRQ") == 0)
|
|
out->sort_cmp_func = cmp_interrupts;
|
|
- else if (strcasecmp(name, "TOTAL") == 0)
|
|
+ else if (c_strcasecmp(name, "TOTAL") == 0)
|
|
out->sort_cmp_func = cmp_total;
|
|
- else if (strcasecmp(name, "DELTA") == 0)
|
|
+ else if (c_strcasecmp(name, "DELTA") == 0)
|
|
out->sort_cmp_func = cmp_delta;
|
|
- else if (strcasecmp(name, "NAME") == 0)
|
|
+ else if (c_strcasecmp(name, "NAME") == 0)
|
|
out->sort_cmp_func = cmp_name;
|
|
else
|
|
errx(EXIT_FAILURE, _("unsupported column name to sort output"));
|
|
diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c
|
|
index 2a24b3d..e06047c 100644
|
|
--- a/sys-utils/ldattach.c
|
|
+++ b/sys-utils/ldattach.c
|
|
@@ -22,6 +22,7 @@
|
|
#include <unistd.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "all-io.h"
|
|
#include "nls.h"
|
|
#include "strutils.h"
|
|
@@ -152,7 +153,7 @@ static int lookup_table(const struct ld_table *tab, const char *str)
|
|
const struct ld_table *t;
|
|
|
|
for (t = tab; t && t->name; t++)
|
|
- if (!strcasecmp(t->name, str))
|
|
+ if (!c_strcasecmp(t->name, str))
|
|
return t->value;
|
|
return -1;
|
|
}
|
|
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
|
|
index 7134542..eafab72 100644
|
|
--- a/sys-utils/losetup.c
|
|
+++ b/sys-utils/losetup.c
|
|
@@ -26,6 +26,7 @@
|
|
#include <libsmartcols.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "strutils.h"
|
|
#include "loopdev.h"
|
|
@@ -124,7 +125,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
|
|
index ffec372..108efb1 100644
|
|
--- a/sys-utils/lscpu.c
|
|
+++ b/sys-utils/lscpu.c
|
|
@@ -29,6 +29,7 @@
|
|
|
|
#include <libsmartcols.h>
|
|
|
|
+#include "cctype.h"
|
|
#include "closestream.h"
|
|
#include "optutils.h"
|
|
#include "c_strtod.h"
|
|
@@ -186,7 +187,7 @@ cpu_column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(coldescs_cpu); i++) {
|
|
const char *cn = coldescs_cpu[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
@@ -201,7 +202,7 @@ cache_column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(coldescs_cache); i++) {
|
|
const char *cn = coldescs_cache[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c
|
|
index 133957e..693be9b 100644
|
|
--- a/sys-utils/lsipc.c
|
|
+++ b/sys-utils/lsipc.c
|
|
@@ -35,6 +35,7 @@
|
|
#include <libsmartcols.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "closestream.h"
|
|
#include "strutils.h"
|
|
@@ -244,7 +245,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(coldescs); i++) {
|
|
const char *cn = coldescs[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz)) {
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz)) {
|
|
if (i > COL_CTIME) {
|
|
if (i >= LOWER && i <= UPPER)
|
|
return i;
|
|
diff --git a/sys-utils/lsmem.c b/sys-utils/lsmem.c
|
|
index 9aa6745..2b79114 100644
|
|
--- a/sys-utils/lsmem.c
|
|
+++ b/sys-utils/lsmem.c
|
|
@@ -11,23 +11,26 @@
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*/
|
|
-#include <c.h>
|
|
-#include <nls.h>
|
|
-#include <path.h>
|
|
-#include <strutils.h>
|
|
-#include <closestream.h>
|
|
-#include <xalloc.h>
|
|
-#include <getopt.h>
|
|
-#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
+#include <getopt.h>
|
|
+#include <stdbool.h>
|
|
#include <dirent.h>
|
|
#include <fcntl.h>
|
|
#include <inttypes.h>
|
|
#include <assert.h>
|
|
-#include <optutils.h>
|
|
+
|
|
#include <libsmartcols.h>
|
|
|
|
+#include "c.h"
|
|
+#include "cctype.h"
|
|
+#include "nls.h"
|
|
+#include "path.h"
|
|
+#include "strutils.h"
|
|
+#include "closestream.h"
|
|
+#include "xalloc.h"
|
|
+#include "optutils.h"
|
|
+
|
|
#define _PATH_SYS_MEMORY "/sys/devices/system/memory"
|
|
|
|
#define MEMORY_STATE_ONLINE 0
|
|
@@ -150,7 +153,7 @@ static int zone_name_to_id(const char *name)
|
|
size_t i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(zone_names); i++) {
|
|
- if (!strcasecmp(name, zone_names[i]))
|
|
+ if (!c_strcasecmp(name, zone_names[i]))
|
|
return i;
|
|
}
|
|
return ZONE_UNKNOWN;
|
|
@@ -166,7 +169,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(coldescs); i++) {
|
|
const char *cn = coldescs[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
@@ -737,7 +740,7 @@ int main(int argc, char **argv)
|
|
int split[ARRAY_SIZE(coldescs)] = { 0 };
|
|
static size_t nsplits = 0;
|
|
|
|
- if (strcasecmp(splitarg, "none") == 0)
|
|
+ if (c_strcasecmp(splitarg, "none") == 0)
|
|
;
|
|
else if (string_add_to_idarray(splitarg, split, ARRAY_SIZE(split),
|
|
&nsplits, column_name_to_id) < 0)
|
|
diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c
|
|
index fc590f8..812afe7 100644
|
|
--- a/sys-utils/lsns.c
|
|
+++ b/sys-utils/lsns.c
|
|
@@ -42,6 +42,7 @@
|
|
#include "nls.h"
|
|
#include "xalloc.h"
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "widechar.h"
|
|
#include "list.h"
|
|
#include "closestream.h"
|
|
@@ -271,7 +272,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c
|
|
index 57c11fb..fbab008 100644
|
|
--- a/sys-utils/prlimit.c
|
|
+++ b/sys-utils/prlimit.c
|
|
@@ -24,6 +24,7 @@
|
|
#include <libsmartcols.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "xalloc.h"
|
|
#include "strutils.h"
|
|
@@ -277,7 +278,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/sys-utils/rfkill.c b/sys-utils/rfkill.c
|
|
index 860e864..d1c38b0 100644
|
|
--- a/sys-utils/rfkill.c
|
|
+++ b/sys-utils/rfkill.c
|
|
@@ -30,6 +30,7 @@
|
|
#include <sys/time.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "closestream.h"
|
|
#include "nls.h"
|
|
#include "optutils.h"
|
|
@@ -156,7 +157,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
|
|
index 15efa48..7667857 100644
|
|
--- a/sys-utils/swapon.c
|
|
+++ b/sys-utils/swapon.c
|
|
@@ -29,6 +29,7 @@
|
|
#include <libsmartcols.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "bitops.h"
|
|
#include "blkdev.h"
|
|
@@ -158,7 +159,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/sys-utils/wdctl.c b/sys-utils/wdctl.c
|
|
index ba013a3..6559b54 100644
|
|
--- a/sys-utils/wdctl.c
|
|
+++ b/sys-utils/wdctl.c
|
|
@@ -32,6 +32,7 @@
|
|
|
|
#include "nls.h"
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "xalloc.h"
|
|
#include "closestream.h"
|
|
#include "optutils.h"
|
|
@@ -165,7 +166,7 @@ static long name2bit(const char *name, size_t namesz)
|
|
|
|
for (i = 0; i < ARRAY_SIZE(wdflags); i++) {
|
|
const char *cn = wdflags[i].name;
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return wdflags[i].flag;
|
|
}
|
|
warnx(_("unknown flag: %s"), name);
|
|
@@ -178,7 +179,7 @@ static int column2id(const char *name, size_t namesz)
|
|
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
|
|
index dfe752b..9aa7296 100644
|
|
--- a/sys-utils/zramctl.c
|
|
+++ b/sys-utils/zramctl.c
|
|
@@ -29,6 +29,7 @@
|
|
#include <libsmartcols.h>
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "nls.h"
|
|
#include "closestream.h"
|
|
#include "strutils.h"
|
|
@@ -143,7 +144,7 @@ static int column_name_to_id(const char *name, size_t namesz)
|
|
for (i = 0; i < ARRAY_SIZE(infos); i++) {
|
|
const char *cn = infos[i].name;
|
|
|
|
- if (!strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
+ if (!c_strncasecmp(name, cn, namesz) && !*(cn + namesz))
|
|
return i;
|
|
}
|
|
warnx(_("unknown column: %s"), name);
|
|
diff --git a/term-utils/script.c b/term-utils/script.c
|
|
index 4da25fa..9007024 100644
|
|
--- a/term-utils/script.c
|
|
+++ b/term-utils/script.c
|
|
@@ -58,6 +58,7 @@
|
|
#include "closestream.h"
|
|
#include "nls.h"
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "ttyutils.h"
|
|
#include "all-io.h"
|
|
#include "monotonic.h"
|
|
@@ -864,9 +865,9 @@ int main(int argc, char **argv)
|
|
ctl.quiet = 1;
|
|
break;
|
|
case 'm':
|
|
- if (strcasecmp(optarg, "classic") == 0)
|
|
+ if (c_strcasecmp(optarg, "classic") == 0)
|
|
format = SCRIPT_FMT_TIMING_SIMPLE;
|
|
- else if (strcasecmp(optarg, "advanced") == 0)
|
|
+ else if (c_strcasecmp(optarg, "advanced") == 0)
|
|
format = SCRIPT_FMT_TIMING_MULTI;
|
|
else
|
|
errx(EXIT_FAILURE, _("unsupported logging format: '%s'"), optarg);
|
|
diff --git a/tests/helpers/test_mkfds.c b/tests/helpers/test_mkfds.c
|
|
index 5ceaa3f..f7673c8 100644
|
|
--- a/tests/helpers/test_mkfds.c
|
|
+++ b/tests/helpers/test_mkfds.c
|
|
@@ -18,6 +18,7 @@
|
|
*/
|
|
|
|
#include "c.h"
|
|
+#include "cctype.h"
|
|
#include "xalloc.h"
|
|
#include "test_mkfds.h"
|
|
#include "exitcodes.h"
|
|
@@ -242,10 +243,10 @@ static union value boolean_read(const char *arg, const union value *defv)
|
|
if (!arg)
|
|
return *defv;
|
|
|
|
- if (strcasecmp(arg, "true") == 0
|
|
+ if (c_strcasecmp(arg, "true") == 0
|
|
|| strcmp(arg, "1") == 0
|
|
- || strcasecmp(arg, "yes") == 0
|
|
- || strcasecmp(arg, "y") == 0)
|
|
+ || c_strcasecmp(arg, "yes") == 0
|
|
+ || c_strcasecmp(arg, "y") == 0)
|
|
r.boolean = true;
|
|
else
|
|
r.boolean = false;
|