[PATCH] Support arbitrary-precision arithmetic in expr.

2008-08-02 Thread James Youngman
This code has more instances of #if HAVE_GMP than I would like, but I 
thought it was important to be able to transition smoothly from 
native arithmetic to arbitrary-precision arithmetic.


2008-08-02  James Youngman  <[EMAIL PROTECTED]>

Support arbitrary-precision arithmetic in expr.
* src/Makefile.am (expr_LDADD): Link expr against GNU MP.
* doc/coreutils.texi (expr invocation): Describe --bignum,
--no-bignum.   Explain the new arbitrary-precision functionality.
* NEWS: Indicate that arbitrary-precision arithmetic is now
supported in expr.
* src/expr.c (enum valtype): Added mp_integer, signifying a GNU MP
number.
(usage): Document the new options --bignum and --no-bignum which
force and prohibit the use of arbitrary-precision arithmetic,
respectively.
(long_options): data structure for getopt_long, which we need to
use to parse the options mentioned above.
(main): parse these options with getopt_long instead of
parse_long_options.
(valinfo): Downgrade the numeric member of the union from
intmax_t to signed long, since MP lacks functions for promoting an
intmax_t to an arbitrary-precision quantity.
(enum arithmetic_mode): Represents the current choice between
--bignum, --no-bignum and the default (automatically switch from
one to the other if needed).
(integer_overflow): issue a more explicit error message indicating
that MP is not available.
(string_too_long): new function, emits a fatal error message for
the case where an argument to the 'index' expression is too long
for a string offset to be represented.
(int_value): With --bignum, create the value as mp_integer rather
than plain integer.
(substr_value): factored out of eval6; implements "substr".
(freev): also destroy mp_integer values.  Check that no mp_integer
values exist if --no-bignum was specified.
(printv, null, tostring): support mp_integer.
(toint): new funtion for converting from string or mp_integer to
integer.
(getsize): extracts a size_t value from a VALUE object; used to
implement substr.
(promote): promotes a value from integer to mp_integer.
(domult, dodivide): functions for multiplication and division,
factored out of eval4.
(doadd): addition/subraction function, factpred out of eval3.
(eval3): support mp_integer types; call doadd.
(eval4): support mp_integer types; call domult, dodivide.
(eval6): support mp_integer offsets and lengths for "substr" and
"index".
* TODO: Mention that expr supports arbitrary-precision arithmetic,
and suggest that this might also be a good idea for seq and test.
* AUTHORS (expr): Add James Youngman.
---
 AUTHORS|2 +-
 NEWS   |5 +-
 TODO   |4 +
 doc/coreutils.texi |   17 ++-
 src/Makefile.am|3 +
 src/expr.c |  655 +---
 6 files changed, 593 insertions(+), 93 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index eab9bec..9c3d990 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -25,7 +25,7 @@ du: Torbjörn Granlund, David MacKenzie, Paul Eggert, Jim 
Meyering
 echo: Brian Fox, Chet Ramey
 env: Richard Mlynarik, David MacKenzie
 expand: David MacKenzie
-expr: Mike Parker
+expr: Mike Parker, James Youngman
 factor: Paul Rubin
 false: Jim Meyering
 fmt: Ross Paterson
diff --git a/NEWS b/NEWS
index dfe893c..0957757 100644
--- a/NEWS
+++ b/NEWS
@@ -19,8 +19,9 @@ GNU coreutils NEWS-*- 
outline -*-
   With this new option, after a short read, dd repeatedly calls read,
   until it fills the incomplete block, reaches EOF, or encounters an error.
 
-  factor accepts arbitrarily large numbers and factors them using
-  Pollard's rho algorithm.
+  If the GNU MP library is available at configure time, factor and
+  expr support arbitrarily large numbers.  Pollard's rho algorithm is
+  used to factor large numbers.
 
   md5sum now accepts the new option, --quiet, to suppress the printing of
   'OK' messages.  sha1sum, sha224sum, sha384sum, and sha512sum accept it, too.
