www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2016/08/07/09:05:28

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to;
bh=KLZsjhhyIDwGaBkxS0eJkaN7BGJbkODrGCQbmZi+uwM=;
b=PymWwQYGHj8PMCYvLOR94ka3hHUJEsEYKVylDqWhXKMZnL/BXUejULI14Q5Orh+vag
s8ektyrP5TDu9QFrIHn5/4OtpIkegIZJDQhXCbztB3PmWBr16yxO5QDDXwQaKeXEyGPh
3eHP+08btdnxlf5pgMCkRY5cXeuBwEk4mv1y3a/tLk98CNLblUBHGIzlcteLq0ltCW2W
0YOefcT8hlMKuM8Qi6lGIHVncBfEhXfmXMUxP/Bhn4lHIqLVV8ALd30Lwib9j0f7byB4
RCsYjcxUuAPyheME49SFqe0Hiw+nMtr94akguqIDSQerMzzehEM5CLcCh+fKdX9sX6XQ
5UbA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20130820;
h=x-gm-message-state:mime-version:in-reply-to:references:from:date
:message-id:subject:to;
bh=KLZsjhhyIDwGaBkxS0eJkaN7BGJbkODrGCQbmZi+uwM=;
b=jo1GFpt3riasO4bs4bBqK0PsPfDhwNd5eQi0Jal2D4MSxKeFR/fyomsn6jjAP2Mlwd
LpLlaBc5koW7uyvl3MOEGTpvUA4y0SlTnLq8yCMBpcoSntZKMr0IsPMYuXtrZHM9JByx
5ys2p12si77D6Xcnfqg/+UNdXdHbGWMghX/Z5g8XZnoPXpKOssiDxIW+EXe6CVh34y6w
mN4FP0VE/g/W9FA6DScVLNJ9/He0aloiUzmx5qUP1Pu2A/l19yCBJUbNWv6v0Hn3GVTS
QKDOKH/42Q7gd3PB/Ys6c4dUhagrIJFgj+5Xjdhcb9WgnCAdQcFCls7d3PFphNKGWX6G
2c9g==
X-Gm-Message-State: AEkoouvfpGIBUzBON7tOpd1+6susiehjfXvgyaqX2J8SQnOErR+HbFUpObbPoGYHe9a0TdnRcIaH6xoK+O4Bfg==
X-Received: by 10.31.149.132 with SMTP id x126mr47083272vkd.71.1470575122153;
Sun, 07 Aug 2016 06:05:22 -0700 (PDT)
MIME-Version: 1.0
In-Reply-To: <CAA-ihx--MPtqRcT62Q6RvFrfGM05BdoZoezeqXLMCSPoZJxC7Q@mail.gmail.com>
References: <CAA-ihx-exBLSkvQqFz5BHj_Ma1Cqn7bUqYwSPvUMEh7_-ARJEA AT mail DOT gmail DOT com>
<CAA-ihx--MPtqRcT62Q6RvFrfGM05BdoZoezeqXLMCSPoZJxC7Q AT mail DOT gmail DOT com>
From: "Rugxulo (rugxulo AT gmail DOT com) [via djgpp-workers AT delorie DOT com]" <djgpp-workers AT delorie DOT com>
Date: Sun, 7 Aug 2016 08:05:21 -0500
Message-ID: <CAA-ihx8zf+Jg3cufgA=fHp+ro-WsANaTpHwvjMOJw9w8COWX8g@mail.gmail.com>
Subject: Re: linking more bloat from ctime.c
To: djgpp-workers AT delorie DOT com
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Hi,

On Sun, Aug 7, 2016 at 7:16 AM, Rugxulo <rugxulo AT gmail DOT com> wrote:
>
> So I whipped up a quick attempt to fix this.
>
> === ctime.dif begins ===
> ...
> +  newres[24]='\n';
> ...
> === ctime.dif ends ===

Oops! That line should probably?? be this instead:

+  newres[24]='\n'; newres[25]='\0';

> Should I brute-force try to run through every time_t since 1970 to make sure that there are no bugs?

Thus, a slightly improved example follows:

=== asctime.c begins ===
#include <stdio.h>
#include <time.h>

void say(const char* s) {
  for (size_t i=0; s[i]; i++) putchar(s[i]);
}

int main(void) {
  struct tm t = {
    .tm_isdst = -1,
    .tm_year = 70,
    .tm_mday = 1,
    .tm_mon = 6,
    .tm_yday = 180,
    .tm_hour = 13,
    .tm_min  = 41,
    .tm_sec = 0,
    .tm_wday = 0,
  };

  time_t blah;

  for (int i=0; i <= 135; i++) {
    blah=mktime(&t);
    say(asctime(localtime(&blah)));
    t.tm_year++;
  }

  return 0;
}
=== asctime.c ends ===

Okay, that's enough for now.   :-P

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019