summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>2013-02-12 21:47:37 +0100
committerLennart Poettering <lennart@poettering.net>2013-02-13 00:56:13 +0100
commitb43d1d01eabe2cbbf393e8f56b76e182c6069c4c (patch)
tree2c15db7971c0514f3e3f741b44fbe42bd7802fbd
parent641906e9366891e0ad3e6e38b7396a427678c4cf (diff)
util: introduce strcaseeq/strncaseeq
-rw-r--r--src/shared/calendarspec.c8
-rw-r--r--src/shared/util.c4
-rw-r--r--src/shared/util.h2
-rw-r--r--src/udev/scsi_id/scsi_id.c6
4 files changed, 11 insertions, 9 deletions
diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index c2eae3f139..cc680779b5 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -653,7 +653,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
if (!c)
return -ENOMEM;
- if (strcasecmp(p, "hourly") == 0) {
+ if (strcaseeq(p, "hourly")) {
r = const_chain(0, &c->minute);
if (r < 0)
goto fail;
@@ -661,7 +661,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
if (r < 0)
goto fail;
- } else if (strcasecmp(p, "daily") == 0) {
+ } else if (strcaseeq(p, "daily")) {
r = const_chain(0, &c->hour);
if (r < 0)
goto fail;
@@ -672,7 +672,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
if (r < 0)
goto fail;
- } else if (strcasecmp(p, "monthly") == 0) {
+ } else if (strcaseeq(p, "monthly")) {
r = const_chain(1, &c->day);
if (r < 0)
goto fail;
@@ -686,7 +686,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
if (r < 0)
goto fail;
- } else if (strcasecmp(p, "weekly") == 0) {
+ } else if (strcaseeq(p, "weekly")) {
c->weekdays_bits = 1;
diff --git a/src/shared/util.c b/src/shared/util.c
index 8dceb82051..aa0532a2be 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -218,9 +218,9 @@ void close_many(const int fds[], unsigned n_fd) {
int parse_boolean(const char *v) {
assert(v);
- if (streq(v, "1") || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T' || !strcasecmp(v, "on"))
+ if (streq(v, "1") || v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T' || strcaseeq(v, "on"))
return 1;
- else if (streq(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || !strcasecmp(v, "off"))
+ else if (streq(v, "0") || v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F' || strcaseeq(v, "off"))
return 0;
return -EINVAL;
diff --git a/src/shared/util.h b/src/shared/util.h
index cd13457528..3ad90ddce4 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -65,6 +65,8 @@ size_t page_size(void);
#define streq(a,b) (strcmp((a),(b)) == 0)
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
+#define strcaseeq(a,b) (strcasecmp((a),(b)) == 0)
+#define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0)
bool streq_ptr(const char *a, const char *b);
diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index d664787fd9..dcf03eefac 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -227,7 +227,7 @@ static int get_file_options(struct udev *udev,
continue;
str1 = strsep(&buf, "=");
- if (str1 && strcasecmp(str1, "VENDOR") == 0) {
+ if (str1 && strcaseeq(str1, "VENDOR")) {
str1 = get_value(&buf);
if (!str1) {
retval = log_oom();
@@ -236,7 +236,7 @@ static int get_file_options(struct udev *udev,
vendor_in = str1;
str1 = strsep(&buf, "=");
- if (str1 && strcasecmp(str1, "MODEL") == 0) {
+ if (str1 && strcaseeq(str1, "MODEL")) {
str1 = get_value(&buf);
if (!str1) {
retval = log_oom();
@@ -247,7 +247,7 @@ static int get_file_options(struct udev *udev,
}
}
- if (str1 && strcasecmp(str1, "OPTIONS") == 0) {
+ if (str1 && strcaseeq(str1, "OPTIONS")) {
str1 = get_value(&buf);
if (!str1) {
retval = log_oom();