[Toybox] [PATCH 1/2] tac: switch to getline().

Rob Landley rob at landley.net
Wed Jul 24 15:55:49 PDT 2019


On 7/23/19 11:50 PM, enh via Toybox wrote:
>  static void do_tac(int fd, char *name)
>  {
>    struct arg_list *list = NULL;
> -  char *c;
> +  FILE *fp;
>  
> -  // Read in lines
> +  if (fd == -1) {
> +    perror_msg_raw(name);
> +    return;
> +  }

The infrastructure does that if you pass WARN_ONLY in the flags. (Which
loopfiles() does by default.)

Don't close stdin when they -, it makes the rest of your pipeline unhappy.
(do_lines() in lib/ checks for this)...

Actually, lemme rewrite this to use do_lines(), via the loopfiles_lines() bridge
that's already in lib. And use a dlist since that already has a function to
allocate the wrapper for us and it's trivially reversible...

There, checked in on top of yours. Try now?

Rob



More information about the Toybox mailing list