From c200c7cf30dd09723543a658b5b3550b05a84623 Mon Sep 17 00:00:00 2001 From: Ian Darwin Date: Tue, 4 Jun 2013 21:51:00 +0000 Subject: [PATCH] Account for wcwidth might return -1. | | >From OpenBSD revision 1.23 | date: 2011/04/15 16:05:34; author: stsp; state: Exp; lines: +7 -3 e! | Make the file_mbswidth() function cope if wcwidth() returns -1. | ok mikeb millert Here, ok Christos. --- src/file.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/file.c b/src/file.c index d9180bc8..eb7c6bcf 100644 --- a/src/file.c +++ b/src/file.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: file.c,v 1.148 2012/11/21 16:27:39 christos Exp $") +FILE_RCSID("@(#)$File: file.c,v 1.149 2013/01/07 18:20:19 christos Exp $") #endif /* lint */ #include "magic.h" @@ -465,8 +465,11 @@ file_mbswidth(const char *s) * is always right */ width++; - } else - width += wcwidth(nextchar); + } else { + w = wcwidth(nextchar); + if (w > 0) + width += w; + } s += bytesconsumed, n -= bytesconsumed; } -- 2.50.0