new snapshot available: coreutils-7.6.63-addb6

2009-10-03 Thread Jim Meyering
There have been *many* changes in gnulib since the previous snapshot,
and the changes in coreutils are non-negligible, so please give
this a try.  I'd like to make the beta release on Monday.
I'll probably call it coreutils-8.0.


coreutils snapshot:
  http://meyering.net/cu/coreutils-ss.tar.gz  9.8 MB
  http://meyering.net/cu/coreutils-ss.tar.xz  4.1 MB
  http://meyering.net/cu/coreutils-ss.tar.gz.sig
  http://meyering.net/cu/coreutils-ss.tar.xz.sig
aka
  http://meyering.net/cu/coreutils-7.6.63-addb6.tar.gz
  http://meyering.net/cu/coreutils-7.6.63-addb6.tar.xz

Changes in coreutils since 7.6.24-99f59a:

Eric Blake (7):
  build: avoid compiler warnings on cygwin 1.5
  readlink: pick up gnulib changes to readlink -f
  maint: summarize gnulib changes
  build: update gnulib submodule to latest
  build: update gnulib submodule to latest
  ln: add -L/-P options
  cp, mv: use linkat to guarantee semantics

James R. Van Zandt (1):
  dircolors: highlight .cgm and .emf as images

Jim Meyering (20):
  dircolors: arrange to highlight names with the .lz suffix
  maint: automate the web-doc updating procedure
  doc: ls: add an article, the
  build: update gnulib submodule to latest
  maint: df.c: adapt to newer gnulib
  doc: ls: further improve --help message re --color
  maint: factor coreutils-specific code out of bootstrap
  ls: with -LR, exit with status 2 upon detecting a cycle
  ls: print ?, not 0 as inode of dereferenced dangling symlink
  ls: don't use an undefined struct stat after failed stat/lstat
  stat: interpret - as standard input
  build: use gnulib's freopen module
  build: now that we use the lock module, don't exclude lock.m4
  build: translate diagnostics from two new files
  build: update gnulib submodule to latest
  tests: tail-2/pid: use a 3-second timeout, not 1
  build: update gnulib submodule to latest
  maint: move gnu-web-doc-update script to gnulib
  maint: remove obsolete syntax-check exclusion
  build: update gnulib submodule to latest

Pádraig Brady (11):
  doc: mention the texinfo documentation in --help
  doc: normalize and add missing entries to texinfo menu
  doc: ls: make help for --color more concise and accurate
  ls: handle disabling of colors consistently for all tile types
  ls: fix a performance regression
  maint: uptime: fix a theoretical compile warning
  doc: stdbuf: mention it can have a non standard exit status
  maint: expr: avoid compiler warnings without GMP
  maint: Use logical rather than bitwise operators on bools
  ls: always print ? for allocated size of a dereferenced dangling symlink
  tail: avoid a race where we could miss new data with --pid


Changes in gnulib since 7.6.24-99f59a:

* gnulib 6c9f1e8...881b91b (119):
   fchdir: avoid compiler warning
   test-open: support mingw errno values
   open: fix opening directory on mingw
   test-open: on GNU/Hurd, /dev/null is a directory
   maint: cleanup whitespace in recent commits
   rename, fchdir: don't ignore chdir failure
   maint: cleanup whitespace in recent commits
   relocatable-prog-wrapper: Add missing dependency on double-slash-root.
   renameat: fix Solaris bugs
   renameat: new module
   rename: fix mingw bugs
   rename: fix another cygwin 1.5 bug
   rename-dest-slash: merge into rename module
   rename: fix cygwin 1.5.x bugs
   rename: fix Solaris 10 bug
   rename: fix Solaris 9 bug
   rename-dest-slash: fix NetBSD bug
   rename-tests: new test, exposes several platform bugs
   Assume version info is available.
   gnu-web-doc-update: correct --help output
   gnu-web-doc-update: add standard options
   gnu-web-doc-update: New module.
   link: LoadLibrary is not needed.
   getopt: bump serial number
   tests: tighten link, rmdir, and remove tests
   maint.mk: requiring make major was annoying, for a minor release.
   Fix broken build of replacement for Windows tmpfile().
   Avoid identifier clash with POSIX function 'remove' defined as a macro.
   doc: mention yet more cygwin 1.7 status
   argp: fix test failure
   test-yesno: work around sparc-dash here-document infelicity
   Disable untested support for new flavours of ACLs on AIX.
   Typo in comment.
   Add support for new flavours of ACLs on AIX. (Untested.)
   argp: fix compilation of getopt
   doc: mention more cygwin 1.7 status
   autoupdate
   test-linkat: make test more robust
   getopt: fix inclusion guards for cygwin
   same-inode: revert prior change; it is not yet ready
   linkat: new module
   dirname: add library-safe mdir_name
   fchdir: another mingw fix
   same-inode: make SAME_INODE tri-state, to port to mingw
   lstat: avoid mingw compilation error
   autoupdate
   link: fix test failure on Solaris 9
   test-symlinkat: enhance test
   readlink: document portability issue with symlink length
   readlink: fix Solaris 9 bug with trailing slash
   readlink: fix cygwin 1.5.x 

