Re: [PATCH] SEQ BUG

2007-06-23 Thread Jim Meyering
Paul Eggert [EMAIL PROTECTED] wrote:

 Pádraig Brady [EMAIL PROTECTED] writes:

 The attached patch handles this by
 only counting signficant digits from the operands.

 I'd rather use the idea I proposed earlier.  Here's an implementation
 of it, which works on all the test cases in your patch.  In addition,
 it works on the wilder counterexamples I suggested (which alas we
 can't put into the test suite since they're machine-specific).

 2007-06-22  Paul Eggert  [EMAIL PROTECTED]

   * NEWS: seq no longer mishandles obvious cases like
   seq 0 0.01 0.03 by omitting the last output number.
   * doc/coreutils.texi (seq invocation): Remove advice about workaround
   for seq off-by-one problem, since the bug is fixed now.  Replace
   it with more-generic advice about rounding error.
   * src/seq.c (long_double_format, print_numbers):
   New arg NUMERIC_FORMAT.  All uses changed.

 2007-06-22  Pádraig Brady  [EMAIL PROTECTED]  (trivial change)

   * tests/seq/basic: Add test cases for seq off-by-one problem.

Thanks to both of you!
I've applied that patch with minor changes to make the new code use the
STREQ macro rather than using strcmp directly.  That has been informal
policy for years, since using STREQ makes the code more readable.

In fact, I think it's worth an addition to Makefile.maint,
so converted a few more and added a rule to enforce the policy:

2007-06-23  Jim Meyering  [EMAIL PROTECTED]

Prefer STREQ (a, b) over strcmp (a, b) == 0; similar for != 0.
* src/base64.c (main): Likewise.
* src/install.c (setdefaultfilecon): Likewise.
* src/sort.c (main): Likewise.
* Makefile.maint (sc_prohibit_strcmp): New rule.
* .x-sc_prohibit_strcmp: New file, to list the few exceptions.
* Makefile.am (EXTRA_DIST): Add .x-sc_prohibit_strcmp.


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils


Re: Simplifying command line parsing with Genparse

2007-06-23 Thread Michael Geng
On Sat, Jun 16, 2007 at 07:23:09PM +0200, Michael Geng wrote:
 On Thu, Jun 07, 2007 at 02:44:38PM +0200, Jim Meyering wrote:
  However, before I even consider it seriously, it'll need
  some improvements:
  
- it must detect any and all write failures[*]
 
 I just added a new release of genparse 
 (http://sourceforge.net/project/showfiles.php?group_id=4341package_id=4354release_id=516584)
 which now also checks file write and close operations, not only
 file open operations as it was before.
 
- packaging so that I can run ./configure  make  make check, and
if I don't happen to have cppunit infrastructure, gcj or something
similar, it should tell me about it directly, rather than causing
harder-to-diagnose build failures.
 
 I went through all these tools and updated configure.ac (and related files)
 such that you get a warning if something is missing but you can still
 compile genparse. For example if you don't have gcj installed then it 
 automatically removes the java example from the list of build targets.
 It now checks for cunit, cppunit, junit, gcj, doxygen, texi2html, texi2pdf 
 and man2html.
 
- one of the generated .c files I looked at calls strdup but doesn't
check for a NULL return value or (less important) attempt to avoid
the leak when the corresponding --backup=S option appears twice or 
  more.
 
 I'm working on that and I'll let you know when this is finished.

I again released a new version of genparse (0.6.5) which doesn't allocate
any memory on the heap any more because I think this is a better concept.
So it doesn't generate any calls to strdup() or malloc() any more. As a
consequence the parser function changed from 

struct arg_t *Cmdline(int argc, char *argv[]) 

to

void Cmdline(struct arg_t *my_args, int argc, char *argv[]). 

See the Genparse examples page (http://genparse.sourceforge.net/examples.html) 
which is also updated.

 
- not exactly essential, but highly recommended: it should work
with the latest autoconf and automake
 
 I'm using autoconf version 2.59 and automake 1.9.5. Aditionally I renamed 
 configure.in to configure.ac which appears to be the standard today and 
 removed acconfig.h because it appears to be deprecated. This might have
 produced some warnings before. 
 
  [*] with genparse-0.6.3, I get this:
  
$ strace -o log -e write ./genparse -o /full/tmp/foo ../examples/ls.gp \
   echo exit status 0
creating /full/tmp/foo.h...done
creating /full/tmp/foo.c...done
exit status 0
$ tail -2 log
write(3, /***..., 80) = -1 ENOSPC (No space 
  left on device)
write(1, creating /full/tmp/foo.c...done\n, 32) = 32
  
  The two files it claims to have created are both empty,
  and genparse exited successfully.
  This means genparse is not detecting write or close failures.
  
  Note that in the example above, /full/tmp is a full file system that still
  has free inodes, so open can create new files, but writes always fail.
 
 I could verify this behavior and I hope it's fixed now. Now it tells you
 that it can't write to the file and returns with a non zero exit status.
 
 Thanks again for your input,
 Michael
 
 
 ___
 Bug-coreutils mailing list
 Bug-coreutils@gnu.org
 http://lists.gnu.org/mailman/listinfo/bug-coreutils


___
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils