Package: cuetools
Version: 1.3-1.0.branden.1
Severity: wishlist
Tags: upstream

Hi Josh,

As discussed on IRC, here's a giant patch from me that fixes all kinds of
things.

It's huge, but I'm pretty sure I documented everything.

Two things require special attention:
* The debian/rules changes are obviously not for upstream.
* The changelog entry is there for your convenience, and should not be
  included in your next official release as such (it's not kosher to
  release with the version number I used for local testing).  Feel free to
  quote it, though.

The changelog describes all the changes, but here they are extracted from
the attachment.

  * Make several fixes and enhancements to the cuebreakpoints, cueconvert, and
    cueprint commands:
    + Fix them to use an int instead of a char to store the return value of
      getopt_long(), so that the value is not truncated.
    + Enhance usage messages:
      - Store the command synopsis in a static buffer.
      - Report the command synopsis in error as well as "--help" conditions.
      - Summarize the purpose of the command in the usage message.
      - Note default behavior where applicable.
      - Cross-reference manual page.
      - Communicate in complete sentences more.
    + Standardize presentation of error messages.  Always report the command
      name and always say "error:" on error conditions.
    + Make some error message indicate what operation failed instead of
      uttering amorphisms like "input file error".
    + Stop throwing away the value of the function that each program's main()
      wraps.  Instead, store it and use it as the command's exit value instead
      of exiting with status zero no matter what went wrong.
    + Use strcasecmp() instead of strcmp() when attempting to parse file
      format extensions, so that people pulling files from uppercase-happy
      operating systems are less likely to be frustrated.
    + Add lots of comments.
      - Document symbols required from #included system headers.
      - Document the core logic of main().
      - Add some TODO items with ideas that occurred to me.
    + Make style fixes:
      - Kill extraneous whitespace at ends of lines.
      - Wrap lines at 80 columns.
      - Replace ugly multline string literals (with the newline escaped, or
        GCC would have caught this) with a more idiomatic usage.
      - Write function calls consistently.
      - Use idiomatic multi-line comment style.
      - Use complete sentences in non-TODO comments.
      - Refer to argv[0] as argv[0] instead of *argv (idiom again).

  * Make several fixes and enhancements to the cuebreakpoints, cueconvert, and
    cueprint manual pages:
    + Fix .TH directive:
      - Use the command's own name, not "cuetools".
      - Add the date of last modification and the upstream source
        distribution.
    + Fix the NAME section:
      + Move the command's short description here from the DESCRIPTION
        section, so that whatis(1) and apropos(1) have a chance of finding these
        manual pages.
    + Fix the SYNOPSIS section to more usefully synopsize the command's
      usage.  "[ option ... ] [ file ... ]" is only appropriate for very
      complex commands, in my opinion.
    + Move material from non-standard section names into the DESCRIPTION
      section.
    + Move the DESCRIPTION section to precede the OPTIONS section.
    + Fix the items in the OPTIONS section so that they present correctly.
    + Add an EXIT STATUS section.
    + Fix markup of cross-references in SEE ALSO section.
    + Add myself to AUTHORS section, identifying what I did.

  * Make several fixes to debian/rules:
    + Kill off trailing whitespace from lines in debian/rules.
    + Fix phony targets to only depend on stamp targets in debian/rules.
    + Stop ignoring failres from the upstream distclean rule.  Packages need
      to be able to clean themselves.
    + Add configure (phony) and configure-stamp targets to run ./configure,
      and make both the build and clean targets depend on it.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: powerpc (ppc)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.9-powerpc-smp
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages cuetools depends on:
ii  libc6                         2.3.5-4    GNU C Library: Shared libraries an

cuetools recommends no packages.

-- no debconf information
diff -urN cuetools-1.3-OFFICIAL/debian/changelog cuetools-1.3/debian/changelog
--- cuetools-1.3-OFFICIAL/debian/changelog      2005-08-23 14:09:50.000000000 
-0500
+++ cuetools-1.3/debian/changelog       2005-08-25 03:51:55.517015114 -0500
@@ -1,3 +1,73 @@
+cuetools (1.3-1.0.branden.1) unstable; urgency=low
+
+  * Local NMU for testing purposes.
+
+  * Make several fixes and enhancements to the cuebreakpoints, cueconvert, and
+    cueprint commands:
+    + Fix them to use an int instead of a char to store the return value of
+      getopt_long(), so that the value is not truncated.
+    + Enhance usage messages:
+      - Store the command synopsis in a static buffer.
+      - Report the command synopsis in error as well as "--help" conditions.
+      - Summarize the purpose of the command in the usage message.
+      - Note default behavior where applicable.
+      - Cross-reference manual page.
+      - Communicate in complete sentences more.
+    + Standardize presentation of error messages.  Always report the command
+      name and always say "error:" on error conditions.
+    + Make some error message indicate what operation failed instead of
+      uttering amorphisms like "input file error".
+    + Stop throwing away the value of the function that each program's main()
+      wraps.  Instead, store it and use it as the command's exit value instead
+      of exiting with status zero no matter what went wrong.
+    + Use strcasecmp() instead of strcmp() when attempting to parse file
+      format extensions, so that people pulling files from uppercase-happy
+      operating systems are less likely to be frustrated.
+    + Add lots of comments.
+      - Document symbols required from #included system headers.
+      - Document the core logic of main().
+      - Add some TODO items with ideas that occurred to me.
+    + Make style fixes:
+      - Kill extraneous whitespace at ends of lines.
+      - Wrap lines at 80 columns.
+      - Replace ugly multline string literals (with the newline escaped, or
+        GCC would have caught this) with a more idiomatic usage.
+      - Write function calls consistently.
+      - Use idiomatic multi-line comment style.
+      - Use complete sentences in non-TODO comments.
+      - Refer to argv[0] as argv[0] instead of *argv (idiom again).
+
+  * Make several fixes and enhancements to the cuebreakpoints, cueconvert, and
+    cueprint manual pages:
+    + Fix .TH directive:
+      - Use the command's own name, not "cuetools".
+      - Add the date of last modification and the upstream source
+        distribution.
+    + Fix the NAME section:
+      + Move the command's short description here from the DESCRIPTION
+        section, so that whatis(1) and apropos(1) have a chance of finding 
these
+        manual pages.
+    + Fix the SYNOPSIS section to more usefully synopsize the command's
+      usage.  "[ option ... ] [ file ... ]" is only appropriate for very
+      complex commands, in my opinion.
+    + Move material from non-standard section names into the DESCRIPTION
+      section.
+    + Move the DESCRIPTION section to precede the OPTIONS section.
+    + Fix the items in the OPTIONS section so that they present correctly.
+    + Add an EXIT STATUS section.
+    + Fix markup of cross-references in SEE ALSO section.
+    + Add myself to AUTHORS section, identifying what I did.
+
+  * Make several fixes to debian/rules:
+    + Kill off trailing whitespace from lines in debian/rules.
+    + Fix phony targets to only depend on stamp targets in debian/rules.
+    + Stop ignoring failres from the upstream distclean rule.  Packages need
+      to be able to clean themselves.
+    + Add configure (phony) and configure-stamp targets to run ./configure,
+      and make both the build and clean targets depend on it.
+
+ -- Branden Robinson <[EMAIL PROTECTED]>  Mon, 22 Aug 2005 03:34:38 -0500
+
 cuetools (1.3-1) unstable; urgency=low
 
   * Initial release, closes: #301892
