Re: fdformat: reformat usage()

2018-09-17 Thread Robert Klein
On Sun, 16 Sep 2018 22:48:01 +0100
Jason McIntyre  wrote:

> On Wed, Sep 12, 2018 at 05:40:49PM +0100, Jason McIntyre wrote:
> > On Wed, Sep 12, 2018 at 11:50:18AM +0200, Sascha Paunovic wrote:  
> > > Since C99, string literal concatenation is provided, allowing the
> > > number of printf() calls to be greatly reduced (20 -> 1).
> > > 
> > > This is my first diff I'm sending, feedback would be very
> > > appreciated. 
> > 
> > hi.
> > 
> > i'm all for the diff but... generally usage() does not spit out a
> > description of the options (with some exceptions). if you look at
> > the man page, the irony is that the usage seems more verbose.
> > 
> > anyone object to removing the list that follows the synopsis? if
> > not, i'd prefer that.
> > 
> > unrelated question: anyone know why the argument to -g is "gap3len"?
> > 
> > jmc
> >   
> 
> ok, so here's the diff i propose. yay? nay?
> jmc
> 
> Index: fdformat.c
> ===
> RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
> retrieving revision 1.22
> diff -u -r1.22 fdformat.c
> --- fdformat.c16 Mar 2016 15:41:11 -  1.22
> +++ fdformat.c16 Sep 2018 21:46:04 -
> @@ -132,26 +132,10 @@
>  static void
>  usage(void)
>  {
> - printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> gap3len] ",
> - __progname);
> - printf("[-h heads]\n");
> - printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
> - printf("\t[-t steps_per_track] device_name\n");
> - printf("Options:\n");
> - printf("\t-n\tdon't verify floppy after formatting\n");
> - printf("\t-q\tsuppress any normal output, don't ask for
> confirmation\n");
> - printf("\t-v\tdon't format, verify only\n");
> - printf("\tdevname\tthe full name of floppy device or in
> short form fd0, fd1\n");
> - printf("Obscure options:\n");
> - printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
> - printf("\t-F #\tspecify fill byte\n");
> - printf("\t-g #\tspecify gap length\n");
> - printf("\t-h #\tspecify number of floppy heads, 1 or 2\n");
> - printf("\t-i #\tspecify interleave factor\n");
> - printf("\t-r #\tspecify data rate, 250, 300 or 500 kbps\n");
> - printf("\t-S #\tspecify sector size, 0=128, 1=256, 2=512
> bytes\n");
> - printf("\t-s #\tspecify number of sectors per track, 9, 10,
> 15 or 18\n");
> - printf("\t-t #\tnumber of steps per track\n");
> + printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> gap3len] "
> + "[-h heads]\n"
> + "   [-i intleave] [-r rate] [-S secshft] [-s
> secs]\n"
> + "   [-t steps_per_track] device_name\n",
> __progname); exit(2);
>  }
>  
> 

How about putting the information from “usage” in the rather sparse man
page (see below)?

Best regards,
Robert


Index: usr.sbin/fdformat/fdformat.1
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.1,v
retrieving revision 1.19
diff -u -p -r1.19 fdformat.1
--- usr.sbin/fdformat/fdformat.18 Jan 2017 01:32:02 -   1.19
+++ usr.sbin/fdformat/fdformat.117 Sep 2018 07:25:45 -
@@ -62,28 +62,37 @@ are meaningless, since they're overridde
 .Pp
 The options are as follows:
 .Pp
-.Bl -tag -width Ds -compact
+.Bl -tag -width Ds
 .It Fl n
 Don't verify floppy after formatting.
-.Pp
 .It Fl q
 Suppress any normal output from the command, and don't ask the
 user for confirmation whether to format the floppy disk at
 .Ar device_name .
-.Pp
 .It Fl v
 Don't format; verify only.
-.Pp
 .It Fl c Ar cyls
+Number of cylinders (40 or 80).
 .It Fl F Ar fillbyte
+Use
+.Ar fillbyte
+as fill byte.
 .It Fl g Ar gap3len
+Length of gap at the end of any sector.
 .It Fl h Ar heads
+Number of floppy heads (1 or 2).
 .It Fl i Ar intleave
+Sector interleave.
 .It Fl r Ar rate
+Data transfer rate in kilobyte/sec (250, 300, or 500).
 .It Fl S Ar secshft
+Sector size shift factor (use 0 for 128, 1 for 256, and 2 for 512 byte
+sectors).
 .It Fl s Ar secs