diff --git a/TODO b/TODO
index c7bb820..4b8b26e 100644
--- a/TODO
+++ b/TODO
@@ -156,6 +156,10 @@ remove all uses of the `register' keyword: Done.  add a 
maint.mk rule
 remove or adjust chown's --changes option, since it
   can't always do what it currently says it does.
 
+Support arbitrary-precision arithmetic in those tools for which it
+makes sense.  Likely candidates include seq, and perhaps test.
+Factor and expr already support this.
+
 Adapt tools like wc, tr, fmt, etc. (most of the textutils) to be
   multibyte aware.  The problem is that I want to avoid duplicating
   significant blocks of logic, yet I also want to incur only minimal
diff --git

Re: test failures on AIX 5.3: misc/sort-merge, test-copy-acl.sh

2008-08-02 Thread Jim Meyering
Ralf Wildenhues <[EMAIL PROTECTED]> wrote:
> I'm getting the following test failures on AIX 5.3.
> They are using current git coreutils and gnulib, and
> gettext 0.16.1 IIRC.  The UNKNOWN-dirty is because I
> must like it that way, I guess.  ;-)

Thanks for the report!
...
> nmerge-yes...
> nmerge-no...
> sort-merge: test nmerge-no: stderr mismatch, comparing nmerge-no.E (actual) 
> and nmerge-no.1 (expected)
> *** nmerge-no.E Sat Aug  2 14:36:08 2008
> --- nmerge-no.1 Sat Aug  2 14:36:08 2008
> ***
> *** 1 
> ! sort: cannot create temporary file: : No such file or directory
> --- 1 
> ! sort: cannot create temporary file
> batch-size...
> Can't remove directory 
> /home/rwild/coreutils/build-powerpc-ibm-aix5.3.0.0/tests/sort-merge.tmp-1XVm: 
> Device busy at /usr/opt/perl5/lib/5.8.2/File/Temp.pm line 858
> gmake[2]: *** [test-suite.log] Error 1

Sounds like a file is being left open, and
that inhibits directory removal on that system.

Does this change help?  It makes sort use a *hopefully*-nonexistent
temporary directory that is not "."-relative.

diff --git a/tests/misc/sort-merge b/tests/misc/sort-merge
index fb7c63c..27b014b 100755
--- a/tests/misc/sort-merge
+++ b/tests/misc/sort-merge
@@ -29,8 +29,9 @@ my @inputs = (+(map{{IN=> {"empty$_"=> ''}}}1..3), {IN=> 
{foo=> "foo\n"}});

 my $big_input = "aaa\n" x 1024;

-# don't need to check for existence, since we're running in a temp dir
-my $badtmp = 'does/not/exist';
+my $badtmp = "/does/not/exist-$$";
+-e $badtmp
+  and (warn "skipping this test: $badtmp exists"), exit 77;

 # 2^64+1
 my $bigint = "18446744073709551617";

If that doesn't help, please remove 'nmerge-no's ERR_SUBST line and
rerun the test -- that might reveal a more useful diagnostic in the diffs.

---
Regarding the ACL failure,
I don't have access to any AIX systems, so if you
can give a little more info, that'd help.

I.e., in gnulib-tests/test-sameacls.c, there are two blocks:

  #elif HAVE_ACLX_GET /* AIX */
  ...
  #elif HAVE_STATACL /* older AIX */
  ...

Knowing which you're using and where/how (lineno/errno value)
it's failing would help.


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


test failures on AIX 5.3: misc/sort-merge, test-copy-acl.sh

2008-08-02 Thread Ralf Wildenhues
Hi Jim,

I'm getting the following test failures on AIX 5.3.
They are using current git coreutils and gnulib, and
gettext 0.16.1 IIRC.  The UNKNOWN-dirty is because I
must like it that way, I guess.  ;-)

Cheers,
Ralf

===
   GNU coreutils UNKNOWN-dirty: tests/test-suite.log
===

1 of 347 tests failed.  (54 tests were not run).

.. contents:: :depth: 2


FAIL: misc/sort-merge.log (exit: 1)
===

sort-merge: test nmerge-no: stderr mismatch, comparing nmerge-no.E (actual) and
nmerge-no.1 (expected)
*** nmerge-no.E Sat Aug  2 12:44:21 2008
--- nmerge-no.1 Sat Aug  2 12:44:21 2008
***
*** 1 
! sort: cannot create temporary file: : No such file or directory
--- 1 
! sort: cannot create temporary file
Can't remove directory 
/home/rwild/coreutils/build-powerpc-ibm-aix5.3.0.0/tests/sort-merge.tmp-WR19: 
Device busy at /usr/opt/perl5/lib/5.8.2/File/Temp.pm line 858

==
   GNU coreutils UNKNOWN-dirty: gnulib-tests/test-suite.log
==

1 of 99 tests failed.  (5 tests were not run).

.. contents:: :depth: 2


Verbose test failure:

FAIL: misc/sort-merge.log (exit: 1)
===

sort (GNU coreutils) UNKNOWN-dirty
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and Paul Eggert.
m1...
nmerge-0...
nmerge-1...
nmerge-neg...
nmerge-nan...
nmerge-big...
nmerge-yes...
nmerge-no...
sort-merge: test nmerge-no: stderr mismatch, comparing nmerge-no.E (actual) and 
nmerge-no.1 (expected)
*** nmerge-no.E Sat Aug  2 14:36:08 2008
--- nmerge-no.1 Sat Aug  2 14:36:08 2008
***
*** 1 
! sort: cannot create temporary file: : No such file or directory
--- 1 
! sort: cannot create temporary file
batch-size...
Can't remove directory 
/home/rwild/coreutils/build-powerpc-ibm-aix5.3.0.0/tests/sort-merge.tmp-1XVm: 
Device busy at /usr/opt/perl5/lib/5.8.2/File/Temp.pm line 858
gmake[2]: *** [test-suite.log] Error 1



FAIL: test-copy-acl.sh.log (exit: 1)


error accessing the ACLs of file tmpfile0
./../../coreutils/gnulib-tests/test-copy-acl.sh[5]: 978962 IOT/Abort 
trap(coredump)

Verbose test failure:
FAIL: test-copy-acl.sh.log (exit: 1)


+ func_tmpdir
+ + pwd
builddir=/home/rwild/coreutils/build-powerpc-ibm-aix5.3.0.0/gnulib-tests
+ cd /home/rwild/coreutils/build-powerpc-ibm-aix5.3.0.0/gnulib-tests
+ cd /tmp/glR-ebEa
+ rm -f tmpfile[0-9] tmpaclout[0-2]
+ echo Simple contents
+ 1> tmpfile0
+ chmod 600 tmpfile0
+ acl_flavor=none
+ 2> /dev/null
+ 2> /dev/null
+ 2> /dev/null
+ 2> /dev/null
+ acl_flavor=aix
+ func_test_copy tmpfile0 tmpfile1
error accessing the ACLs of file tmpfile0
./../../coreutils/gnulib-tests/test-copy-acl.sh[5]: 462880 IOT/Abort 
trap(coredump)
+ exit 1



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


Re: [PATCH] "date" malfunctions in the Turkish locale

2008-08-02 Thread Jim Meyering
Vefa Bicakci <[EMAIL PROTECTED]> wrote:
> As you can guess from the subject line, the date program

Thank you for the bug report!
To summarize, this invocation of date should not fail:

$ LC_MESSAGES=C LC_CTYPE=tr_TR.UTF-8 date -d Fri
date: invalid date `Fri'
...
> +  setlocale(LC_ALL, "C");
>/* Make it uppercase.  */
>for (p = word; *p; p++)
>  {
>unsigned char ch = *p;
>*p = toupper (ch);
>  }
> +  setlocale(LC_ALL, "");

