zsh-users
 help / color / mirror / code / Atom feed
From: Roman Neuhauser <neuhauser@sigpipe.cz>
To: zsh-users@zsh.org
Subject: cmp(1) as a builtin
Date: Mon, 2 Jun 2014 18:34:46 +0200	[thread overview]
Message-ID: <20140602163446.GB1629@isis.sigpipe.cz> (raw)

hello,

i need to run cmp(1) on a heap of mostly small files, and the forking
overhead is killing me.  i added a PoC bit to zsh/files to expose b:cmp
and C:qf (eQual Files).  it seems to work, but i'm pretty sure it has
issues as i don't know what i'm doing here, on several levels.

questions:

the cmp builtin currently always reads the file data.  it should stat
both operands to see if that can be skipped.  what api do i use for
that?  does zsh have some kind of stat cache i should hook into?

if either operand is "-", it should read from stdin.  how do i get hold
of standard input in the builtin?  can i use the standard FILE* handle
(stdin), do i need fdopen(SHIN, "r") (or use SHIN directly), or...?

the condexpr operator ([[ x -qf y ]]) is implemented like this:

    static int
    cond_cmp(char **args, UNUSED(int func))
    {
        return 0 == do_cmp(
            "cond_qf", 1,
            cond_str(args, 0, 0),
            cond_str(args, 1, 0)
        );
    }

do_cmp() passes the cond_str() results to fopen().  am i using
cond_str() correctly?

-- 
roman


             reply	other threads:[~2014-06-02 16:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-02 16:34 Roman Neuhauser [this message]
2014-06-03  4:28 ` Bart Schaefer

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=20140602163446.GB1629@isis.sigpipe.cz \
    --to=neuhauser@sigpipe.cz \
    --cc=zsh-users@zsh.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).