+Number of sectors per track (9, 10, 15, or 18).
 .It Fl t Ar steps_per_track
-An alternate method to specify the geometry data to write to the floppy disk.
+Number of steps per track.  An alternate method to specify the
+geometry data to write to the floppy disk.
 .El
 .Pp
 If the




Re: fdformat: reformat usage()

2018-09-17 Thread Jason McIntyre
On Mon, Sep 17, 2018 at 02:40:49PM +0200, Robert Klein wrote:
> > 
> > ok, so here's the diff i propose. yay? nay?
> > jmc
> > 
> > Index: fdformat.c
> > ===
> > RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
> > retrieving revision 1.22
> > diff -u -r1.22 fdformat.c
> > --- fdformat.c  16 Mar 2016 15:41:11 -  1.22
> > +++ fdformat.c  16 Sep 2018 21:46:04 -
> > @@ -132,26 +132,10 @@
> >  static void
> >  usage(void)
> >  {
> > -   printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> > gap3len] ",
> > -   __progname);
> > -   printf("[-h heads]\n");
> > -   printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
> > -   printf("\t[-t steps_per_track] device_name\n");
> > -   printf("Options:\n");
> > -   printf("\t-n\tdon't verify floppy after formatting\n");
> > -   printf("\t-q\tsuppress any normal output, don't ask for
> > confirmation\n");
> > -   printf("\t-v\tdon't format, verify only\n");
> > -   printf("\tdevname\tthe full name of floppy device or in
> > short form fd0, fd1\n");
> > -   printf("Obscure options:\n");
> > -   printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
> > -   printf("\t-F #\tspecify fill byte\n");
> > -   printf("\t-g #\tspecify gap length\n");
> > -   printf("\t-h #\tspecify number of floppy heads, 1 or 2\n");
> > -   printf("\t-i #\tspecify interleave factor\n");
> > -   printf("\t-r #\tspecify data rate, 250, 300 or 500 kbps\n");
> > -   printf("\t-S #\tspecify sector size, 0=128, 1=256, 2=512
> > bytes\n");
> > -   printf("\t-s #\tspecify number of sectors per track, 9, 10,
> > 15 or 18\n");
> > -   printf("\t-t #\tnumber of steps per track\n");
> > +   printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> > gap3len] "
> > +   "[-h heads]\n"
> > +   "   [-i intleave] [-r rate] [-S secshft] [-s
> > secs]\n"
> > +   "   [-t steps_per_track] device_name\n",
> > __progname); exit(2);
> >  }
> >  
> > 
> 
> How about putting the information from ???usage??? in the rather sparse man
> page (see below)?
> 
> Best regards,
> Robert
> 

actually i'm slightly embarrassed that that didn;t occur to me. i
definitely like the idea. i reworked the diff a bit to order the
options.

so below is the diff i propose, which i'll commit shortly if no one
starts yelling.

jmc

Index: fdformat.1
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.1,v
retrieving revision 1.20
diff -u -r1.20 fdformat.1
--- fdformat.1  7 Jun 2018 11:37:21 -   1.20
+++ fdformat.1  17 Sep 2018 13:00:32 -
@@ -61,29 +61,43 @@
 .Nm fdformat .
 .Pp
 The options are as follows:
-.Pp
-.Bl -tag -width Ds -compact
+.Bl -tag -width Ds
+.It Fl c Ar cyls
+Number of cylinders
+.Pq 40 or 80 .
+.It Fl F Ar fillbyte
+Use
+.Ar fillbyte
+as fill byte.
+.It Fl g Ar gap3len
+Length of gap at the end of any sector
+.Pq Dq gap 3 .
+.It Fl h Ar heads
+Number of floppy heads
+.Pq 1 or 2 .
+.It Fl i Ar intleave
+Sector interleave to be used.
 .It Fl n
 Don't verify floppy after formatting.
-.Pp
 .It Fl q
 Suppress any normal output from the command, and don't ask the
 user for confirmation whether to format the floppy disk at
 .Ar device_name .
-.Pp
-.It Fl v
-Don't format; verify only.
-.Pp
-.It Fl c Ar cyls
-.It Fl F Ar fillbyte
-.It Fl g Ar gap3len
-.It Fl h Ar heads
-.It Fl i Ar intleave
 .It Fl r Ar rate
+Data transfer rate in kilobyte/sec
+.Pq 250, 300, or 500 .
 .It Fl S Ar secshft
+Sector size code: 0 for 128, 1 for 256, and 2 for 512 byte
+sectors.
 .It Fl s Ar secs
