From: Ian Darwin Date: Tue, 4 Jun 2013 21:51:00 +0000 (+0000) Subject: Account for wcwidth might return -1. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c223876c5e72d895c3acb240e8d0946f3722753f;p=file 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. --- diff --git a/src/file.c b/src/file.c index aa7d5b3c..010e9553 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.149 2013/01/07 18:20:19 christos Exp $") +FILE_RCSID("@(#)$File: file.c,v 1.150 2013/06/04 21:51:00 ian 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; }