X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftrace%2Fvisbuf.c;h=effa84352b7d9230214018cdaec09978de918bd2;hp=a10b805e29750e812f8c4c4dcac226ce15605396;hb=7d3e03f12f3e179f5780f733fa5b78d981080d48;hpb=0573f2d712e4b5cb2a02a3fe52d513843d536b34 diff --git a/ncurses/trace/visbuf.c b/ncurses/trace/visbuf.c index a10b805e..effa8435 100644 --- a/ncurses/trace/visbuf.c +++ b/ncurses/trace/visbuf.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2001-2011,2012 Free Software Foundation, Inc. * + * Copyright (c) 2001-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -42,7 +42,7 @@ #include #include -MODULE_ID("$Id: visbuf.c,v 1.41 2012/09/01 23:53:30 tom Exp $") +MODULE_ID("$Id: visbuf.c,v 1.43 2014/02/23 01:21:08 tom Exp $") #define NUM_VISBUFS 4 @@ -69,7 +69,7 @@ _nc_vischar(char *tp, unsigned c LIMIT_ARG) if (c == '"' || c == '\\') { *tp++ = '\\'; *tp++ = (char) c; - } else if (is7bits(c) && (isgraph(c) || c == ' ')) { + } else if (is7bits((int)c) && (isgraph((int)c) || c == ' ')) { *tp++ = (char) c; } else if (c == '\n') { *tp++ = '\\'; @@ -262,10 +262,12 @@ _nc_viswibuf(const wint_t *buf) else mybuf = typeMalloc(wchar_t, mylen); } - for (n = 0; buf[n] != 0; ++n) { - mybuf[n] = (wchar_t) buf[n]; + if (mybuf != 0) { + for (n = 0; buf[n] != 0; ++n) { + mybuf[n] = (wchar_t) buf[n]; + } + mybuf[n] = L'\0'; } - mybuf[n] = L'\0'; return _nc_viswbuf2(0, mybuf); }