All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sami Kerola <kerolasa@iki.fi>
To: util-linux <util-linux@vger.kernel.org>
Cc: Sami Kerola <kerolasa@iki.fi>, Rui Zhao <renyuneyun@gmail.com>
Subject: Re: [PATCH] scriptreplay: determine if script --quiet was used to create typescript
Date: Sat, 15 Apr 2017 09:43:01 +0100	[thread overview]
Message-ID: <CAG27Bk3dgmzJyFRCxB8w1YqOS8V2deobmg6Z6CiokKaat6dnYw@mail.gmail.com> (raw)
In-Reply-To: <20170414203948.12295-1-kerolasa@iki.fi>

On 14 April 2017 at 21:39, Sami Kerola <kerolasa@iki.fi> wrote:
> diff --git a/term-utils/scriptreplay.c b/term-utils/scriptreplay.c
> index 5fd3ecb16..365b73de4 100644
> --- a/term-utils/scriptreplay.c
> +++ b/term-utils/scriptreplay.c
> @@ -58,6 +59,25 @@ usage(FILE *out)
>         exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
>  }
>
> +static int
> +sfile_has_header(FILE *sfile, FILE *tfile)
> +{
> +       double delay;
> +       size_t blk, total = 0;
> +       char nl;
> +       struct stat st;
> +
> +       if (fstat(fileno(sfile), &st) < 0)
> +               return 0;
> +       while (fscanf(tfile, "%lf %zu%c\n", &delay, &blk, &nl) == 3)
> +               total += blk;
> +       fseek(sfile, 0, SEEK_SET);

sfile file position does not need updating, fixed in:

https://github.com/kerolasa/lelux-utiliteetit/commit/419a5cb277068eea395fdbdf41d9f8cad9296357

branch name: script

> +       fseek(tfile, 0, SEEK_SET);
> +       if ((size_t)st.st_size <= total)
> +               return 0;
> +       return 1;
> +}
> +
>  static double
>  getnum(const char *s)
>  {

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

  reply	other threads:[~2017-04-15  8:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-14 20:39 [PATCH] scriptreplay: determine if script --quiet was used to create typescript Sami Kerola
2017-04-15  8:43 ` Sami Kerola [this message]
2017-04-18 10:23 ` Karel Zak
2017-04-19 18:11   ` Sami Kerola
2017-04-19 21:57     ` renyuneyun
2017-04-19 22:04     ` renyuneyun
2017-04-22 21:35       ` Sami Kerola

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAG27Bk3dgmzJyFRCxB8w1YqOS8V2deobmg6Z6CiokKaat6dnYw@mail.gmail.com \
    --to=kerolasa@iki.fi \
    --cc=kerolasa@gmail.com \
    --cc=renyuneyun@gmail.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.