du: slosh/slash problem in windows build

2009-10-03 Thread da Silva, Joe
Slosh/slash problem in DU 5.3.0 Windows build :

Specifying du c:\ results in lots of error messages like :

...\DU.EXE: cannot access 'c:\\/WINDOWS' : Permission denied
...\DU.EXE: cannot access 'c:\\/My Documents' : Permission denied
...\DU.EXE: cannot access 'c:\\/COMMAND.COM' : Permission denied
...\DU.EXE: (etc.)

OTOH, specifying du c:/ works just fine. Also note that both
'/' or '\' work OK for specifying other directory paths, just
not the root directory. Windows 98, version 4.10..

Regards,
Joe.

Joe da Silva
Senior Electronic Engineer
Landis+Gyr
Phone: +61 2 9690 7309
joe.dasi...@landisgyr.com
http://www.landisgyr.com/

Manage Energy Better


PLEASE CONSIDER OUR ENVIRONMENT BEFORE PRINTING THIS EMAIL.

This e-mail (including any attachments) is confidential and may be legally 
privileged. If you are not an intended recipient or an authorized 
representative of an intended recipient, you are prohibited from using, copying 
or distributing the information in this e-mail or its attachments. If you have 
received this e-mail in error, please notify the sender immediately by return 
e-mail and delete all copies of this message and any attachments. Thank you.




mv should call fsync before erasing source file

2009-10-03 Thread drwowe

I was moving some files with mv from a hard drive to a flash drive.  The
flash drive is very slow.  The mv command finished and the original files
were gone but I realized the operating system still had a gigabyte or so of
data in RAM which was in the process of being written to the flash disk.  I
ran sync to make sure everything was flushed and it took almost 60 seconds
to finish writing.  If my computer had crashed during that minute, the data
would have been gone.
Either by default, or at least with a command line flag, mv should call
fsync() on the new file being written and wait for a successful return
before erasing the original file.  Otherwise there is a significant window
of opportunity for significant data loss.  In theory, that window is
infinite according to POSIX standards, in practice my example shows that it
can be on the order of minutes which is just too long in my opinion to leave
a user's data in jeopardy.
-- 
View this message in context: 
http://www.nabble.com/mv-should-call-fsync-before-erasing-source-file-tp25725948p25725948.html
Sent from the Gnu - Coreutils - Discuss mailing list archive at Nabble.com.





Bug: tail (GNU coreutils) 5.97

2009-10-03 Thread barnettmike
Hello! 

This particular default version of tail cannot handle the argument, 
+line-number. 
This shortcoming does not permit portability. The work-around is to do more 
math than is necessary. 

Examples: 
Old version of tail. 

[mbarn...@corp bin]$ tail --version 
tail (coreutils) 5.2.1 
Written by Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering. 

Copyright (C) 2004 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
[mbarn...@corp bin]$ 

[mbarn...@corp bin]$ wc -l updateSSPage.sh 
64 updateSSPage.sh 
[mbarn...@corp bin]$ 

[mbarn...@corp bin]$ tail +60 updateSSPage.sh 
echo Did not find $TRGF 
/bin/mail -s Error running file `uname -n`:$TWD/$0. n...@someco.com 
exit 
fi 

[mbarn...@corp bin]$ 

NEW version of tail. 

[mbarn...@site bin]$ tail --version 
tail (GNU coreutils) 5.97 
Copyright (C) 2006 Free Software Foundation, Inc. 
This is free software. You may redistribute copies of it under the terms of 
the GNU General Public License http://www.gnu.org/licenses/gpl.html. 
There is NO WARRANTY, to the extent permitted by law. 