diff -urN cuetools-1.3-OFFICIAL/debian/rules cuetools-1.3/debian/rules
--- cuetools-1.3-OFFICIAL/debian/rules  2005-08-23 14:09:50.000000000 -0500
+++ cuetools-1.3/debian/rules   2005-08-23 15:47:11.000000000 -0500
@@ -13,39 +13,43 @@
        CFLAGS += -O0
 else
        CFLAGS += -O2
-endif          
+endif
 
 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
 crossflags := --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE)
 endif
 
+configure: configure-stamp
+configure-stamp:
+       ./configure $(crossflags) --prefix=/usr --mandir=/usr/share/man
+       >$@
+
 build: build-stamp
-build-stamp:
+build-stamp: configure-stamp
        dh_testdir
-       ./configure $(crossflags) --prefix=/usr --mandir=/usr/share/man
        $(MAKE)
-       touch $@
+       >$@
 
-clean:
+clean: configure-stamp
        dh_testdir
        dh_testroot
-       rm -f build-stamp 
-       -$(MAKE) distclean
-       dh_clean 
+       rm -f build-stamp configure-stamp
+       $(MAKE) distclean
+       dh_clean
 
-install: build
+install: build-stamp
        dh_testdir
        dh_testroot
-       dh_clean -k 
+       dh_clean -k
        dh_installdirs
        $(MAKE) install DESTDIR=$(CURDIR)/debian/cuetools
        dh_installchangelogs NEWS
-       dh_installdocs README 
+       dh_installdocs README
 
-binary-indep: 
+binary-indep:
 # Ye olde no-op.
 
-binary-arch: build install
+binary-arch: build-stamp install
        dh_testdir
        dh_testroot
        dh_link
@@ -59,4 +63,4 @@
        dh_builddeb
 
 binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install 
+.PHONY: configure build clean binary-indep binary-arch binary install
diff -urN cuetools-1.3-OFFICIAL/doc/cuebreakpoints.1 
cuetools-1.3/doc/cuebreakpoints.1
--- cuetools-1.3-OFFICIAL/doc/cuebreakpoints.1  2005-03-22 03:15:25.000000000 
-0500
+++ cuetools-1.3/doc/cuebreakpoints.1   2005-08-23 19:26:32.000000000 -0500
@@ -1,46 +1,94 @@
-.TH cuetools 1
-.
+.TH cuebreakpoints 1 2005-08-23 "Cuetools 1.3"
 .SH NAME
-cuebreakpoints
-.
-.SH DESCRIPTION
-cuebreakpoints \- print the breakpoints from a cue or toc file
-.
+cuebreakpoints \- report track breakpoints from a CUE or TOC file
 .SH SYNOPSIS
 .B cuebreakpoints
-[option...] [file...]
-.
+[ {
+.B \-i
+.I format
+|
+.BR \-\-input\-format =\fIformat\fP
+} {
+.B \-\-append\-gaps
+|
+.B \-\-prepend\-gaps
+|
+.B \-\-split\-gaps
+} ]
+[
+.I file
+\&... ]
+.br
+.B cuebreakpoints \-\-help
+.SH DESCRIPTION
+.B cuebreakpoints
+reports the track breakpoints found in CUE and TOC files, which are
+typically created by compact disc ripping software.
+The breakpoints are in a format usable by
+.B shnsplit
+(part of the shntool package).
+.PP
+Three approaches to track pregaps are availabe: append (to previous track),
+prepend (to succeeding track), and split (from both preceding and
+succeeding tracks).
+The split approach can result in up to twice as many breakpoints being
+reported as there are tracks on the disc.
+.PP
+The first track's pregap cannot be appended to the previous track, so it is
+prefixed to the track in both append and prepend modes.
+If you want the track without it, use the
+.B \-\-split\-gaps
+option.
+.PP
+If no filenames are specified,
+.B cuebreakpoints
+reads from standard input, and an input format option
+.I must
+be specified.
+If one or more filenames is provided, but the input format option is not
+specified, the input format will be guessed based on each file's suffix
+(e.g.,
+.I .cue
+or
+.IR .toc ).
+This hueristic is case-insensitive.
 .SH OPTIONS
 .TP
-.B \-h, \--help
-print usage information
-.
+.BR \-h ", " \-\-help
+displays a usage message and exits.
 .TP
