]> Trent Huber's Code - xpmview.git/commitdiff
Revert "if else consistency"
authorTrent Huber <trentmhuber@gmail.com>
Fri, 23 May 2025 08:11:21 +0000 (04:11 -0400)
committerTrent Huber <trentmhuber@gmail.com>
Fri, 23 May 2025 08:11:21 +0000 (04:11 -0400)
This reverts commit dc1c0e249d9aa4c091d83e5e6107138e91d7cd4f.

src/xpm.c

index deac9b7a4311ae61c59ada94cb24e6c191a13591..70761b576208bfc4ab879f0b9fb661f9c2240e42 100644 (file)
--- a/src/xpm.c
+++ b/src/xpm.c
@@ -36,10 +36,10 @@ static char *arrname(char *p, size_t l) {
 
    for (; (step = 5); l = l > step ? l - step : 0, p += step) {
        if (l == 0) return NULL;
-       if (space(*p) || *p == '*') step = 1; else
-           if (strncmp(p, "const", 5) != 0
-               || (!space(*(p + step)) && *(p + step) != '*'))
-               break;
+       if (space(*p) || *p == '*') step = 1;
+       else if (strncmp(p, "const", 5) != 0
+                || (!space(*(p + step)) && *(p + step) != '*'))
+           break;
    }
 
    start = p;
@@ -108,18 +108,18 @@ static unsigned int str2color(char **strp) {
    l = i = 0;
 
    // RGB
-   if (**strp == '#') r = strtol(++*strp, strp, 16); else
-
-       // Color names
-       for (; i < numcolors; ++i) {
-           name = colors[i].name;
-           l = strlen(name);
-           if (strncmp(name, *strp, l) == 0
-               && (i == 0 || *(*strp + l) == '\0' || space(*(*strp + l)))) {
-               r = colors[i].value;
-               break;
-           }
+   if (**strp == '#') r = strtol(++*strp, strp, 16);
+
+   // Color names
+   else for (; i < numcolors; ++i) {
+       name = colors[i].name;
+       l = strlen(name);
+       if (strncmp(name, *strp, l) == 0
+           && (i == 0 || *(*strp + l) == '\0' || space(*(*strp + l)))) {
+           r = colors[i].value;
+           break;
        }
+   }
    if (i == numcolors) {
        warnx("`%s' is not a valid color name", *strp);
        return 0;