Written by Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering. 
[mbarn...@site bin]$ 

[mbarn...@site bin]$ wc -l updateSSPage.sh 
64 updateSSPage.sh 
[mbarn...@site bin]$ 

[mbarn...@site bin]$ tail +60 updateSSPage.sh 
tail: cannot open `+60' for reading: No such file or directory 
== updateSSPage.sh == 

# Clean up the old index.html_* files. 
find $TWD -name 'index.html_*' -mtime +14 -exec rm -f {} \; 

else 
echo Did not find $TRGF 
/bin/mail -s Error running file `uname -n`:$TWD/$0. n...@liveops.com 
exit 
fi 

[mbarn...@site bin]$ 

Keeping you posted. 
Mike Barnett 



Re: Bug: tail (GNU coreutils) 5.97

2009-10-03 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to barnettm...@comcast.net on 10/3/2009 2:59 AM:
 Hello! 
 
 This particular default version of tail cannot handle the argument, 
 +line-number. 

Not a bug.  This behavior is required by newer versions of POSIX.

Use 'tail -n +line-number' instead.  The NEWS file mentions:

   A few usages still have behavior that depends on which POSIX standard is
   being conformed to, and portable applications should beware these
   problematic usages.  These include:
 
 Problematic   Standard-conforming replacement, depending on
usagewhether you prefer the behavior of:
   POSIX 1003.2-1992POSIX 1003.1-2001
 sort +4   sort -k 5sort ./+4
 tail +4   tail -n +4   tail ./+4
 tail - f  tail f   [see (*) below]
 tail -c 4 tail -c 10 ./4   tail -c4
 touch 12312359 f  touch -t 12312359 f  touch ./12312359 f
 uniq +4   uniq -s 4uniq ./+4

See also the manual, 'info coreutils standards', for a means of using
_POSIX2_VERSION to request the older behavior.

 [mbarn...@site bin]$ tail --version 
 tail (GNU coreutils) 5.97 

Consider upgrading.  That version is YEARS old, with numerous bug fixes in
the meantime.  The latest stable version is 7.6.

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrHaOQACgkQ84KuGfSFAYAtNgCghd4B+qhV2pdF3PguXJYNua7f
+p8Anj3N62h/tQVASjAGeuZ82Ou4SEVn
=H+fg
-END PGP SIGNATURE-




Re: du: slosh/slash problem in windows build

2009-10-03 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to da Silva, Joe on 10/1/2009 10:18 PM:
 Slosh/slash problem in DU 5.3.0 Windows build :

5.3.0 is quite old; the latest stable version is 6.7, and may have
portability fixes that have improved the behavior of du on Windows.
However, we don't maintain Windows ports here; you are better off taking
your complaints to the person who built your version of du.  You may also
want to consider using cygwin, which has a more up-to-date port of the
coreutils.

 This e-mail (including any attachments) is confidential

Please consider using a different email account.  Your company's
disclaimer is unenforceable on a publicly-archived mailing list, and it is
considered poor netiquette to include such trailers.  Some people refuse
to reply to this type of email on principle.

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrHabkACgkQ84KuGfSFAYBf1QCfd7D1KKko+tyTDAjjAnyhOh5U
c0UAn2pHkkrGcXYw6UOdzQtqc51w3akI
=PxfX
-END PGP SIGNATURE-




Re: [FEATURE_REQUEST] support openssl checksum format too

2009-10-03 Thread Jim Meyering
 Since the patch is really small I would like to ask you for a review
 without urging me to go through all the git stuff;

It's really not that hard.
Have you looked at the instructions here?

  http://git.sv.gnu.org/cgit/coreutils.git/plain/HACKING

 if you accept the
 simple patch then I will follow up with the docs / NEWS update.

And a test, please.

Guenter Knauf wrote:
 -  size_t i;
 +  size_t i = 0;
bool escaped_filename = false;
size_t algo_name_len;

 -  i = 0;
while (ISWHITE (s[i]))
  ++i;

Instead, please move the declaration down.

 @@ -263,11 +262,14 @@
algo_name_len = strlen (DIGEST_TYPE_STRING);
if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
  {
 -  if (strncmp (s + i + algo_name_len,  (, 2) == 0)
 +  size_t j = i + algo_name_len;
 +  while (ISWHITE (s[j]))
 +++j;

That allows two or more white-space bytes.
Let's restrict it to just 0 or 1 space (not white-space) byte.

 +  if (strncmp (s + j, (, 1) == 0)

This would be better as:

 if (s[j] == '(')

  {
*binary = 0;
 -  return bsd_split_3 (s +  i + algo_name_len + 2,
 -  s_len - (i + algo_name_len + 2),
 +  return bsd_split_3 (s + j + 1, s_len - (j + 1),
hex_digest, file_name);
  }
  }
 --- src/md5sum.c.orig 2009-09-01 13:01:16.0 +0200
 +++ src/md5sum.c  2009-10-03 19:13:27.0 +0200
 @@ -251,11 +251,10 @@
  split_3 (char *s, size_t s_len,
   unsigned char **hex_digest, int *binary, char **file_name)
  {
 -  size_t i;
 +  size_t i = 0;
bool escaped_filename = false;
size_t algo_name_len;

 -  i = 0;

Same here.

while (ISWHITE (s[i]))
  ++i;

 @@ -263,11 +262,14 @@
algo_name_len = strlen (DIGEST_TYPE_STRING);
if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
  {
 -  if (strncmp (s + i + algo_name_len,  (, 2) == 0)
 +  size_t j = i + algo_name_len;
 +  while (ISWHITE (s[j]))
 +++j;

And here.

 +  if (strncmp (s + j, (, 1) == 0)

And here.

  {
*binary = 0;
 -  return bsd_split_3 (s +  i + algo_name_len + 2,
 -  s_len - (i + algo_name_len + 2),
 +  return bsd_split_3 (s + j + 1, s_len - (j + 1),
hex_digest, file_name);
  }
  }




Re: [FEATURE_REQUEST] support openssl checksum format too

2009-10-03 Thread Guenter Knauf
Hi Jim,
Jim Meyering schrieb:
 Would you like to write the patch (including NEWS and
 a small doc update), following these guidelines?
 
   http://git.sv.gnu.org/cgit/coreutils.git/plain/HACKING
I've just tested a bit, and it seems that its enough to hack around the
first place where the blank can appear (bsd tools) or not (openssl).
Since the patch is really small I would like to ask you for a review
without urging me to go through all the git stuff; if you accept the
simple patch then I will follow up with the docs / NEWS update.
I've tested this patch successfully with both bsd and openssl format.
The first hunk is not needed, but I thought while on it we can save
there a line 

thanks, Günter.

--- src/md5sum.c.orig   2009-09-01 13:01:16.0 +0200
+++ src/md5sum.c2009-10-03 19:13:27.0 +0200
@@ -251,11 +251,10 @@
 split_3 (char *s, size_t s_len,
  unsigned char **hex_digest, int *binary, char **file_name)
 {
-  size_t i;
+  size_t i = 0;
   bool escaped_filename = false;
   size_t algo_name_len;

-  i = 0;
   while (ISWHITE (s[i]))
 ++i;

@@ -263,11 +262,14 @@
   algo_name_len = strlen (DIGEST_TYPE_STRING);
   if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
 {
-  if (strncmp (s + i + algo_name_len,  (, 2) == 0)
+  size_t j = i + algo_name_len;
+  while (ISWHITE (s[j]))
+++j;
+
+  if (strncmp (s + j, (, 1) == 0)
 {
   *binary = 0;
-  return bsd_split_3 (s +  i + algo_name_len + 2,
-  s_len - (i + algo_name_len + 2),
+  return bsd_split_3 (s + j + 1, s_len - (j + 1),
   hex_digest, file_name);
 }
 }
--- src/md5sum.c.orig	2009-09-01 13:01:16.0 +0200
+++ src/md5sum.c	2009-10-03 19:13:27.0 +0200
@@ -251,11 +251,10 @@
 split_3 (char *s, size_t s_len,
  unsigned char **hex_digest, int *binary, char **file_name)
 {
-  size_t i;
+  size_t i = 0;
   bool escaped_filename = false;
   size_t algo_name_len;
 
-  i = 0;
   while (ISWHITE (s[i]))
 ++i;
 
@@ -263,11 +262,14 @@
   algo_name_len = strlen (DIGEST_TYPE_STRING);
   if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
 {
-  if (strncmp (s + i + algo_name_len,  (, 2) == 0)
+  size_t j = i + algo_name_len;
+  while (ISWHITE (s[j]))
+++j;
+
+  if (strncmp (s + j, (, 1) == 0)
 {
   *binary = 0;
-  return bsd_split_3 (s +  i + algo_name_len + 2,
-  s_len - (i + algo_name_len + 2),
+  return bsd_split_3 (s + j + 1, s_len - (j + 1),
   hex_digest, file_name);
 }
 }


Re: [FEATURE_REQUEST] support openssl checksum format too

2009-10-03 Thread Guenter Knauf
Jim,
thanks for the very quick review.

Jim Meyering schrieb:
 Guenter Knauf wrote:
 -  size_t i;
 +  size_t i = 0;
bool escaped_filename = false;
size_t algo_name_len;

 -  i = 0;
while (ISWHITE (s[i]))
  ++i;
 
 Instead, please move the declaration down.
hmm, not sure what you mean here - moving it down is bad since var
declarations in the middle of the code are not allowed, although
accepted by gcc. In this case its no problem, but if a while later
someone adds code before the declaration then it clashes with non-gcc
compilers. What's bad with initializing a var with the declaration?
That's valid for all compilers AFAIK. Anyway, since its not needed I
left this part out from my new patch - was just only a suggestion to
save a line.

 That allows two or more white-space bytes.
 Let's restrict it to just 0 or 1 space (not white-space) byte.
ok.

 +  if (strncmp (s + j, (, 1) == 0)
 
 This would be better as:
 
  if (s[j] == '(')
ok.

here's 2nd trial inline (and also attached) which looks even more simple
thanks to your comments:

--- src/md5sum.c.orig   2009-09-01 13:01:16.0 +0200
+++ src/md5sum.c2009-10-03 20:32:28.0 +0200
@@ -263,11 +263,13 @@
   algo_name_len = strlen (DIGEST_TYPE_STRING);
   if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
 {
-  if (strncmp (s + i + algo_name_len,  (, 2) == 0)
+  if (s[i + algo_name_len] == ' ')
+++i;
+  if (s[i + algo_name_len] == '(')
 {
   *binary = 0;
-  return bsd_split_3 (s +  i + algo_name_len + 2,
-  s_len - (i + algo_name_len + 2),
+  return bsd_split_3 (s +  i + algo_name_len + 1,
+  s_len - (i + algo_name_len + 1),
   hex_digest, file_name);
 }
 }

 And a test, please.
I guess you mean something like that (also attached)?

--- tests/misc/md5sum.orig  2009-09-01 13:01:16.0 +0200
+++ tests/misc/md5sum   2009-10-03 20:46:44.0 +0200
@@ -67,6 +67,16 @@
  ['check-bsd3', '--check', '--status',
 {IN= {'f.md5' = MD5 (f) =
$degenerate\n}},
 {AUX= {f= 'bar'}}, {EXIT= 1}],
+ ['check-openssl', '--check', {IN= {'f.sha1' = SHA1(f)=
$degenerate\n}},
+{AUX= {f= ''}},
+{ERR=md5sum: f.sha1: no properly
formatted 
+   . MD5 checksum lines found\n},
+{EXIT= 1}],
+ ['check-openssl2', '--check', {IN= {'f.md5' = MD5(f)=
$degenerate\n}},
+{AUX= {f= ''}}, {OUT=f: OK\n}],
+ ['check-openssl3', '--check', '--status',
+{IN= {'f.md5' = MD5(f)=
$degenerate\n}},
+{AUX= {f= 'bar'}}, {EXIT= 1}],
  ['bsd-segv', '--check', {IN= {'z' = MD5 (}}, {EXIT= 1},
   {ERR= $prog: z: no properly formatted MD5 checksum lines
found\n}],

does this work for you? Sorry, but I've not yet figured out how I could
run these tests - a 'make tests' didnt work (therefore wrote above
blindly assumed)- can you please give me a quick hint before I read me
dead? Thanks. Once I know I create patches for the sha*sum tests too.
Also, is it possible to run single tests?

thanks, Günter.


--- src/md5sum.c.orig	2009-09-01 13:01:16.0 +0200
+++ src/md5sum.c	2009-10-03 20:32:28.0 +0200
@@ -263,11 +263,13 @@
   algo_name_len = strlen (DIGEST_TYPE_STRING);
   if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
 {
-  if (strncmp (s + i + algo_name_len,  (, 2) == 0)
+  if (s[i + algo_name_len] == ' ')
+++i;
+  if (s[i + algo_name_len] == '(')
 {
   *binary = 0;
-  return bsd_split_3 (s +  i + algo_name_len + 2,
-  s_len - (i + algo_name_len + 2),
+  return bsd_split_3 (s +  i + algo_name_len + 1,
+  s_len - (i + algo_name_len + 1),
   hex_digest, file_name);
 }
 }
--- tests/misc/md5sum.orig	2009-09-01 13:01:16.0 +0200
+++ tests/misc/md5sum	2009-10-03 20:46:44.0 +0200
@@ -67,6 +67,16 @@
  ['check-bsd3', '--check', '--status',
 {IN= {'f.md5' = MD5 (f) = $degenerate\n}},
 {AUX= {f= 'bar'}}, {EXIT= 1}],
+ ['check-openssl', '--check', {IN= {'f.sha1' = SHA1(f)= $degenerate\n}},
+{AUX= {f= ''}},
+{ERR=md5sum: f.sha1: no properly formatted 
+   . MD5 checksum lines found\n},
+{EXIT= 1}],
+ ['check-openssl2', '--check', {IN= {'f.md5' = MD5(f)= $degenerate\n}},
+{AUX= {f= ''}}, {OUT=f: OK\n}],
+ ['check-openssl3', '--check', '--status',
+

Re: [FEATURE_REQUEST] support openssl checksum format too

2009-10-03 Thread Jim Meyering
Guenter Knauf wrote:

 Jim,
 thanks for the very quick review.

 Jim Meyering schrieb:
 Guenter Knauf wrote:
 -  size_t i;
 +  size_t i = 0;
bool escaped_filename = false;
size_t algo_name_len;

 -  i = 0;
while (ISWHITE (s[i]))
  ++i;

 Instead, please move the declaration down.
 hmm, not sure what you mean here - moving it down is bad since var
 declarations in the middle of the code are not allowed, although
 accepted by gcc.

stmt-after-decl is part of C99, now a 10-year-old standard.

 In this case its no problem, but if a while later
 someone adds code before the declaration then it clashes with non-gcc
 compilers. What's bad with initializing a var with the declaration?
 That's valid for all compilers AFAIK. Anyway, since its not needed I
 left this part out from my new patch - was just only a suggestion to
 save a line.

This is what I meant:
...
-  i = 0;
+  size_t i = 0;
   while (ISWHITE (s[i]))
 ++i;

There is already code in coreutils that requires C99 decl-after-stmt,
so even if someone added a statement before it, that would be fine.

 That allows two or more white-space bytes.
 Let's restrict it to just 0 or 1 space (not white-space) byte.
 ok.

 +  if (strncmp (s + j, (, 1) == 0)

 This would be better as:

  if (s[j] == '(')
 ok.

 here's 2nd trial inline (and also attached) which looks even more simple

No need to include a patch twice.

 thanks to your comments:

 --- src/md5sum.c.orig   2009-09-01 13:01:16.0 +0200
 +++ src/md5sum.c2009-10-03 20:32:28.0 +0200
 @@ -263,11 +263,13 @@
algo_name_len = strlen (DIGEST_TYPE_STRING);
if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
  {
 -  if (strncmp (s + i + algo_name_len,  (, 2) == 0)
 +  if (s[i + algo_name_len] == ' ')
 +++i;
 +  if (s[i + algo_name_len] == '(')
  {
*binary = 0;
 -  return bsd_split_3 (s +  i + algo_name_len + 2,
 -  s_len - (i + algo_name_len + 2),
 +  return bsd_split_3 (s +  i + algo_name_len + 1,
 +  s_len - (i + algo_name_len + 1),
hex_digest, file_name);
  }
  }

 And a test, please.
 I guess you mean something like that (also attached)?

...

 does this work for you?

Right idea.  I haven't tried them.

 Sorry, but I've not yet figured out how I could
 run these tests - a 'make tests' didnt work (therefore wrote above

make check runs most tests.

Use this

  make check -C tests TESTS=misc/md5sum VERBOSE=yes

to run just the one you changed.

 blindly assumed)- can you please give me a quick hint before I read me
 dead? Thanks. Once I know I create patches for the sha*sum tests too.
 Also, is it possible to run single tests?




Re: [FEATURE_REQUEST] support openssl checksum format too

2009-10-03 Thread Guenter Knauf
Hi Jim,
Jim Meyering schrieb:
 This is what I meant:
 ...
 -  i = 0;
 +  size_t i = 0;
while (ISWHITE (s[i]))
  ++i;
ok, added.

 make check runs most tests.
 
 Use this
 
   make check -C tests TESTS=misc/md5sum VERBOSE=yes
 
 to run just the one you changed.
thanks, tests passed:
PASS: misc/md5sum
=
1 test passed
=
PASS: misc/sha1sum
=
1 test passed
=

the other sha*sum tests do not test the bsd format, so I also didnt add
the openssl format. Also the doc/coerutils.info doesnt mention yet that
the BSD checksum format is supported, so was not sure about adding now
the openssl format.

Find attached the hopefully correct git patch.

thanks, Günter.


From 941f0d07618d480110dd3417ccb7e1511e8f9504 Mon Sep 17 00:00:00 2001
From: Guenter Knauf li...@gknw.net
Date: Sat, 3 Oct 2009 23:24:26 +0200
Subject: [PATCH] added support for openssl checksum format to md5sum / sha*sum 
tools.

changed src/md5sum.c to also accept file checksums generated by openssl
which are very close to the format of the bsd checksum tools.
---
 NEWS   |2 ++
 src/md5sum.c   |   11 ++-
 tests/misc/md5sum  |   10 ++
 tests/misc/sha1sum |   11 +++
 4 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index aff0744..dea34e4 100644
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,8 @@ GNU coreutils NEWS-*- 
outline -*-
 
 ** New features
 
+  md5sum / sha*sum now also accept file checksums created with openssl. 
+
   ln now accepts the options --logical (-L) and --physical (-P),
   added by POSIX 2008.  The default behavior is -P on systems like
   GNU/Linux where link(2) creates hard links to symlinks, and -L on
diff --git a/src/md5sum.c b/src/md5sum.c
index e004c5e..aa2a144 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -251,11 +251,10 @@ static bool
 split_3 (char *s, size_t s_len,
  unsigned char **hex_digest, int *binary, char **file_name)
 {
-  size_t i;
   bool escaped_filename = false;
   size_t algo_name_len;
 
-  i = 0;
+  size_t i = 0;
   while (ISWHITE (s[i]))
 ++i;
 
@@ -263,11 +262,13 @@ split_3 (char *s, size_t s_len,
   algo_name_len = strlen (DIGEST_TYPE_STRING);
   if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
 {
-  if (strncmp (s + i + algo_name_len,  (, 2) == 0)
+  if (s[i + algo_name_len] == ' ')
+++i;
+  if (s[i + algo_name_len] == '(')
 {
   *binary = 0;
-  return bsd_split_3 (s +  i + algo_name_len + 2,
-  s_len - (i + algo_name_len + 2),
+  return bsd_split_3 (s +  i + algo_name_len + 1,
+  s_len - (i + algo_name_len + 1),
   hex_digest, file_name);
 }
 }
diff --git a/tests/misc/md5sum b/tests/misc/md5sum
index 2fb024d..30edd9e 100755
--- a/tests/misc/md5sum
+++ b/tests/misc/md5sum
@@ -67,6 +67,16 @@ my @Tests =
  ['check-bsd3', '--check', '--status',
 {IN= {'f.md5' = MD5 (f) = $degenerate\n}},
 {AUX= {f= 'bar'}}, {EXIT= 1}],
+ ['check-openssl', '--check', {IN= {'f.sha1' = SHA1(f)= 
$degenerate\n}},
+{AUX= {f= ''}},
+{ERR=md5sum: f.sha1: no properly formatted 
+   . MD5 checksum lines found\n},
+{EXIT= 1}],
+ ['check-openssl2', '--check', {IN= {'f.md5' = MD5(f)= $degenerate\n}},
+{AUX= {f= ''}}, {OUT=f: OK\n}],
+ ['check-openssl3', '--check', '--status',
+{IN= {'f.md5' = MD5(f)= $degenerate\n}},
+{AUX= {f= 'bar'}}, {EXIT= 1}],
  ['bsd-segv', '--check', {IN= {'z' = MD5 (}}, {EXIT= 1},
   {ERR= $prog: z: no properly formatted MD5 checksum lines found\n}],
 
diff --git a/tests/misc/sha1sum b/tests/misc/sha1sum
index 3f09aba..d084204 100755
--- a/tests/misc/sha1sum
+++ b/tests/misc/sha1sum
@@ -60,6 +60,17 @@ my @Tests =
  ['check-bsd3', '--check', '--status',
 {IN= {'f.sha1' = SHA1 (f) = $sha_degenerate\n}},
 {AUX= {f= 'bar'}}, {EXIT= 1}],
+ ['check-openssl', '--check', {IN= {'f.md5' = MD5(f)= 
$sha_degenerate\n}},
+{AUX= {f= ''}},
+{ERR=sha1sum: f.md5: no properly formatted 
+  . SHA1 checksum lines found\n},
+{EXIT= 1}],
+ ['check-openssl2', '--check',
+{IN= {'f.sha1' = SHA1(f)= $sha_degenerate\n}},
+{AUX= {f= ''}}, {OUT=f: OK\n}],
+ ['check-openssl3', '--check', '--status',
+{IN= {'f.sha1' = SHA1(f)= $sha_degenerate\n}},
+{AUX= {f= 'bar'}}, {EXIT= 1}],
  ['bsd-segv', '--check', {IN= {'z' = SHA1 (}}, {EXIT= 1},
   {ERR= 

Re: new snapshot available: coreutils-7.6.63-addb6

2009-10-03 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Jim Meyering on 10/3/2009 2:30 AM:
 There have been *many* changes in gnulib since the previous snapshot,
 and the changes in coreutils are non-negligible, so please give
 this a try.  I'd like to make the beta release on Monday.
 I'll probably call it coreutils-8.0.

I'm still wondering if we want one more patch: now that we document that

 readlink -f link/

succeeds, with the claim that 'mkdir link/' will also succeed, we should
make sure of that.  Right now, Solaris systems work (mkdir(2) follows
POSIX), but GNU/Linux reject it (since mkdir(2) fails with EEXIST on a
slashed symlink).

What's worse, I wonder if we have a bug on Solaris:

$ rm -Rf ?
$ ln -s a b
$ mkdir -p b/c
mkdir: cannot create directory `b': File exists
$ mkdir b/
$ mkdir b/c

