On Tue, Jul 05, 2022 at 11:08:13AM +0200, Claudio Jeker wrote:
> On Mon, Jul 04, 2022 at 05:10:05PM -0500, Scott Cheloha wrote:
> > On Mon, Jul 04, 2022 at 11:15:24PM +0200, Claudio Jeker wrote:
> > > On Mon, Jul 04, 2022 at 01:28:12PM -0500, Scott Cheloha wrote:
> > > > Hi,
> > > >
> > > > Couple things:
> > > >
> > > > [...]
> > >
> > > I don't like the introduction of all these local variables that are just
> > > hard to follow and need extra code pathes. Happy to rename roff to offset,
> > > start_offset or something similar. Also moving the localtime call into
> > > fmtfmt() is fine.
> >
> > You need an "elapsed" variable to avoid overwriting "now" in the
> > -i flag case to avoid calling clock_gettime(2) twice.
> >
> > We can get rid of "utc_start" and just reuse "now" for the initial
> > value of CLOCK_REALTIME.
> >
> > How is this?
>
> How about this instead?
Looks like an improvement
The suggestion to change 'ms' to 'us' might be a good one to roll into
this changeset too.
nitpick: the changeset doesn't apply cleanly:
$ cat ts.c.rej
@@ -40,8 +40,7 @@
{
int iflag, mflag, sflag;
int ch, prev;
- struct timespec roff, start, now;
- struct tm *tm;
+ struct timespec start, now, utc_offset, ts;
int clock = CLOCK_REALTIME;
if (pledge("stdio", NULL) == -1)