+Number of sectors per track
+.Pq 9, 10, 15, or 18 .
 .It Fl t Ar steps_per_track
-An alternate method to specify the geometry data to write to the floppy disk.
+Number of steps per track.
+An alternate method to specify the
+geometry data to write to the floppy disk.
+.It Fl v
+Don't format; verify only.
 .El
 .Pp
 If the
Index: fdformat.c
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
retrieving revision 1.22
diff -u -r1.22 fdformat.c
--- fdformat.c  16 Mar 2016 15:41:11 -  1.22
+++ fdformat.c  17 Sep 2018 13:00:32 -
@@ -132,26 +132,10 @@
 static void
 usage(void)
 {
-   printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g gap3len] ",
-   __progname);
-   printf("[-h heads]\n");
-   printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
-   printf("\t[-t steps_per_track] device_name\n");
-   printf("Options:\n");
-   printf("\t-n\tdon't verify floppy after formatting\n");
-   printf("\t-q\tsuppress any normal output, don't ask for 
confirmation\n");
-   printf("\t-v\tdon't format, verify only\n");
-   printf("\tdevname\tthe full name of floppy device or in short form fd0, 
fd1\n");
-   printf("Obscure options:\n");
-   printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
-   printf("\t-F #\tspecify fill byte\n");
-   

Re: fdformat: reformat usage()

2018-09-17 Thread Robert Klein
(sorry, if this turns up twice, first attempt didn't show up for a
couple of hours; updated doc patch below)

 On Sun, 16 Sep 2018 22:48:01 +0100
Jason McIntyre  wrote:

> On Wed, Sep 12, 2018 at 05:40:49PM +0100, Jason McIntyre wrote:
> > On Wed, Sep 12, 2018 at 11:50:18AM +0200, Sascha Paunovic wrote:  
> > > Since C99, string literal concatenation is provided, allowing the
> > > number of printf() calls to be greatly reduced (20 -> 1).
> > > 
> > > This is my first diff I'm sending, feedback would be very
> > > appreciated. 
> > 
> > hi.
> > 
> > i'm all for the diff but... generally usage() does not spit out a
> > description of the options (with some exceptions). if you look at
> > the man page, the irony is that the usage seems more verbose.
> > 
> > anyone object to removing the list that follows the synopsis? if
> > not, i'd prefer that.
> > 
> > unrelated question: anyone know why the argument to -g is "gap3len"?
> > 
> > jmc
> >   
> 
> ok, so here's the diff i propose. yay? nay?
> jmc
> 
> Index: fdformat.c
> ===
> RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
> retrieving revision 1.22
> diff -u -r1.22 fdformat.c
> --- fdformat.c16 Mar 2016 15:41:11 -  1.22
> +++ fdformat.c16 Sep 2018 21:46:04 -
> @@ -132,26 +132,10 @@
>  static void
>  usage(void)
>  {
> - printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> gap3len] ",
> - __progname);
> - printf("[-h heads]\n");
> - printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
> - printf("\t[-t steps_per_track] device_name\n");
> - printf("Options:\n");
> - printf("\t-n\tdon't verify floppy after formatting\n");
> - printf("\t-q\tsuppress any normal output, don't ask for
> confirmation\n");
> - printf("\t-v\tdon't format, verify only\n");
> - printf("\tdevname\tthe full name of floppy device or in
> short form fd0, fd1\n");
> - printf("Obscure options:\n");
> - printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
> - printf("\t-F #\tspecify fill byte\n");
> - printf("\t-g #\tspecify gap length\n");
> - printf("\t-h #\tspecify number of floppy heads, 1 or 2\n");
> - printf("\t-i #\tspecify interleave factor\n");
> - printf("\t-r #\tspecify data rate, 250, 300 or 500 kbps\n");
> - printf("\t-S #\tspecify sector size, 0=128, 1=256, 2=512
> bytes\n");
> - printf("\t-s #\tspecify number of sectors per track, 9, 10,
> 15 or 18\n");
> - printf("\t-t #\tnumber of steps per track\n");
> + printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> gap3len] "
> + "[-h heads]\n"
> + "   [-i intleave] [-r rate] [-S secshft] [-s
> secs]\n"
> + "   [-t steps_per_track] device_name\n",
> __progname); exit(2);
>  }
>  
> 

How about putting the information from “usage” in the rather sparse man
page (see below)?

Best regards,
Robert


Index: usr.sbin/fdformat/fdformat.1
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.1,v
retrieving revision 1.19
diff -u -p -r1.19 fdformat.1
--- usr.sbin/fdformat/fdformat.18 Jan 2017 01:32:02 -   1.19
+++ usr.sbin/fdformat/fdformat.117 Sep 2018 10:00:23 -
@@ -61,29 +61,43 @@ are meaningless, since they're overridde
 .Nm fdformat .
 .Pp
 The options are as follows:
-.Pp
-.Bl -tag -width Ds -compact
+.Bl -tag -width Ds
 .It Fl n
 Don't verify floppy after formatting.
-.Pp
 .It Fl q
 Suppress any normal output from the command, and don't ask the
 user for confirmation whether to format the floppy disk at
 .Ar device_name .
-.Pp
 .It Fl v
 Don't format; verify only.
-.Pp
 .It Fl c Ar cyls
+Number of cylinders
+.Pq 40 or 80 .
 .It Fl F Ar fillbyte
+Use
+.Ar fillbyte
+as fill byte.
 .It Fl g Ar gap3len
+Length of gap at the end of any sector
+.Pq Dq gap 3 .
 .It Fl h Ar heads
+Number of floppy heads
+.Pq 1 or 2 .
 .It Fl i Ar intleave
+Sector interleave to be used.
 .It Fl r Ar rate
+Data transfer rate in kilobyte/sec
+.Pq 250, 300, or 500 .
 .It Fl S Ar secshft
+Sector size code: 0 for 128, 1 for 256, and 2 for 512 byte
+sectors.
 .It Fl s Ar secs
+Number of sectors per track
+.Pq 9, 10, 15, or 18 .
 .It Fl t Ar steps_per_track
-An alternate method to specify the geometry data to write to the floppy disk.
+Number of steps per track.
+An alternate method to specify the
+geometry data to write to the floppy disk.
 .El
 .Pp
 If the



Re: fdformat: reformat usage()

2018-09-16 Thread Jason McIntyre
On Wed, Sep 12, 2018 at 05:40:49PM +0100, Jason McIntyre wrote:
> On Wed, Sep 12, 2018 at 11:50:18AM +0200, Sascha Paunovic wrote:
> > Since C99, string literal concatenation is provided, allowing the number
> > of printf() calls to be greatly reduced (20 -> 1).
> > 
> > This is my first diff I'm sending, feedback would be very appreciated.
> > 
> 
> hi.
> 
> i'm all for the diff but... generally usage() does not spit out a
> description of the options (with some exceptions). if you look at the
> man page, the irony is that the usage seems more verbose.
> 
> anyone object to removing the list that follows the synopsis? if not,
> i'd prefer that.
> 
> unrelated question: anyone know why the argument to -g is "gap3len"?
> 
> jmc
> 

ok, so here's the diff i propose. yay? nay?
jmc

Index: fdformat.c
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
retrieving revision 1.22
diff -u -r1.22 fdformat.c
--- fdformat.c  16 Mar 2016 15:41:11 -  1.22
+++ fdformat.c  16 Sep 2018 21:46:04 -
@@ -132,26 +132,10 @@
 static void
 usage(void)
 {
-   printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g gap3len] ",
-   __progname);
-   printf("[-h heads]\n");
-   printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
-   printf("\t[-t steps_per_track] device_name\n");
-   printf("Options:\n");
-   printf("\t-n\tdon't verify floppy after formatting\n");
-   printf("\t-q\tsuppress any normal output, don't ask for 
confirmation\n");
-   printf("\t-v\tdon't format, verify only\n");
-   printf("\tdevname\tthe full name of floppy device or in short form fd0, 
fd1\n");
-   printf("Obscure options:\n");
-   printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
-   printf("\t-F #\tspecify fill byte\n");
-   printf("\t-g #\tspecify gap length\n");
-   printf("\t-h #\tspecify number of floppy heads, 1 or 2\n");
-   printf("\t-i #\tspecify interleave factor\n");
-   printf("\t-r #\tspecify data rate, 250, 300 or 500 kbps\n");
-   printf("\t-S #\tspecify sector size, 0=128, 1=256, 2=512 bytes\n");
-   printf("\t-s #\tspecify number of sectors per track, 9, 10, 15 or 
18\n");
-   printf("\t-t #\tnumber of steps per track\n");
+   printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g gap3len] "
+   "[-h heads]\n"
+   "   [-i intleave] [-r rate] [-S secshft] [-s secs]\n"
+   "   [-t steps_per_track] device_name\n", __progname);
exit(2);
 }
 