-.B \-i, \--input-format cue|toc
-set format of file(s)
-.
+.BR \-i " \fIformat\fP, " \-\-input\-format=\fIformat\fP
+sets the expected format of the input file(s) to
+.IR format ,
+which must be either
+.B cue
+or
+.BR toc .
 .TP
-.B \--append-gaps
-append pregaps to previous track (default)
-.
+.B \-\-append\-gaps
+appends pregaps to the end of the previous track.
+This is the default.
 .TP
-.B \--prepend-gaps
-prefix pregaps to track
-.
+.B \-\-prepend\-gaps
+prefixes pregaps to the beginning of each subsequent track.
 .TP
-.B \--split-gaps
-split at beginning and end of pregaps
-.
-.SH NOTES
-The breakpoints are in a format usable by shnsplit (part of the shntool 
package).
+.B \-\-split\-gaps
+separates pregaps from both the preceding and succeeding tracks.
 .PP
-The first track's pregap cannot be appended to the previous track, so it is 
prefixed to the track in both append and prepend modes.  If you want the track 
without it, use the split mode.
-.PP
-If no files are specified, stdin is used.  If a filename is specified and the 
format is not specified, the format will be set based on a ".cue" or ".toc" 
suffix.
-.
+If more than one of
+.BR \-\-append\-gaps ,
+.BR \-\-prepend\-gaps ,
+and
+.B \-\-split\-gaps
+are specified, all except the last encountered are ignored.
+.SH "EXIT STATUS"
+.B cuebreakpoints
+exits with status zero if it successfully generates a report for each
+input file, and nonzero if there were problems.
 .SH AUTHOR
-Svend Sorensen
-.
+Cuetools was written by Svend Sorensen.
+Branden Robinson contributed fixes and enhancements to the utilities and
+documentation.
 .SH "SEE ALSO"
-cueconvert(1),
-cueprint(1)
+.BR cueconvert (1),
+.BR cueprint (1)
diff -urN cuetools-1.3-OFFICIAL/doc/cueconvert.1 cuetools-1.3/doc/cueconvert.1
--- cuetools-1.3-OFFICIAL/doc/cueconvert.1      2005-03-22 03:15:25.000000000 
-0500
+++ cuetools-1.3/doc/cueconvert.1       2005-08-23 18:23:23.000000000 -0500
@@ -1,34 +1,79 @@
-.TH cuetools 1
-.
+.TH cueconvert 1 2005-08-23 "Cuetools 1.3"
 .SH NAME
-cueconvert
-.
-.SH DESCRIPTION
-cueconvert \- convert between the cue and toc formats
-.
+cueconvert \- convert files between CUE and TOC formats
 .SH SYNOPSIS
 .B cueconvert
-[option...] [infile [outfile]]
-.
+[
+.B \-i
+.I format
+|
+.BR \-\-input\-format =\fIformat\fP
+] [
+.B \-o
+.I format
+|
+.BR \-\-output\-format =\fIformat\fP
+] [
+.I infile
+[
+.I outfile
+] ]
+.br
+.B cueconvert \-\-help
+.SH DESCRIPTION
+.B cueconvert
+coverts files between the CUE and TOC formats, each of which are commonly
+used by compact disc ripping software to denote track breakpoints and other
+data.
+.PP
+The operands are optional; if
+.I infile
+is not specified,
+.B cueconvert
+reads from standard input, and if
+.I outfile
+is not specified, it writes to standard output.
+.PP
+If no filenamess are specified, standard input is used, and an input format
+option
+.I must
+be specified.
+The complementary format is used for output.
+.PP
+If filenames are provided, but format options are not specified,
+the input and output formats will be guessed based on each filename's
+suffix (e.g.,
+.I .cue
+or
+.IR .toc ).
+This hueristic is case-insensitive.
 .SH OPTIONS
 .TP
-.B \-h, \--help
-print usage information
-.
+.BR \-h ", " \-\-help
+displays a usage message and exits.
 .TP
-.B \-i, \--input-format cue|toc
-set format of input file
-.
+.BR \-i " \fIformat\fP, " \-\-input\-format=\fIformat\fP
+sets the expected format of the input file to
+.IR format .
 .TP
-.B \-o, \--output-format cue|toc
-set format of output file
-.
-.SH NOTES
-If infile or outfile is not specified, stdin and stdout are used, 
respectively.  If a filename is specified and the format is not specified, the 
format will be set based on a ".cue" or ".toc" suffix.  If the output file 
format is not specified, and it cannot be determined from the suffix, it will 
be set to the opposite of the input format.
-.
+.BR \-o " \fIformat\fP, " \-\-output\-format=\fIformat\fP
+sets the format of the generated output file to
+.IR format .
+.PP
+The option argument
+.I format
+must be either
+.B cue
+or
+.BR toc .
+.SH "EXIT STATUS"
+.B cueconvert
+exits with status zero if it successfully coverts the input file, and
+nonzero if there were problems.
 .SH AUTHOR
-Svend Sorensen
-.
+Cuetools was written by Svend Sorensen.
+Branden Robinson contributed fixes and enhancements to the utilities and
+documentation.
 .SH "SEE ALSO"
-cuebreakpoints(1),
-cueprint(1)
+.BR cuebreakpoints (1),
+.BR cueprint (1)
diff -urN cuetools-1.3-OFFICIAL/doc/cueprint.1 cuetools-1.3/doc/cueprint.1
--- cuetools-1.3-OFFICIAL/doc/cueprint.1        2005-03-22 03:15:25.000000000 
-0500
+++ cuetools-1.3/doc/cueprint.1 2005-08-23 19:28:09.000000000 -0500
@@ -1,198 +1,186 @@
-.TH cuetools 1
-.
+.TH cueprint 1 2005-08-23 "Cuetools 1.3"
 .SH NAME
-cueprint
-.
-.SH DESCRIPTION
-cueprint \- print disc and track infomation for a cue or toc file
-.
+cueprint \- report disc and track infomation from a CUE or TOC file
 .SH SYNOPSIS
 .B cueprint
