about summary refs log tree commit diff
path: root/Src/utils.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2005-11-15 08:44:24 +0000
committerWayne Davison <wayned@users.sourceforge.net>2005-11-15 08:44:24 +0000
commit01875dc4a1fbbe7088d4e0004de082c39f6a6ef1 (patch)
tree0be3bcf65e1250889652d5ec559e4879f5eecf71 /Src/utils.c
parentd8838293f533a6cab5902611fe72bc5d21bb16fa (diff)
downloadzsh-01875dc4a1fbbe7088d4e0004de082c39f6a6ef1.tar.gz
zsh-01875dc4a1fbbe7088d4e0004de082c39f6a6ef1.tar.xz
zsh-01875dc4a1fbbe7088d4e0004de082c39f6a6ef1.zip
Changed ztrcmp() to take normal char pointers, not unsigned char.
Diffstat (limited to 'Src/utils.c')
-rw-r--r--Src/utils.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/Src/utils.c b/Src/utils.c
index 58bf3286f..f32b162f7 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3223,35 +3223,34 @@ unmeta(const char *file_name)
     return fn;
 }
 
-/* Unmetafy and compare two strings, with unsigned characters. *
- * "a\0" sorts after "a".                                      */
+/* Unmetafy and compare two strings, comparing unsigned character values.
+ * "a\0" sorts after "a".  */
 
 /**/
 int
-ztrcmp(unsigned char const *s1, unsigned char const *s2)
+ztrcmp(char const *s1, char const *s2)
 {
     int c1, c2;
 
-    while(*s1 && *s1 == *s2) {
+    while (*s1 && *s1 == *s2) {
 	s1++;
 	s2++;
     }
 
-    if(!(c1 = *s1))
+    if (!(c1 = STOUC(*s1)))
 	c1 = -1;
-    else if(c1 == STOUC(Meta))
-	c1 = *++s1 ^ 32;
-    if(!(c2 = *s2))
+    else if (c1 == STOUC(Meta))
+	c1 = STOUC(*++s1) ^ 32;
+    if (!(c2 = STOUC(*s2)))
 	c2 = -1;
-    else if(c2 == STOUC(Meta))
-	c2 = *++s2 ^ 32;
+    else if (c2 == STOUC(Meta))
+	c2 = STOUC(*++s2) ^ 32;
 
-    if(c1 == c2)
+    if (c1 == c2)
 	return 0;
-    else if(c1 < c2)
+    if (c1 < c2)
 	return -1;
-    else
-	return 1;
+    return 1;
 }
 
 /* Return the unmetafied length of a metafied string. */
@@ -3262,7 +3261,7 @@ ztrlen(char const *s)
 {
     int l;
 
-    for (l = 0; *s; l++)
+    for (l = 0; *s; l++) {
 	if (*s++ == Meta) {
 #ifdef DEBUG
 	    if (! *s)
@@ -3271,6 +3270,7 @@ ztrlen(char const *s)
 #endif
 	    s++;
 	}
+    }
     return l;
 }
 
@@ -3282,7 +3282,7 @@ ztrsub(char const *t, char const *s)
 {
     int l = t - s;
 
-    while (s != t)
+    while (s != t) {
 	if (*s++ == Meta) {
 #ifdef DEBUG
 	    if (! *s || s == t)
@@ -3292,6 +3292,7 @@ ztrsub(char const *t, char const *s)
 	    s++;
 	    l--;
 	}
+    }
     return l;
 }
 
@@ -3586,9 +3587,10 @@ mb_width(const char *s)
 mod_export int
 hasspecial(char const *s)
 {
-    for (; *s; s++)
+    for (; *s; s++) {
 	if (ispecial(*s == Meta ? *++s ^ 32 : *s))
 	    return 1;
+    }
     return 0;
 }