Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Unicode, Korean, normalization form, Mac OS X and tab completion



It seems we need to cast the return value of iconv() to a "signed" integer
for correctly detecting the error.


diff --git a/Src/utils.c b/Src/utils.c
index 8b512bb..2693ecd 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4296,14 +4296,13 @@ zreaddir(DIR *dir, int ignoredots)
 	conv_name = zrealloc(conv_name, orig_name_len+1);
 	conv_name_ptr = conv_name;
 	conv_name_len = orig_name_len;
-	if (iconv(conv_ds,
+	if ((long)iconv(conv_ds,
 		  &orig_name_ptr, &orig_name_len,
-		  &conv_name_ptr, &conv_name_len) >= 0) {
-	  if (orig_name_len == 0) {
+		  &conv_name_ptr, &conv_name_len) >= 0 &&
+	    orig_name_len == 0) {
 	    /* Completely converted, metafy and return */
 	    *conv_name_ptr = '\0';
 	    return metafy(conv_name, -1, META_STATIC);
-	  }
 	}
 	/* Error, or conversion incomplete, keep the original name */
     }





Messages sorted by: Reverse Date, Date, Thread, Author