Thanks for the patch.
However, I can't use it for two reasons:
  - first, it doesn't necessarily restore the locale settings
to pre-get_date state (though that could be fixed).

More importantly,
  - it changes process-global state (albeit temporarily), which is
better avoided in multi-threaded applications.

Here's a proposed patch to solve the problem without changing locale.
Since tables are all ASCII, we can simply use c_toupper instead
of toupper.  While not necessary, I've gone ahead and changed to
c_isspace and c_isalpha as well.  Any application that relies on getdate
skipping leading white space characters not in the ASCII set already has
locale-dependent bugs.  In other words, while this change does restrict
the input grammar slightly, it is for a good cause: making the grammar
locale-independent.

Barring objections, I'll push this on Monday.

>From cfd6d6448c3e1f1fec7f50ad1b58d252d172eec8 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[EMAIL PROTECTED]>
Date: Sat, 2 Aug 2008 15:40:39 +0200
Subject: [PATCH] getdate.y: avoid locale-dependent date parsing failure

In Turkish locales, getdate would fail to recognize keywords
containing a lowercase "i".  The solution is not to rely on
locale-sensitive case-conversion.
* lib/getdate.y: Include  rather than .
(lookup_word): Use c_toupper in place of toupper.
(yylex, get_date): Use c_ prefixed variants of isspace and isalpha, too.
Reported by Vefa Bicakci <[EMAIL PROTECTED]> in
.
---
 ChangeLog |   12 
 lib/getdate.y |   14 +++---
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e5bbf45..03328e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-08-02  Jim Meyering  <[EMAIL PROTECTED]>
+
+   getdate.y: avoid locale-dependent date parsing failure
+   In Turkish locales, getdate would fail to recognize keywords
+   containing a lowercase "i".  The solution is not to rely on
+   locale-sensitive case-conversion.
+   * lib/getdate.y: Include  rather than .
+   (lookup_word): Use c_toupper in place of toupper.
+   (yylex, get_date): Use c_ prefixed variants of isspace and isalpha, too.
+   Reported by Vefa Bicakci <[EMAIL PROTECTED]> in
+   .
+
 2008-08-02  Ralf Wildenhues  <[EMAIL PROTECTED]>