-[option...] [file...]
-.
-.SH OPTIONS
-.TP
-.B \-h, \--help
-print usage information
-.
-.TP
-.B \-i, \--input-format cue|toc
-set format of file(s)
-.
-.TP
-.B \-n, \--track-number <number>
-only print track information for single track.  The default is to print 
information for all tracks.
-.
-.TP
-.B \-d, \--disc-template <template>
-set disc template (see TEMPLATE EXPANSION)
-.
-.TP
-.B \-t, \--track-template <template>
-set track template (see TEMPLATE EXPANSION)
-.
-.SH TEMPLATE EXPANSION
-All characters in the template are reproduced in the output except for 
conversions, which begin with `%'.
-.PP
-A conversion has the form `%[flags][width][.precision]<conversion\-char>'.
-.PP
-There may be zero or more of the following flags:
-.
-.TP
-.B \-
-left justification
-.
-.TP
-.B +
-place sign before numbers
-.
-.TP
-.B ` '
-(space) place a space before a positive number
-.
-.TP
-.B 0
-pad with zeros
-.
-.TP
-.B #
-(unused)
-.
-.PP
-width is the minimum field width.  precision is the maximum width for strings.
-.PP
-Disc template expansion characters are valid for both the disc and track 
templates.
+[ {
+.B \-i
+.I format
+|
+.BR \-\-input\-format =\fIformat\fP
+} {
+.B \-n
+.I number
+|
+.BR \-\-track\-number =\fInumber\fP
+} {
+.B \-d
+.I template
+|
+.BR \-\-disc\-template =\fItemplate\fP
+} {
+.B \-t
+.I template
+|
+.BR \-\-track\-template =\fItemplate\fP
+} ]
+[
+.I file
+\&... ]
+.br
+.B cueprint \-\-help
+.SH DESCRIPTION
+.B cueprint
+reports disc and track information from CUE and TOC files, which are
+typically created by compact disc ripping software.
 .PP
-.B Disc Conversion Specifiers
-.
-.TP
-.B A
-album arranger
-.
-.TP
-.B C
-album composer
-.
-.TP
-.B G
-album genre
-.
-.TP
-.B M
-album message
-.
-.TP
-.B N
-number of tracks
-.
-.TP
-.B P
-album performer
-.
-.TP
-.B S
-album songwriter
-.
-.TP
-.B T
-album title
-.
-.TP
-.B U
-album UPC/EAN
-.
+By default,
+.B cueprint
+reports a default set of disc information, and a default set of information
+for each track on the disc.
+With options, the report can be restricted to a specific track, and the
+presentation of the disc and track information can be extensively
+customized using
+.BR printf (3)-style
+format strings (referred to here as \(oqtemplates\(cq to avoid confusion
+with the concept of file format).
+All characters in a template are reproduced as-is in the output except for
+conversions (which begin with
+.RB \(oq % \(cq)
+and escapes (which begin with
+.RB \(oq \e \(cq).
 .PP
-.B Track Conversion Specifiers
-.
-.TP
-.B a
-track arranger
-.
-.TP
-.B c
-track composer
-.
-.TP
-.B g
-track genre
-.
-.TP
-.B i
-track ISRC
-.
-.TP
-.B m
-track message
-.
-.TP
-.B n
-track number
-.
-.TP
-.B p
-track perfomer
-.
-.TP
-.B t
-track title
-.
-.TP
-.B u
-track ISRC (CD-TEXT)
-.
-.PP
-Any other character is expanded to that character.  For example, a % expands 
to a literal `%'.
-.
-.SH ESCAPES
-The following single-character escapes are recognized:
-.
-.TP
-.B \ea
-alert (bell)
-.
-.TP
-.B \eb
-backspace
-.
-.TP
-.B \ef
-formfeed
-.
-.TP
-.B \en
-newline
-.
+If no filenames are specified,
+.B cueprint
+reads from standard input, and an input format option
+.I must
+be specified.
+If one or more filenames is provided, but the input format option is not
+specified, the input format will be guessed based on each file's suffix
+(e.g.,
+.I .cue
+or
+.IR .toc ).
+This hueristic is case-insensitive.
+.SS Conversions
+A conversion has the form
+.RB \(oq % [ \fIflags\fP ][ \fIwidth\fP ][ .\fIprecision\fP ] \fItype\fP \(cq.
+.PP
+.I flags
+may be zero or more of the following:
+.TS
+nokeep;
+l      l.
+Character      Meaning
+_
+\-     left-justify expansion
++      place sign before numbers
+\(oq \(cq (space)      place a blank space before a positive number
+0      pad numbers with zeroes
+.TE
+.\"#   (unused)
+.PP
+.I width
+is the minimum field width.
+.I precision
+is the maximum width for strings.
+.I type
+is a single character which specifies the conversion type \(em apart from
+.BR % ,
+it is the only mandatory part of the conversion.
+.PP
+The available conversion types are presented in the table below; disc
+conversion types are presented in the left half of the table, and track
+conversion types in the right half.
+Disc template expansion characters are valid for both disc and track
+templates.
+.TS
+nokeep;
+l      l       l       l.
+Character      Conversion      Character       Conversion
+_
+A      album arranger  a       track arranger
+C      album composer  c       track composer
+G      album genre     g       track genre
+               i       track ISRC
+M      album message   m       track message
+N      number of tracks        n       track number
+P      album performer p       track performer
+S      album songwriter
+T      album title     t       track title
+U      album UPC/EAN   u       track ISRC (CD-TEXT)
+.TE
+.PP
+Any other character used as a conversion type expands to itself.
+This is how a literal percent sign is placed in the template; i.e.,
+.RB \(oq %% \(cq
+expands to
+.RB \(oq % \(cq.
+.SS Escapes
+The recognized escapes are all single characters, and listed in the table
+below.
+.TS
+nokeep;
+l      l.
+Escape Sequence        Expansion
+_
+\ea    alert (bell)
+\eb    backspace
+\ef    formfeed
+\en    newline
+\er    carriage return
+\et    horizontal tab
+\ev    vertical tab
+\e0    null
+.TE
+.PP
+Any other character used after the
+.RB \(oq \e \(cq
+in an escape sequence expands to itself.
+This is how a literal escape character is placed in the template; i.e.,
+.RB \(oq \e\e \(cq
+expands to
+.RB \(oq \e \(cq.
+.SH OPTIONS
 .TP
-.B \er
-carriage return
-.
+.BR \-d " \fItemplate\fP, " \-\-disc\-template=\fItemplate\fP
+set disc template (see TEMPLATE EXPANSION)
 .TP
-.B \et
-horizontal tab
-.
+.BR \-h ", " \-\-help
+displays a usage message and exits.
 .TP
-.B \ev
-vertial tab
-.
+.BR \-i " \fIformat\fP, " \-\-input\-format=\fIformat\fP
+sets the expected format of the input file(s) to
+.IR format ,
+which must be either
+.B cue
+or
+.BR toc .
+.TP
+.BR \-n " \fInumber\fP, " \-\-track\-number=\fInumber\fP
+only print track information for single track.
+The default is to print information for all tracks.
 .TP
-.B \e0
-NULL
-.
-.SH NOTES
-If no files are specified, stdin is used.  If a filename is specified and the 
format is not specified, the format will be set based on a ".cue" or ".toc" 
suffix.
-.
+.BR \-t " \fItemplate\fP, " \-\-track\-template=\fItemplate\fP
+set track template (see TEMPLATE EXPANSION)
+.SH "EXIT STATUS"
+.B cueprint
+exits with status zero if it successfully reports information from each
+input file, and nonzero if there were problems.
 .SH EXAMPLES
-To display disc and track information (using the default template for both), 
run:
+To display disc and track information (using the default template for
+both):
 .PP
-% cueprint album.cue
+.RB "% " "cueprint album.cue"
 .PP
-To print the number of tracks in a cue file, run:
+To print the number of tracks in a CUE file:
 .PP
-% cueprint -d '%N\en' album.cue
-.
+.RB "% " "cueprint -d \(aq%N\en\(aq album.cue"
 .SH AUTHOR
-Svend Sorensen
-.
+Cuetools was written by Svend Sorensen.
+Branden Robinson contributed fixes and enhancements to the utilities and
+documentation.
 .SH "SEE ALSO"
-cueconvert(1),
-cuebreakpoints(1)
+.BR cuebreakpoints (1),
+.BR cueconvert (1),
+.BR printf(3)
diff -urN cuetools-1.3-OFFICIAL/src/tools/cuebreakpoints.c 
cuetools-1.3/src/tools/cuebreakpoints.c
--- cuetools-1.3-OFFICIAL/src/tools/cuebreakpoints.c    2005-03-22 
03:15:25.000000000 -0500
+++ cuetools-1.3/src/tools/cuebreakpoints.c     2005-08-23 15:57:21.000000000 
-0500
@@ -3,18 +3,21 @@
  *
  * Copyright (C) 2004 Svend Sorensen
  * For license terms, see the file COPYING in this distribution.
+ *
+ * Modified 2005-08-23 by Branden Robinson.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <getopt.h>
+#include <getopt.h>    /* getopt_long() */
+#include <stdio.h>     /* fprintf(), printf(), snprintf(), stderr */
+#include <stdlib.h>    /* exit() */
+#include <string.h>    /* strcasecmp() */
 #include "cuefile.h"
 #include "time.h"
 
 char *progname;
 
-/* pregap correction modes
+/*
+ * pregap correction modes:
  * APPEND - append pregap to previous track (except for first track)
  * PREPEND - prefix pregap to current track
  * SPLIT - print breakpoints for beginning and end of pregap
@@ -23,22 +26,36 @@
 
 void usage (int status)
 {
+       char synopsis[1024];
+
+       /* TODO: We could use asprintf() if we know we're using GNU libc. */
+       snprintf(synopsis, 1023, "usage: %s [option ...] [file ...]\n",
+                progname);
+
        if (0 == status) {
-               fprintf(stdout, "%s: usage: cuebreakpoints [option...] 
[file...]\n", progname);
-               fputs("\
-\n\
-OPTIONS\n\
--h, --help                     print usage\n\
--i, --input-format cue|toc     set format of file(s)\n\
---append-gaps                  append pregaps to previous track (default)\n\
---prepend-gaps                 prefix pregaps to track\n\
---split-gaps                   split at beginning and end of pregaps\n\
-", stdout);
+               printf("%s", synopsis);
+               printf("Report track breakpoints from a CUE or TOC file.\n"
+                      "\n"
+                      "Options:\n"
+                      "-h, --help\t\t\t\tdisplay this message and exit\n"
+                      "-i {cue|toc}, --input-format={cue|toc}\tset format of"
+                      " input file(s)\n"
+                      "--append-gaps\t\t\t\tappend pregaps to previous track\n"
+                      "--prepend-gaps\t\t\t\tprefix pregaps to track\n"
+                      "--split-gaps\t\t\t\tsplit at beginning and end of"
+                      " pregaps\n"
+                      "\n"
+                      "The default handling of gaps is as if --append-gaps"
+                      " were specified.\n"
+                      "\n"
+                      "See the %s(1) manual page for more information.\n",
+                      progname);
        } else {
-               fprintf(stderr, "run `%s --help' for usage\n", progname);
+               fprintf(stderr, "%sRun \"%s --help\" for more information.\n",
+                       synopsis, progname);
        }
 
-       exit (status);
+       exit(status);
 }
 
 void print_m_ss_ff (long frame)
@@ -46,7 +63,7 @@
        int m, s, f;
 
        time_frame_to_msf(frame, &m, &s, &f);
-       printf ("%d:%02d.%02d\n", m, s, f);
+       printf("%d:%02d.%02d\n", m, s, f);
 }
 
 void print_breakpoint (long b)
@@ -64,7 +81,8 @@
 
        for (i = 1; i <= cd_get_ntrack(cd); i++) {
                track = cd_get_track(cd, i);
-               /* when breakpoint is at:
+               /*
+                * when breakpoint is at:
                 * index 0: gap is prepended to track
                 * index 1: gap is appended to previous track
                 */
@@ -75,12 +93,17 @@
                }
 
                if (gaps == APPEND || gaps == SPLIT) {
-                       /* there is no previous track to append the first 
tracks pregap to */
-                       /* TODO:  should first track's pregap be split when 
appending?
-                        * this could be a suprising default
+                       /*
+                        * There is no previous track to append the first
+                        * track's pregap to.
+                        */
+                       /*
+                        * TODO: Should first track's pregap be split when
+                        * appending?  This could be a suprising default.
                         */
                        if (1 < i) {
-                               b += track_get_index(track, 1) - 
track_get_zero_pre(track);
+                               b += track_get_index(track, 1)
+                                    - track_get_zero_pre(track);
                                print_breakpoint(b);
                        }
                }
@@ -92,7 +115,8 @@
        Cd *cd = NULL;
 
        if (NULL == (cd = cf_parse(name, &format))) {
-               fprintf(stderr, "%s: input file error\n", name);
+               fprintf(stderr, "%s: error: unable to parse input file"
+                       " \"%s\"\n", progname, name);
                return -1;
        }
 
@@ -105,9 +129,10 @@
 {
        int format = UNKNOWN;
        int gaps = APPEND;
+       int ret = 0;            /* return value of breaks() */
 
        /* option variables */
-       char c;
+       int c;
        /* getopt_long() variables */
        extern char *optarg;
        extern int optind;
@@ -121,7 +146,7 @@
                {NULL, 0, NULL, 0}
        };
 
-       progname = *argv;
+       progname = argv[0];
 
        while (-1 != (c = getopt_long(argc, argv, "hi:", longopts, NULL))) {
                switch (c) {
@@ -129,13 +154,15 @@
                        usage(0);
                        break;
                case 'i':
-                       if (0 == strcmp("cue", optarg))
+                       if (0 == strcasecmp("cue", optarg))
                                format = CUE;
-                       else if (0 == strcmp("toc", optarg))
+                       else if (0 == strcasecmp("toc", optarg))
                                format = TOC;
-                       else
-                               fprintf(stderr, "%s: illegal format `%s'\n", 
progname, optarg);
+                       else {
+                               fprintf(stderr, "%s: error: unknown input file"
+                                       " format \"%s\"\n", progname, optarg);
                                usage(1);
+                       }
                        break;
                case 'a':
                        gaps = APPEND;
@@ -152,12 +179,19 @@
                }
        }
 
+       /* What we do depends on the number of operands. */
        if (optind == argc) {
-               breaks("-", format, gaps);
+               /* No operands: report breakpoints of stdin. */
+               ret = breaks("-", format, gaps);
        } else {
-               for (; optind < argc; optind++)
-                       breaks(argv[optind], format, gaps);
+               /* Report track breakpoints for each operand. */
+               for (; optind < argc; optind++) {
+                       ret = breaks(argv[optind], format, gaps);
+                       /* Bail out if breaks() returns nonzero. */
+                       if (!ret)
+                               break;
+               }
        }
 
-       return 0;
+       return ret;
 }
diff -urN cuetools-1.3-OFFICIAL/src/tools/cueconvert.c 
cuetools-1.3/src/tools/cueconvert.c
--- cuetools-1.3-OFFICIAL/src/tools/cueconvert.c        2005-03-22 
03:15:25.000000000 -0500
+++ cuetools-1.3/src/tools/cueconvert.c 2005-08-23 15:53:03.000000000 -0500
@@ -3,32 +3,45 @@
  *
  * Copyright (C) 2004 Svend Sorensen
  * For license terms, see the file COPYING in this distribution.
+ *
+ * Modified 2005-08-23 by Branden Robinson.
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <getopt.h>
+#include <getopt.h>    /* getopt_long() */
+#include <stdio.h>     /* fprintf(), printf(), snprintf(), stderr */
+#include <stdlib.h>    /* exit() */
+#include <string.h>    /* strcasecmp() */
 #include "cuefile.h"
 
 char *progname;
 
 void usage (int status)
 {
+       char synopsis[1024];
+
+       /* TODO: We could use asprintf() if we know we're using GNU libc. */
+       snprintf(synopsis, 1023, "usage: %s [option ...] [infile [outfile]]\n",
+                progname);
+
        if (0 == status) {
-               fprintf(stdout, "%s: usage: cueconvert [option...] [infile 
[outfile]]\n", progname);
-               fputs("\
-\n\
-OPTIONS\n\
--h, --help                     print usage\n\
--i, --input-format cue|toc     set format of input file\n\
--o, --output-format cue|toc    set format of output file\n\
-", stdout);
+               printf("%s", synopsis);
+               printf("Convert files between CUE and TOC formats.\n"
+                      "\n"
+                      "Options:\n"
+                      "-h, --help\t\t\t\tdisplay this message and exit\n"
+                      "-i {cue|toc}, --input-format={cue|toc}\tset format of"
+                      " input file\n"
+                      "-o {cue|toc}, --output-format={cue|toc}\tset format of"
+                      " output file\n"
+                      "\n"
+                      "See the %s(1) manual page for more information.\n",
+                      progname);
        } else {
-               fprintf(stderr, "run `%s --help' for usage\n", progname);
+               fprintf(stderr, "%sRun \"%s --help\" for more information.\n",
+                               synopsis, progname);
        }
 
-       exit (status);
+       exit(status);
 }
 
 int convert (char *iname, int iformat, char *oname, int oformat)
@@ -36,7 +49,8 @@
        Cd *cd = NULL;
 
        if (NULL == (cd = cf_parse(iname, &iformat))) {
-               fprintf(stderr, "input file error\n");
+               fprintf(stderr, "%s: error: unable to parse input file\n",
+                       progname);
                return -1;
        }
 
@@ -62,9 +76,9 @@
 {
        int iformat = UNKNOWN;
        int oformat = UNKNOWN;
-       /* option variables */
-       char c;
+       int ret = 0;            /* return value of convert() */
        /* getopt_long() variables */
+       int c;
        extern char *optarg;
        extern int optind;
 
@@ -75,7 +89,7 @@
                {NULL, 0, NULL, 0}
        };
 
-       progname = *argv;
+       progname = argv[0];
 
        while (-1 != (c = getopt_long(argc, argv, "hi:o:", longopts, NULL))) {
                switch (c) {
@@ -83,22 +97,26 @@
                        usage(0);
                        break;
                case 'i':
-                       if (0 == strcmp("cue", optarg))
+                       if (0 == strcasecmp("cue", optarg))
                                iformat = CUE;
-                       else if (0 == strcmp("toc", optarg))
+                       else if (0 == strcasecmp("toc", optarg))
                                iformat = TOC;
-                       else
-                               fprintf(stderr, "%s: illegal format `%s'\n", 
progname, optarg);
+                       else {
+                               fprintf(stderr, "%s: unknown input file format"
+                                       " \"%s\"\n", progname, optarg);
                                usage(1);
+                       }
                        break;
                case 'o':
-                       if (0 == strcmp("cue", optarg))
+                       if (0 == strcasecmp("cue", optarg))
                                oformat = CUE;
-                       else if (0 == strcmp("toc", optarg))
+                       else if (0 == strcasecmp("toc", optarg))
                                oformat = TOC;
-                       else
-                               fprintf(stderr, "%s: illegal format `%s'\n", 
progname, optarg);
+                       else {
+                               fprintf(stderr, "%s: unknown output file format"
+                                       " \"%s\"\n", progname, optarg);
                                usage(1);
+                       }
                        break;
                default:
                        usage(1);
@@ -106,15 +124,23 @@
                }
        }
 
+       /* What we do depends on the number of operands. */
        if (optind == argc) {
-               convert("-", iformat, "-", oformat);
+               /* No operands: convert stdin to stdout. */
+               ret = convert("-", iformat, "-", oformat);
        } else if (optind == argc - 1) {
-               convert(argv[optind], iformat, "-", oformat);
+               /* One operand: convert operand file to stdout. */
+               ret = convert(argv[optind], iformat, "-", oformat);
        } else if (optind == argc - 2) {
-               convert(argv[optind], iformat, argv[optind + 1], oformat);
+               /* Two operands: convert input file to output file. */
+               ret = convert(argv[optind], iformat, argv[optind + 1], oformat);
        } else {
                usage(1);
        }
 
-       return 0;
+       if (0 != ret) {
+               fprintf(stderr, "%s: conversion failed\n", progname);
+       }
+
+       return ret;
 }
diff -urN cuetools-1.3-OFFICIAL/src/tools/cueprint.c 
cuetools-1.3/src/tools/cueprint.c
--- cuetools-1.3-OFFICIAL/src/tools/cueprint.c  2005-03-22 03:15:25.000000000 
-0500
+++ cuetools-1.3/src/tools/cueprint.c   2005-08-23 16:00:57.000000000 -0500
@@ -3,13 +3,15 @@
  *
  * Copyright (C) 2004 Svend Sorensen
  * For license terms, see the file COPYING in this distribution.
+ *
+ * Modified 2005-08-23 by Branden Robinson.
  */
 
-#include <stdio.h>
-#include <stdlib.h>            /* exit() */
-#include <string.h>            /* strcmp() */
-#include <getopt.h>
-#include <ctype.h>             /* isdigit() */
+#include <ctype.h>     /* isdigit() */
+#include <getopt.h>    /* getopt_long() */
+#include <stdio.h>     /* fprintf(), printf(), snprintf(), stderr */
+#include <stdlib.h>    /* exit() */
+#include <string.h>    /* strcasecmp() */
 #include "cuefile.h"
 
 /* default templates */
@@ -57,52 +59,44 @@
 
 void usage (int status)
 {
+       char synopsis[1024];
+
+       /* TODO: We could use asprintf() if we know we're using GNU libc. */
+       snprintf(synopsis, 1023, "usage: %s [option ...] [file ...]\n",
+                progname);
+
        if (0 == status) {
-               fprintf(stdout, "%s: usage: cueprint [option...] [file...]\n", 
progname);
-               fputs("\
-\n\
-OPTIONS\n\
--h, --help                     print usage\n\
--i, --input-format cue|toc     set format of file(s)\n\
--n, --track-number <number>    only print track information for single track\n\
--d, --disc-template <template> set disc template (see TEMPLATE EXPANSION)\n\
--t, --track-template <template>        set track template (see TEMPLATE 
EXPANSION)\n\
-\n\
-Template Expansion\n\
-Disc:\n\
-%A - album arranger\n\
-%C - album composer\n\
-%G - album genre\n\
-%M - album message\n\
-%N - number of tracks\n\
-%P - album performer\n\
-%S - album songwriter\n\
-%T - album title\n\
-%U - album UPC/EAN\n\
-Track:\n\
-%a - track arranger\n\
-%c - track composer\n\
-%g - track genre\n\
-%i - track ISRC\n\
-%m - track message\n\
-%n - track number\n\
-%p - track perfomer\n\
-%t - track title\n\
-%u - track ISRC (CD-TEXT)\n\
-\n\
-Any other %<character> is expanded to that character.  For example, to get a\n\
-'%', use %%.\n\
-\n\
-", stdout);
-               fprintf(stdout, "default disc template is:\n%s\n", D_TEMPLATE);
-               fprintf(stdout, "default track template is:\n%s\n", T_TEMPLATE);
+               printf("%s", synopsis);
+               printf("Report disc and track information from a CUE or TOC"
+                      " file.\n"
+                      "\n"
+                      "Options:\n"
+                      "-d TEMPLATE, --disc-template=TEMPLATE\tset disc"
+                      " template\n"
+                      "-h, --help\t\t\t\tdisplay this message and exit\n"
+                      "-i {cue|toc}, --input-format={cue|toc}\tset format of"
+                      " input file(s)\n"
+                      "-n N, --track-number=N\t\t\treport information for"
+                      " track N only\n"
+                      "-t TEMPLATE, --track-template=TEMPLATE\tset track"
+                      " template\n"
+                      "\n"
+                      "TEMPLATE is a printf(3)-style format string.\n"
+                      "\n"
+                      "Default disc template: %s\n"
+                      "Default track template: %s\n"
+                      "See the %s(1) manual page for more information.\n",
+                      D_TEMPLATE, T_TEMPLATE, progname);
        } else {
-               fprintf(stderr, "run `%s --help' for usage\n", progname);
+               fprintf(stderr, "%sRun \"%s --help\" for more information.\n",
+                       synopsis, progname);
        }
 
-       exit (status);
+       exit(status);
 }
 
+/* TODO: Shouldn't we be using vprintf() to help us out with this stuff? */
+
 void disc_field (char *conv, int length, Cd *cd, Value *value)
 {
        char *c;        /* pointer to conversion character */
@@ -230,8 +224,9 @@
 
 }
 
-/* print a % conversion specification
- * %[flag(s)][width][.precision]<conversion-char>
+/*
+ * Print a conversion specification.
+ * [flag(s)][width][.precision]<conversion-char>
  */
 void print_conv (char *start, int length, Cd *cd, int trackno)
 {
@@ -240,7 +235,7 @@
        char *c;        /* pointer to conversion-char */
 
        /* TODO: use strndup? */
-       conv = malloc ((unsigned) (length + 1));
+       conv = malloc((unsigned) (length + 1));
        strncpy(conv, start, length);
        conv[length] = '\0';
 
@@ -303,7 +298,7 @@
                                conv_length++;
                                c++;
                        }
-                       
+
                        /* precision */
                        /* '*' not recognized */
                        if ('.' == *c) {
@@ -329,7 +324,8 @@
        }
 }
 
-int info (char *name, int format, int trackno, char *d_template, char 
*t_template)
+int info (char *name, int format, int trackno, char *d_template,
+         char *t_template)
 {
        Cd *cd = NULL;
        int ntrack;
@@ -359,8 +355,9 @@
        return 0;
 }
 
-/* translate escape sequences in a string
- * string is overwritten and terminated
+/*
+ * Translate escape sequences in a string.
+ * The string is overwritten and terminated.
  * TODO: this does not handle octal and hexidecimal escapes
  *       except for \0
  */
@@ -420,11 +417,13 @@
 int main (int argc, char **argv)
 {
        int format = UNKNOWN;
-       int trackno = -1;               /* track number (-1 = unspecified, 0 = 
disc info) */
+       int trackno = -1;               /* track number (-1 = unspecified,
+                                                         0 = disc info) */
        char *d_template = NULL;        /* disc template */
        char *t_template = NULL;        /* track template */
+       int ret = 0;                    /* return value of info() */
        /* getopt_long() variables */
-       char c;
+       int c;
        extern char *optarg;
        extern int optind;
 
@@ -437,21 +436,24 @@
                {NULL, 0, NULL, 0}
        };
 
-       progname = *argv;
+       progname = argv[0];
 
-       while (-1 != (c = getopt_long(argc, argv, "hi:n:d:t:", longopts, 
NULL))) {
+       while (-1 != (c = getopt_long(argc, argv, "hi:n:d:t:", longopts, NULL)))
+       {
                switch (c) {
                case 'h':
                        usage(0);
                        break;
                case 'i':
-                       if (0 == strcmp("cue", optarg))
+                       if (0 == strcasecmp("cue", optarg))
                                format = CUE;
-                       else if (0 == strcmp("toc", optarg))
+                       else if (0 == strcasecmp("toc", optarg))
                                format = TOC;
-                       else
-                               fprintf(stderr, "%s: illegal format `%s'\n", 
progname, optarg);
+                       else {
+                               fprintf(stderr, "%s: error: unknown input file"
+                                       " format \"%s\"\n", progname, optarg);
                                usage(1);
+                       }
                        break;
                case 'n':
                        trackno = atoi(optarg);
@@ -468,7 +470,7 @@
                }
        }
 
-       /* if no disc or track template is set, use the defaults for both */
+       /* If no disc or track template is set, use the defaults for both. */
        /* TODO: alternative to strdup to get variable strings? */
        if (NULL == d_template && NULL == t_template) {
                d_template = strdup(D_TEMPLATE);
@@ -481,16 +483,24 @@
                        t_template = strdup("");
        }
 
-       /* translate escape sequences */
+       /* Translate escape sequences. */
        translate_escapes(d_template);
        translate_escapes(t_template);
 
+       /* What we do depends on the number of operands. */
        if (optind == argc) {
-               info("-", format, trackno, d_template, t_template);
+               /* No operands: report information about stdin. */
+               ret = info("-", format, trackno, d_template, t_template);
        } else {
-               for (; optind < argc; optind++)
-                       info(argv[optind], format, trackno, d_template, 
t_template);
+               /* Report information for each operand. */
+               for (; optind < argc; optind++) {
+                       ret = info(argv[optind], format, trackno, d_template,
+                                  t_template);
+                       /* Bail out if info() returns nonzero. */
+                       if (!ret)
+                               break;
+               }
        }
 
-       return 0;
+       return ret;
 }

Reply via email to