From owner-svn-src-all@freebsd.org Tue May 17 06:01:12 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 7B380B3E371; Tue, 17 May 2016 06:01:12 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-oi0-f44.google.com (mail-oi0-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3FD7D1E26; Tue, 17 May 2016 06:01:11 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-oi0-f44.google.com with SMTP id x201so9243084oif.3; Mon, 16 May 2016 23:01:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:cc; bh=Mv85xx285Ws4JyY6aX99eA2x7w753DwD98Dg6yL3m3w=; b=bvdzIaHhhJAdAbKzQk2SFZ3daMaQPlBdTqHcmkNgO9Xy8u0TbiPEdLj3gwYkgzgR1y BeK5rskhsJNmqa1jaFv6bzaI3zse4OJxE60N55VJ+AgsonGRbGNTZAxIr/PTeDRiC5FQ Py9uT+41y+Eo0g72KUTlqQV0fCWndAQ7RJ8Bhj6NTle7GtkX+tzD1BgyQYCbrERfhV8L Vk2MHBPXXCu5Fhh6s3mtuHEx1Y7pxZ+0DCkpSjOQUwsA5qYHJZxxdxjolc5l87DqWI77 IG1kkGo+LduDv/FKsYwuZBxUh+TjJRy0K4YxKsFnsQZI5oc5HDw5WyZpMhPh+mHM2vak z9hg== X-Gm-Message-State: AOPr4FVccbYqfmaoQMrwqiYh6vcSIRP4aisAVF2dWr+FDBaNDN2r70SslgeIecdGBhjZNA== X-Received: by 10.157.8.133 with SMTP id 5mr13036262otf.52.1463464475688; Mon, 16 May 2016 22:54:35 -0700 (PDT) Received: from mail-oi0-f46.google.com (mail-oi0-f46.google.com. [209.85.218.46]) by smtp.gmail.com with ESMTPSA id z3sm347187ota.21.2016.05.16.22.54.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 May 2016 22:54:35 -0700 (PDT) Received: by mail-oi0-f46.google.com with SMTP id x201so9075367oif.3; Mon, 16 May 2016 22:54:35 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.157.35.225 with SMTP id t88mr19998957otb.18.1463464475194; Mon, 16 May 2016 22:54:35 -0700 (PDT) Reply-To: cem@FreeBSD.org Received: by 10.157.19.20 with HTTP; Mon, 16 May 2016 22:54:35 -0700 (PDT) In-Reply-To: <201605170505.u4H55Uwr091152@repo.freebsd.org> References: <201605170505.u4H55Uwr091152@repo.freebsd.org> Date: Mon, 16 May 2016 22:54:35 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r300005 - head/usr.bin/ncal From: Conrad Meyer To: Don Lewis Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 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 06:01:12 -0000 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; > Best, Conrad