Portability fix for GNU make 3.79.1.
diff --git a/lib/getdate.y b/lib/getdate.y
index 695fd59..a94bf8b 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -60,7 +60,7 @@
 # undef static
 #endif

-#include 
+#include 
 #include 
 #include 
 #include 
@@ -900,7 +900,7 @@ lookup_word (parser_control const *pc, char *word)
   for (p = word; *p; p++)
 {
   unsigned char ch = *p;
-  *p = toupper (ch);
+  *p = c_toupper (ch);
 }

   for (tp = meridian_table; tp->name; tp++)
@@ -965,7 +965,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc)

   for (;;)
 {
-  while (c = *pc->input, isspace (c))
+  while (c = *pc->input, c_isspace (c))
pc->input++;

   if (ISDIGIT (c) || c == '-' || c == '+')
@@ -976,7 +976,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc)
  if (c == '-' || c == '+')
{
  sign = c == '-' ? -1 : 1;
- while (c = *++pc->input, isspace (c))
+ while (c = *++pc->input, c_isspace (c))
continue;
  if (! ISDIGIT (c))
/* skip the '-' sign */
@@ -1080,7 +1080,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc)
}
}

-  if (isalpha (c))
+  if (c_isalpha (c))
{
  char buff[20];
  char *p = buff;
@@ -1092,7 +1092,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc)
*p++ = c;
  c = *++pc->input;
}
- while (isalpha (c) || c == '.');
+ while (c_isalpha (c) || c == '.');

  *p = '\0';
  tp = lookup_word (pc, buff);
@@ -1205,7 +1205,7 @@ get_date (struct timespec *result, char const *p, struct 
timespec const *now)
   if (! tmp)
 return false;

-  while (c = *p, isspace (c))
+  while (c = *p, c_isspace (c))
 p++;

   if (strncmp (p, "TZ=\"", 4) == 0)
--
1.6.0.rc1.36.g5ff70


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


Re: [PATCH] Fix build-aux/check.mk for non-GNU make.

