[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-tech
Subject:    Re: have indent default to stdin with no input files
From:       Mark Kettenis <mark.kettenis () xs4all ! nl>
Date:       2013-06-20 9:19:56
Message-ID: 201306200919.r5K9JtZT014475 () glazunov ! sibelius ! xs4all ! nl
[Download RAW message or body]

> Date: Thu, 20 Jun 2013 17:03:48 +1000
> From: Jonathan Gray <jsg@jsg.id.au>
> 
> Default to stdin/stdout if no input files are
> given to indent.  FreeBSD and GNU indent have had
> this behaviour for a long time now.
> 
> Based on FreeBSD svn rev 40502 from back in 1998.

Makes sense to me.

ok kettenis@

> Index: indent.1
> ===================================================================
> RCS file: /cvs/src/usr.bin/indent/indent.1,v
> retrieving revision 1.21
> diff -u -p -r1.21 indent.1
> --- indent.1	20 Jun 2013 06:28:15 -0000	1.21
> +++ indent.1	20 Jun 2013 06:50:52 -0000
> @@ -41,7 +41,7 @@
>  .Sh SYNOPSIS
>  .Nm indent
>  .Bk -words
> -.Ar input-file Op Ar output-file
> +.Op Ar input-file Op Ar output-file
>  .Op Fl bad | nbad
>  .Op Fl bap | nbap
>  .Op Fl bbb | nbbb
> @@ -114,6 +114,11 @@ is specified,
>  .Nm
>  checks to make sure it is different from
>  .Ar input-file .
> +.Pp
> +If no
> +.Ar input-file
> +is specified
> +input is read from stdin and the formatted file is written to stdout. 
>  .Pp
>  The options listed below control the formatting style imposed by
>  .Nm .
> Index: indent.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/indent/indent.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 indent.c
> --- indent.c	20 Jun 2013 06:28:15 -0000	1.21
> +++ indent.c	20 Jun 2013 06:50:52 -0000
> @@ -198,11 +198,10 @@ main(int argc, char **argv)
>  	    set_option(argv[i]);
>      }				/* end of for */
>      if (input == NULL) {
> -	fprintf(stderr, "usage: indent input-file [output-file] [options]\n");
> -	exit(1);
> +	input = stdin;
>      }
>      if (output == NULL) {
> -	if (troff)
> +	if (troff || input == stdin)
>  	    output = stdout;
>  	else {
>  	    out_name = in_name;
> 
> 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic