Browse code

Fixed "while loop has empty body" warning with macOS compiler

Andrew Alderwick authored on 10/10/2021 19:09:20
Showing 1 changed files
... ...
@@ -51,7 +51,7 @@ static int   cpos(char *s, char a){ int i = 0; char c; while((c = s[i++])) if(c
51 51
 static int   scmp(char *a, char *b, int len) { int i = 0; while(a[i] == b[i]) if(!a[i] || ++i >= len) return 1; return 0; } /* string compare */
52 52
 static int   sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')) return 0; return i > 1; } /* string is hexadecimal */
53 53
 static int   shex(char *s) { int n = 0, i = 0; char c; while((c = s[i++])) if(c >= '0' && c <= '9') n = n * 16 + (c - '0'); else if(c >= 'a' && c <= 'f') n = n * 16 + 10 + (c - 'a'); return n; } /* string to num */
54
-static int   slen(char *s) { int i = 0; while(s[i] && s[++i]) ; return i; } /* string length */
54
+static int   slen(char *s) { int i = 0; while(s[i]) ++i; return i; } /* string length */
55 55
 static char *scpy(char *src, char *dst, int len) { int i = 0; while((dst[i] = src[i]) && i < len - 2) i++; dst[i + 1] = '\0'; return dst; } /* string copy */
56 56
 static char *scat(char *dst, const char *src) { char *ptr = dst + slen(dst); while(*src) *ptr++ = *src++; *ptr = '\0'; return dst; } /* string cat */
57 57