2008-08-02 Thread Jim Meyering
Ralf Wildenhues <[EMAIL PROTECTED]> wrote:
> * build-aux/check.mk ($(TEST_LOGS)) [!GNU_MAKE]: Check for
> a $(TESTS) test in the build dir, before one in srcdir.
> ---
>
> Hmpf.  First, this updated patch fixes the alignment of backslash
> newline.
>
> Second, I should note that this whole shenanigan only works well because
> automake inserts an '$(MAKE) ... $(check_PROGRAMS)' earlier, so that it
> is clear that the TESTS entry exists if it has been built, iff it has
> been listed in check_PROGRAMS.
>
> I believe this to be no problem for well-written Makefile.am files.

Thanks for the stress-testing, and especially for taking the time to
track down and fix such problems.

I've applied your patch.


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


[PATCH] Fix build-aux/check.mk for non-GNU make.

2008-08-02 Thread Ralf Wildenhues
* build-aux/check.mk ($(TEST_LOGS)) [!GNU_MAKE]: Check for
a $(TESTS) test in the build dir, before one in srcdir.
---

Hmpf.  First, this updated patch fixes the alignment of backslash
newline.

Second, I should note that this whole shenanigan only works well because
automake inserts an '$(MAKE) ... $(check_PROGRAMS)' earlier, so that it
is clear that the TESTS entry exists if it has been built, iff it has
been listed in check_PROGRAMS.

I believe this to be no problem for well-written Makefile.am files.

Cheers,
Ralf


 build-aux/check.mk |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/build-aux/check.mk b/build-aux/check.mk
index f26696d..4ed55a0 100644
--- a/build-aux/check.mk
+++ b/build-aux/check.mk
@@ -159,8 +159,9 @@ CHECK-FORCE:
 DEPENDENCY = CHECK-FORCE
 $(TEST_LOGS): $(DEPENDENCY)
@if test '$(DEPENDENCY)' = CHECK-FORCE; then\
- dst=$@;   \
- exec $(MAKE) $(AM_MAKEFLAGS) DEPENDENCY='$(srcdir)'/$${dst%.log} $@;\
+ dst=$@; src=$${dst%.log}; \
+ test -x "$$src" || src='$(srcdir)'/$$src; \
+ exec $(MAKE) $(AM_MAKEFLAGS) DEPENDENCY="$$src" $@;   \
else\
  src='$(DEPENDENCY)';  \
  $(am__check_pre) "$$dir$$src" $(am__check_post);  \
-- 
1.5.5.40.g4cdda



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


[PATCH] Fix build-aux/check.mk for non-GNU make.

2008-08-02 Thread Ralf Wildenhues
* build-aux/check.mk ($(TEST_LOGS)) [!GNU_MAKE]: Check for
a $(TESTS) test in the build dir, before one in srcdir.
---

In gnulib-tests, 'make check' causes non-GNU make to try to update and
execute $srcdir/test-EOVERFLOW:

$ pmake check
[...]
pmake  check-TESTS
gcc -std=gnu99 -g -O2  -Wl,--as-needed -o 
../../coreutils/gnulib-tests/test-EOVERFLOW 
../../coreutils/gnulib-tests/test-EOVERFLOW.c
../../coreutils/gnulib-tests/test-EOVERFLOW.c:17:20: error: config.h: No such 
file or directory
*** Error code 1

This patch fixes it.

Cheers,
Ralf

 build-aux/check.mk |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/build-aux/check.mk b/build-aux/check.mk
index f26696d..976f741 100644
--- a/build-aux/check.mk
+++ b/build-aux/check.mk
@@ -159,8 +159,9 @@ CHECK-FORCE:
 DEPENDENCY = CHECK-FORCE
 $(TEST_LOGS): $(DEPENDENCY)
