From owner-svn-src-all@freebsd.org Tue May 17 07:34:33 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D37D9B3E37D; Tue, 17 May 2016 07:34:33 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from gw.catspoiler.org (unknown [IPv6:2602:304:b010:ef20::f2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gw.catspoiler.org", Issuer "gw.catspoiler.org" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 94B8413CF; Tue, 17 May 2016 07:34:33 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.15.2/8.15.2) with ESMTP id u4H7YNUX074219; Tue, 17 May 2016 00:34:27 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Message-Id: <201605170734.u4H7YNUX074219@gw.catspoiler.org> Date: Tue, 17 May 2016 00:34:23 -0700 (PDT) From: Don Lewis Subject: Re: svn commit: r300005 - head/usr.bin/ncal To: cem@FreeBSD.org cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org In-Reply-To: <201605170607.u4H67VJL074016@gw.catspoiler.org> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2016 07:34:33 -0000 On 16 May, To: cem@FreeBSD.org wrote: > On 16 May, Conrad Meyer wrote: >> On Mon, May 16, 2016 at 10:05 PM, Don Lewis wrote: >>> Author: truckman >>> Date: Tue May 17 05:05:30 2016 >>> New Revision: 300005 >>> URL: https://svnweb.freebsd.org/changeset/base/300005 >>> >>> Log: >>> swprintf() and apparently wcsftime() want the their output buffer size >>> specified in terms of the the number of wide characters and not >>> sizeof(buffer). >>> ... >>> Modified: head/usr.bin/ncal/ncal.c >>> ============================================================================== >>> --- head/usr.bin/ncal/ncal.c Tue May 17 04:53:21 2016 (r300004) >>> +++ head/usr.bin/ncal/ncal.c Tue May 17 05:05:30 2016 (r300005) >>> @@ -642,8 +642,8 @@ monthrangeb(int y, int m, int jd_flag, i >>> wprintf(L"%-*ls ", >>> mw, wcenter(ws, year[i].name, mw)); >>> else { >>> - swprintf(ws, sizeof(ws), L"%-ls %d", >>> - year[i].name, M2Y(m + i)); >>> + swprintf(ws, sizeof(ws)/sizeof(ws[0]), >> >> Normally we spell this nitems(ws). >> >>> + L"%-ls %d", year[i].name, M2Y(m + i)); >>> wprintf(L"%-*ls ", mw, wcenter(ws1, ws, mw)); >>> } >>> printf("\n"); >>> @@ -958,7 +958,7 @@ mkweekdays(struct weekdays *wds) >>> >>> for (i = 0; i != 7; i++) { >>> tm.tm_wday = (i+1) % 7; >>> - wcsftime(buf, sizeof(buf), L"%a", &tm); >>> + wcsftime(buf, sizeof(buf)/sizeof(buf[0]), L"%a", &tm); >> >> This one can be nitems(buf) too. >> >>> for (len = 2; len > 0; --len) { >>> if ((width = wcswidth(buf, len)) <= 2) >>> break; >>> > > I thought about that, but I didn't see any obvious signs that > was included. It's not included indirectly, either. cc -O2 -pipe -g -MD -MF.depend.ncal.o -MTncal.o -std=gnu99 -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations -Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Qunused-arguments -c /usr/src/usr.bin/ncal/ncal.c -o ncal.o /usr/src/usr.bin/ncal/ncal.c:645:18: error: implicit declaration of function 'nitems' is invalid in C99 [-Werror,-Wimplicit-function-declaration] swprintf(ws, nitems(ws), L"%-ls %d",