Re: fdformat: reformat usage()

2018-09-12 Thread d . rauschenb
Hi,

> unrelated question: anyone know why the argument to -g is "gap3len"?

The gap between the sectors. More info at
https://en.wikipedia.org/wiki/Floppy_disk_format#Sectoring

-dra



Re: fdformat: reformat usage()

2018-09-12 Thread Sascha Paunovic
On Wed, Sep 12, 2018 at 05:40:49PM +0100, Jason McIntyre wrote:
> hi.
> 
> i'm all for the diff but... generally usage() does not spit out a
> description of the options (with some exceptions). if you look at the
> man page, the irony is that the usage seems more verbose.
> 
> anyone object to removing the list that follows the synopsis? if not,
> i'd prefer that.
> 
> unrelated question: anyone know why the argument to -g is "gap3len"?
> 
> jmc

Hello,

I agree, removing it from usage() and putting the information in the man
page is more inline with other OpenBSD utilities.

I might get to that on Friday or during the weekend.

(not 100% sure on the gap3len, but I believe it's kinda like a safety
gap used to compensate between the slight differences between the drive
that originally wrote the disk and the one that is currently writing the
disk)

Thanks for the feedback.

-- 
Sascha Paunovic 



Re: fdformat: reformat usage()

2018-09-12 Thread Jason McIntyre
On Wed, Sep 12, 2018 at 11:50:18AM +0200, Sascha Paunovic wrote:
> Since C99, string literal concatenation is provided, allowing the number
> of printf() calls to be greatly reduced (20 -> 1).
> 
> This is my first diff I'm sending, feedback would be very appreciated.
> 