@if test '$(DEPENDENCY)' = CHECK-FORCE; then\
- dst=$@;   \
- exec $(MAKE) $(AM_MAKEFLAGS) DEPENDENCY='$(srcdir)'/$${dst%.log} $@;\
+ dst=$@; src=$${dst%.log}; \
+ test -x "$$src" || src='$(srcdir)'/$$src; \
+ exec $(MAKE) $(AM_MAKEFLAGS) DEPENDENCY="$$src" $@;\
else\
  src='$(DEPENDENCY)';  \
  $(am__check_pre) "$$dir$$src" $(am__check_post);  \
-- 
1.5.5.40.g4cdda


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


Re: [PATCH] Again, do not change the mode of all directories below $HOME.

2008-08-02 Thread Jim Meyering
Ralf Wildenhues <[EMAIL PROTECTED]> wrote:
...
>> > Would the following not have sufficed, too?
>> >
>> >> -trap 'st=$?; cleanup_; d='"$t_"';
>> >> -cd '"$test_dir_"' && chmod -R u+rwx "$d" && rm -rf "$d" && exit $st' >> >> 0
>> >   +trap 'st=$?; cleanup_; d="$t_";
>> >   +cd "$test_dir_" && chmod -R u+rwx "$d" && rm -rf "$d" && exit $st' 0
>>
>> I don't see how that would change anything.  The cd is just to
>> get out of the directory we're about to remove.  It worked.
>> The chmod is what failed, operating on the prefix up to,
>> but not including the space.
>
> Hmm.  I think I fail to see what exactly the shell-under-quoting was
> then.  Could you be bothered to explain?  Thanks.

>From memory, ...
when building with a space-polluted build and/or source directory name,
there was at least one failure (or mere diagnostic leading to a directory
not being removed?) that I tracked down to the failure of that chmod
command.  The chmod diagnostic mentioned the prefix before the space.

>> > BTW, I see that you use 'local' in shell functions.  This isn't required
>> > to be supported by POSIX sh, and AFAIK won't work with some ksh variants,
>> > for example the "Version M 1993-12-28 r" on my GNU/Linux system, but
>> > also your test-lib.sh doesn't check for this capability.  I suggest to
>> > just avoid local variables, since you have only a couple anyway.  Should
>> > I write a patch to this end?
>>
>> I'd be more amenable to a patch that makes a macro like
>> posix-shell.m4 choose a shell with the features I use.
>> Since no one has reported trouble yet, perhaps it's not a problem
>> in practice.
>
> Hmm.  Maybe you're right.  That would be very cool to have 'local'
> available.
>
>> > FWIW, your second patch looks like it won't quite do what you intended
>> > if TMPDIR contains white space:
>> >
>> >   tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-")
>> >   t_prefix = $(tp)/a
>> >   ... using $(t_prefix) unquoted in a number of places ...
>>
>> Yes.  That was deliberate.
>> With those rules, I have never bothered to accommodate white space in TMPDIR.
>> I expect that anyone clueful enough to run those optional rules also
>> knows not to choose a TMPDIR value that is likely to cause trouble.
>
> That is fine with me.  I just thought I'd mention it.

Hmm... don't want to give the wrong impression.
I don't want to obfuscate the code to accommodate a pathological TMPDIR
value.  However, it'd be far better to make things fail with a sensible
diagnostic when TMPDIR has an invalid value, than to continue on
and misbehave.

too little time...


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


Re: [PATCH] Again, do not change the mode of all directories below $HOME.

2008-08-02 Thread Ralf Wildenhues
Hi Jim, and sorry for the delay,

* Jim Meyering wrote on Tue, Jul 22, 2008 at 09:42:30PM CEST:
> Ralf Wildenhues <[EMAIL PROTECTED]> wrote:
> >
> >> But seriously, considering the potential for damage and mischief,
> >> perhaps it's time to add infrastructure that stops e.g., configure
> >> in its tracks whenever it detects a potentially troublesome source or
> >> build dir.
> >
> > I disagree.  You can do that and admit defeat.  I worked to mostly[1]
> > fix Automake for this, because users kept complaining, and now refuse
> > to admit defeat.

> I wouldn't call it admitting defeat.
> It's more like admitting that not everyone will go to
> the required lengths to make their code robust enough
> to deal with such situations.

