X-Original-To: bind9-confidential@bugs.isc.org X-RT-Interface: Email Subject: Re: [ISC-Bugs #46039] strftime is not very platform neutral Date: Tue, 19 Sep 2017 19:15:38 +1000 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.0 Delivered-To: bind9-confidential@bugs.isc.org References: <021001d33122$4b4e0610$e1ea1230$@wangsu.com> Return-Path: Received: from mx.pao1.isc.org (mx.pao1.isc.org [IPv6:2001:4f8:0:2::2b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx.pao1.isc.org", Issuer "COMODO RSA Organization Validation Secure Server CA" (not verified)) by bugs.isc.org (Postfix) with ESMTPS id 806A9D78B0A for ; Tue, 19 Sep 2017 09:15:44 +0000 (UTC) Received: from zmx1.isc.org (zmx1.isc.org [149.20.0.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.pao1.isc.org (Postfix) with ESMTPS id 5ADFE349D5A for ; Tue, 19 Sep 2017 09:15:41 +0000 (UTC) Received: from zmx1.isc.org (localhost [127.0.0.1]) by zmx1.isc.org (Postfix) with ESMTPS id 48379160082 for ; Tue, 19 Sep 2017 09:15:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zmx1.isc.org (Postfix) with ESMTP id 37FDF160081 for ; Tue, 19 Sep 2017 09:15:41 +0000 (UTC) Received: from zmx1.isc.org ([127.0.0.1]) by localhost (zmx1.isc.org [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qcyZTt2KNzFX for ; Tue, 19 Sep 2017 09:15:41 +0000 (UTC) Received: from rock.dv.isc.org (c27-253-115-14.carlnfd2.nsw.optusnet.com.au [27.253.115.14]) by zmx1.isc.org (Postfix) with ESMTPSA id C328A160041 for ; Tue, 19 Sep 2017 09:15:40 +0000 (UTC) Received: from rock.dv.isc.org (localhost [IPv6:::1]) by rock.dv.isc.org (Postfix) with ESMTP id 3917986AB66C for ; Tue, 19 Sep 2017 19:15:38 +1000 (AEST) From: "Mark Andrews" Message-ID: <20170919091538.3917986AB66C@rock.dv.isc.org> To: bind9-confidential@isc.org content-type: text/plain; charset="utf-8" X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mx.pao1.isc.org From marka@isc.org Tue Sep 19 09:15:44 2017 X-RT-Original-Encoding: utf-8 X-RT-Incoming-Encryption: Not encrypted In-Reply-To: Your message of "Tue, 19 Sep 2017 08:36:19 +0000." RT-Message-ID: Content-Length: 1177 Does this work for you? diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 562ef79a73..f67f1080df 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -231,7 +231,11 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) { isc_uint64_t diff; time_t tnow; struct tm tmnow; +#ifdef WIN32 + wchar_t time_str[100]; +#else char time_str[100]; +#endif char fromtext[ISC_SOCKADDR_FORMATSIZE]; isc_sockaddr_format(from, fromtext, sizeof(fromtext)); @@ -250,9 +254,15 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) { tmnow = *localtime(&tnow); #endif +#ifdef WIN32 + if (wcsftime(time_str, sizeof(time_str)/sizeof(time_str[0]), + "%a %b %d %H:%M:%S %Z %Y", &tmnow) > 0U) + printf(";; WHEN: %ls\n", time_str); +#else if (strftime(time_str, sizeof(time_str), "%a %b %d %H:%M:%S %Z %Y", &tmnow) > 0U) printf(";; WHEN: %s\n", time_str); +#endif if (query->lookup->doing_xfr) { printf(";; XFR size: %u records (messages %u, " "bytes %" ISC_PRINT_QUADFORMAT "u)\n", -- Mark Andrews, ISC 1 Seymour St., Dundas Valley, NSW 2117, Australia PHONE: +61 2 9871 4742 INTERNET: marka@isc.org