screen-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[screen-devel] [PATCH 7/8] Display: Convert strlen_onscreen to be unsign


From: Kieran Bingham
Subject: [screen-devel] [PATCH 7/8] Display: Convert strlen_onscreen to be unsigned like strlen
Date: Sun, 4 Oct 2015 16:52:32 +0100

Currently there are different use cases of both signed and unsigned
char arrays passed into this function.

Upon initial examination of the function, I believe that it is safe
to use an unsigned type, matching the c library strlen declaration,
and then unifying calls so that they do not have to simply cast
the array types.

The only part of the function which uses the actual (signed/unsigned)
type of the char is the call to FromUtf8() which itself converts to a
signed int.

Converting to use signed char* here seems to be a reasonable fix for the
compiler warnings. (rather than casting the warning lines to unsigned)

Signed-off-by: Kieran Bingham <address@hidden>
---
 src/display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/display.c b/src/display.c
index db7b0d5..72f3236 100644
--- a/src/display.c
+++ b/src/display.c
@@ -1581,7 +1581,7 @@ static void RemoveStatusMinWait()
        RemoveStatus();
 }
 
-static int strlen_onscreen(unsigned char *c, unsigned char *end)
+static int strlen_onscreen(char *c, char *end)
 {
        int len = 0;
        while (*c && (!end || c < end)) {
@@ -1608,7 +1608,7 @@ static int PrePutWinMsg(char *s, int start, int max)
           Ideally, this would not be necessary. But fixing it the Right Way 
will
           probably take way more time. So this will have to do for now. */
        if (D_encoding == UTF8) {
-               int chars = strlen_onscreen((unsigned char *)(s + start), 
(unsigned char *)(s + max));
+               int chars = strlen_onscreen((s + start), (s + max));
                D_encoding = 0;
                PutWinMsg(s, start, max + ((max - start) - chars));     /* 
Multibyte count */
                D_encoding = UTF8;
-- 
2.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]