or if it is a bug in POSIX, since it describes mkdir -p in terms of
$(dirname dir) rather than $(dirname dir)/.  The native Solaris
/bin/mkdir also fails with mkdir -p b/c, but with ENOENT.

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrH1EsACgkQ84KuGfSFAYCmaACbBhcqzRFLpnZSo4A0z34ChWZL
TeMAn3Yz03L3srsPAEmxOkSWKWNmG7QT
=K2DB
-END PGP SIGNATURE-




Re: mv should call fsync before erasing source file

2009-10-03 Thread drwowe


Jim Meyering wrote:
 
 Maybe you want a new option to enable this behavior when
 does not do an atomic rename, but it will never be the
 efault, because it would cause a huge performance hit
 when copying many files between devices.
 
True, it's the classic reliability vs performance tradeoff, although in the
case of a batch move, the algorithm could be changed to copy many, sync
many, remove many in that order.

Anyway, a command line option would be better than nothing.  Just the
existence of the option and a short blurb in mv --help could potentially
make someone reading the help text aware who might otherwise not be.  Of
course there are workarounds (such as using find/dd/rm in a script as you
suggest, in fact I might just write such a script and alias it to mv) but
I'm especially concerned for a newbie who might not even know there was a
potential for a problem.
 
-- 
View this message in context: 
http://www.nabble.com/mv-should-call-fsync-before-erasing-source-file-tp25725948p25733498.html
Sent from the Gnu - Coreutils - Discuss mailing list archive at Nabble.com.





tail bug?

2009-10-03 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

$ echo abc | tail -c +1
tail: cannot open `+1' for reading: No such file or directory
$ echo abc | tail -c+1
abc
$ tail --version | head -n1
tail (GNU coreutils) 7.6

Shouldn't -c behave the same, whether or not there is a space before the
count argument?

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrH4TEACgkQ84KuGfSFAYB9mgCgwGzq5DOR4eZXFdsLS0VxG0Uf
ts4AniOXOzE/HN/1iKsXY0d7voG03v/T
=b4s7
-END PGP SIGNATURE-