Granted.  But please don't disallow white space in the build dir for a
normal "./configure && make all install".  That would hurt some users.

> >> I applied your patch, then added a test to ensure there is no further
> >> regression, in spite of the added cost to "make distcheck".  Finally,
> >> I fixed a similar (and long-standing!) shell-under-quoting bug in
> >> test-lib.sh that was exposed by the cleanup (trap-run) code not removing
> >> a per-test directory for the tests that create unsearchable directories.
> >> With a bad build directory containing an "a b" component, instead of
> >> running e.g., chmod -R 700 "/.../a b/...", the pre-patch trap/cleanup
> >> code would run chmod -R 700 "/.../a".
> >
> > Would the following not have sufficed, too?
> >
> >> -trap 'st=$?; cleanup_; d='"$t_"';
> >> -cd '"$test_dir_"' && chmod -R u+rwx "$d" && rm -rf "$d" && exit $st' 0
> >   +trap 'st=$?; cleanup_; d="$t_";
> >   +cd "$test_dir_" && chmod -R u+rwx "$d" && rm -rf "$d" && exit $st' 0
> 
> I don't see how that would change anything.  The cd is just to
> get out of the directory we're about to remove.  It worked.
> The chmod is what failed, operating on the prefix up to,
> but not including the space.

Hmm.  I think I fail to see what exactly the shell-under-quoting was
then.  Could you be bothered to explain?  Thanks.

> > BTW, I see that you use 'local' in shell functions.  This isn't required
> > to be supported by POSIX sh, and AFAIK won't work with some ksh variants,
> > for example the "Version M 1993-12-28 r" on my GNU/Linux system, but
> > also your test-lib.sh doesn't check for this capability.  I suggest to
> > just avoid local variables, since you have only a couple anyway.  Should
> > I write a patch to this end?
> 
> I'd be more amenable to a patch that makes a macro like
> posix-shell.m4 choose a shell with the features I use.
> Since no one has reported trouble yet, perhaps it's not a problem
> in practice.

Hmm.  Maybe you're right.  That would be very cool to have 'local'
available.

> > FWIW, your second patch looks like it won't quite do what you intended
> > if TMPDIR contains white space:
> >
> >   tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-")
> >   t_prefix = $(tp)/a
> >   ... using $(t_prefix) unquoted in a number of places ...
> 
> Yes.  That was deliberate.
> With those rules, I have never bothered to accommodate white space in TMPDIR.
> I expect that anyone clueful enough to run those optional rules also
> knows not to choose a TMPDIR value that is likely to cause trouble.

That is fine with me.  I just thought I'd mention it.

Cheers,
Ralf


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


Re: compiling error

2008-08-02 Thread Ralf Wildenhues
* Jim Meyering wrote on Fri, Aug 01, 2008 at 11:11:37AM CEST:
> Ralf Wildenhues <[EMAIL PROTECTED]> wrote:
> > Jeph Cowan  ucar.edu> writes:
> >> > Making all in man
> >> > cd .. && make  am--refresh
> >> > make: 1254-002 Cannot find a rule to create target \.x from dependencies.
> >> > Stop.
> >> > make: 1254-004 The error code from the last command is 1.
> >
> > Try using GNU make instead of the native one.
> > The  $(NO_INSTALL_PROGS_DEFAULT:%=%.x)  construct in man/Makefile.am

> I wondered about that, but that use is only
> in the definition of EXTRA_DIST:
> 
>   EXTRA_DIST = $(man_aux) $(NO_INSTALL_PROGS_DEFAULT:%=%.x) help2man
> 
> which is used only via "distdir".

Yeah, and GNU make failed as well for Jeph.

For me, both makes work, at least in this directory,
so I cannot reproduce the issue here.  It could help
if Jeph showed the generated man/Makefile, or inspected
it himself for weird stuff.  Please gzip large files
you send, thanks.

> Patches are always welcome ;-)

Yeah, sending them for the other stuff I found.

Cheers,
Ralf


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