hi.

i'm all for the diff but... generally usage() does not spit out a
description of the options (with some exceptions). if you look at the
man page, the irony is that the usage seems more verbose.

anyone object to removing the list that follows the synopsis? if not,
i'd prefer that.

unrelated question: anyone know why the argument to -g is "gap3len"?

jmc

> diff --git usr.sbin/fdformat/fdformat.c usr.sbin/fdformat/fdformat.c
> index c2566992e..2d6afbd3f 100644
> --- usr.sbin/fdformat/fdformat.c
> +++ usr.sbin/fdformat/fdformat.c
> @@ -132,26 +132,26 @@ verify_track(int fd, int track, int tracksize)
>  static void
>  usage(void)
>  {
> - printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g gap3len] ",
> - __progname);
> - printf("[-h heads]\n");
> - printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
> - printf("\t[-t steps_per_track] device_name\n");
> - printf("Options:\n");
> - printf("\t-n\tdon't verify floppy after formatting\n");
> - printf("\t-q\tsuppress any normal output, don't ask for 
> confirmation\n");
> - printf("\t-v\tdon't format, verify only\n");
> - printf("\tdevname\tthe full name of floppy device or in short form fd0, 
> fd1\n");
> - printf("Obscure options:\n");
> - printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
> - printf("\t-F #\tspecify fill byte\n");
> - printf("\t-g #\tspecify gap length\n");
> - printf("\t-h #\tspecify number of floppy heads, 1 or 2\n");
> - printf("\t-i #\tspecify interleave factor\n");
> - printf("\t-r #\tspecify data rate, 250, 300 or 500 kbps\n");
> - printf("\t-S #\tspecify sector size, 0=128, 1=256, 2=512 bytes\n");
> - printf("\t-s #\tspecify number of sectors per track, 9, 10, 15 or 
> 18\n");
> - printf("\t-t #\tnumber of steps per track\n");
> + printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g gap3len] "
> + "[-h heads]\n"
> + "   [-i intleave] [-r rate] [-S secshft] [-s secs]\n"
> + "   [-t steps_per_track] device_name\n"
> + "Options:\n"
> + "   -n  don't verify floppy after formatting\n"
> + "   -q  inhibit any normal output, don't ask for confirmation\n"
> + "   -v  don't format, verify only\n"
> + "   devname "
> + "the full name of floppy device or in short form fd0, fd1\n"
> + "Obscure options:\n"
> + "   -c #specify number of cylinders, 40 or 80\n"
> + "   -F #specify fill byte\n"
> + "   -g #specify gap length\n"
> + "   -h #specify number of floppy heads, 1 or 2\n"
> + "   -i #specify interleave factor\n"
> + "   -r #specify data rate, 250, 300 or 500 kbps\n"
> + "   -S #specify sector size, 0=128, 1=256, 2=512 bytes\n"
> + "   -s #specify number of sectors per track, 9, 10, 15 or 18\n"
> + "   -t #number of steps per track\n", __progname);
>   exit(2);
>  }
>  
> -- 
> Sascha Paunovic 
>