From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] hoc output format
Date: Thu, 13 May 2010 09:24:47 -0400 [thread overview]
Message-ID: <158d5dc0571fa04cab44a99b3fdf5921@kw.quanstro.net> (raw)
In-Reply-To: <op.vcmv3401hipq0d@santucco.avp.ru>
On Thu May 13 03:51:56 EDT 2010, santucco@gmail.com wrote:
> Yes, I'm agree, but with one exception - awk(1) separates a data from a
> code, hoc(1) doesn't do it. So hoc(1) can be used for plain calculation
> tasks, not for processing input files with a data.
both awk and hoc accept standard input
echo 1 + 2 | hoc # (sic, see below)
echo 1 2 | hoc -e '{while(read(x) != 0)y += x' ^ $nl ^ ' print y, "\n"}' -
echo 1 2 | awk '{for(i = 1; i <= NF; i++) x+= $i}END{print x}'
or execute directly from the command line
hoc -e '1 + 2'
awk 'BEGIN{print 1 + 2; exit}'
note that the wierd extra {} are required for hoc. hoc read
requests are satisfied from the same file descriptor as the data.
so the input needs to be exhausted before read runs.
also, the trailing newline on the input is required, since Bgetd()
won't accept '1<EOF>'. this seems like a bug induced by the
fact that charstod has one argument too few. if it also returned
the number of characters consumed, Bgetd could read
int
Bgetd(Biobufhdr *bp, double *dp)
{
double d;
struct bgetd b;
b.b = bp;
b.eof = 0;
> b.nchr = 0;
> d = charstod(Bgetdf, &b, &n);
> if(b.eof || b.nchr != n)
return -1;
Bungetc(bp);
*dp = d;
return 1;
}
- erik
next prev parent reply other threads:[~2010-05-13 13:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-12 10:24 Rudolf Sykora
2010-05-12 10:41 ` Alexander Sychev
2010-05-12 18:06 ` Akshat Kumar
2010-05-13 7:51 ` Alexander Sychev
2010-05-13 13:24 ` erik quanstrom [this message]
2010-05-13 14:06 ` Alexander Sychev
2010-05-13 14:23 ` erik quanstrom
2010-05-13 15:04 ` Ethan Grammatikidis
2010-05-13 15:09 ` Gorka Guardiola
2010-05-13 15:37 ` erik quanstrom
2010-05-13 15:16 ` roger peppe
2010-05-13 15:31 ` erik quanstrom
2010-05-13 15:53 ` roger peppe
2010-05-13 16:06 ` erik quanstrom
2010-05-13 16:16 ` roger peppe
2010-05-13 15:54 ` Ethan Grammatikidis
2010-05-13 16:08 ` roger peppe
2010-05-13 15:20 ` Rudolf Sykora
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=158d5dc0571fa04cab44a99b3fdf5921@kw.quanstro.net \
--to=quanstro@quanstro.net \
--cc=9fans@9fans.net \
/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 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).