Re: [PATCH] * bootstrap: Fix unportable expr usage.

2008-08-02 Thread Jim Meyering
Ralf Wildenhues <[EMAIL PROTECTED]> wrote:
> Hi Jim,
>
> This fixes a bootstrap failure on FreeBSD due to:
>
> $ expr --gnulib-srcdir=foo : '--gnulib-srcdir=\(.*\)'
> expr: illegal option -- -
> usage: expr [-e] expression

Thank you!
Applied.


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


[PATCH] * bootstrap: Fix unportable expr usage.

2008-08-02 Thread Ralf Wildenhues
---
Hi Jim,

This fixes a bootstrap failure on FreeBSD due to:

$ expr --gnulib-srcdir=foo : '--gnulib-srcdir=\(.*\)'
expr: illegal option -- -
usage: expr [-e] expression

Cheers,
Ralf

 bootstrap |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bootstrap b/bootstrap
index 6226973..faa9bab 100755
--- a/bootstrap
+++ b/bootstrap
@@ -165,7 +165,7 @@ do
 usage
 exit;;
   --gnulib-srcdir=*)
-GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
+GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
   --skip-po)
 SKIP_PO=t;;
   --force)
-- 
1.5.5.40.g4cdda



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


Re: Problems with coreutils-6.12.70-4f470

2008-08-02 Thread Jim Meyering
Peter Fales <[EMAIL PROTECTED]> wrote:
> I decided to have a look at the latest coreutils-6.12.70-4f470, and I'm
> seeing a new problem on Solaris 8.  (Both sparc and x86)
>
> It seems that on Solaris, you can't simply copy the ACLs using GETACL/SETACL
> if the source file is in /tmp.  This causes qcopy_acl() to fail with an
> error, and can be demonstrated with the following program.  Copying the
> ACLs from /foo works, but copying from /tmp/foo fails with EINVAL:

Thanks for investigating/reporting that.
Unfortunately, copy-acl.c has several candidate acl/facl calls,
and I don't have access to a Solaris 8 system on which to debug it.
Do you know which one is affected in your case?
There are already some attempts to handle EINVAL.

> ##
> #include 
> #include 
>
> main(int argc, char *argv[])
> {
> int count, fd, i, res;
> aclent_t *entries;
>
>
>   char *file[] = { "foo", "/tmp/foo" };
>
>   open("bar",O_WRONLY|O_CREAT,0644);
>
>   for ( i = 0 ; i < 2 ; i++ ) {
>
>   open(file[i],O_WRONLY|O_CREAT,0644);
>
>   count =  acl (file[i], GETACLCNT, 0, NULL);
>
>   entries = (aclent_t *) malloc (count * sizeof (aclent_t));
>
>   res = acl (file[i], GETACL, count, entries);
>
>   res = acl ("bar", SETACL, count, entries);
>   if ( res < 0 ) {
>   perror(file[i]);
>   }
>   }
> }
> ##


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


Re: compiling error

2008-08-02 Thread Jim Meyering
Jeph Cowan <[EMAIL PROTECTED]> wrote:
> Hi Ralf.
>
> Thanks for the quick reply. I tried the GNU-make and had the same results:
>
>   ...
>> Making all in man
>> make[2]: Entering directory `/ptmp/jeph/coreutils-6.12/man'
>> make[2]: *** No rule to make target `\.x', needed by `\.1'.  Stop.
>> make[2]: Leaving directory `/ptmp/jeph/coreutils-6.12/man'
>> make[1]: *** [all-recursive] Error 1
>> make[1]: Leaving directory `/ptmp/jeph/coreutils-6.12'
>> make: *** [all] Error 2

Thanks for the feedback.
I suspect that something has generated an invalid Makefile.

Can you try the latest snapshot instead of 6.12?

  http://meyering.net/cu/coreutils-6.12.70-4f470.tar.gz
  http://meyering.net/cu/coreutils-6.12.70-4f470.tar.lzma

If that still fails, please send config.log along with
man/Makefile.


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