Re: [Bug-wget] Download files and preserve their data and time

2011-08-25 Thread Giuseppe Scrivano
Ray Satiro raysat...@yahoo.com writes:

 Calling utime() works. You could also use SetFileTime(). 2489 changed utime 
 to utimes but the CRT doesn't have utimes. 

thanks to have checked it.

I am going to apply the patch below.

Cheers,
Giuseppe



=== modified file 'configure.ac'
--- configure.ac2011-08-11 10:20:25 +
+++ configure.ac2011-08-25 09:01:31 +
@@ -197,7 +197,7 @@
 AC_FUNC_FSEEKO
 AC_CHECK_FUNCS(strptime timegm vsnprintf vasprintf drand48)
 AC_CHECK_FUNCS(strtoll usleep ftello sigblock sigsetjmp memrchr wcwidth mbtowc)
-AC_CHECK_FUNCS(sleep symlink)
+AC_CHECK_FUNCS(sleep symlink utime)
 
 if test x$ENABLE_OPIE = xyes; then
   AC_LIBOBJ([ftp-opie])

=== modified file 'src/utils.c'
--- src/utils.c 2011-08-11 12:23:39 +
+++ src/utils.c 2011-08-25 09:22:03 +
@@ -42,15 +42,23 @@
 #ifdef HAVE_PROCESS_H
 # include process.h  /* getpid() */
 #endif
-#ifdef HAVE_UTIME_H
-# include utime.h
-#endif
 #include errno.h
 #include fcntl.h
 #include assert.h
 #include stdarg.h
 #include locale.h
 
+#if HAVE_UTIME
+# include sys/types.h
+# ifdef HAVE_UTIME_H
+#  include utime.h
+# endif
+
+# ifdef HAVE_SYS_UTIME_H
+#  include sys/utime.h
+# endif
+#endif
+
 #include sys/stat.h
 
 /* For TIOCGWINSZ and friends: */
@@ -487,6 +495,20 @@
 void
 touch (const char *file, time_t tm)
 {
+#if HAVE_UTIME
+# ifdef HAVE_STRUCT_UTIMBUF
+  struct utimbuf times;
+# else
+  struct {
+time_t actime;
+time_t modtime;
+  } times;
+# endif
+  times.modtime = tm;
+  times.actime = time (NULL);
+  if (utime (file, times) == -1)
+logprintf (LOG_NOTQUIET, utime(%s): %s\n, file, strerror (errno));
+#else
   struct timespec timespecs[2];
   int fd;
 
@@ -506,6 +528,7 @@
 logprintf (LOG_NOTQUIET, futimens(%s): %s\n, file, strerror (errno));
 
   close (fd);
+#endif
 }
 
 /* Checks if FILE is a symbolic link, and removes it if it is.  Does




[Bug-wget] Wget 1.12 (macports) has NULLs and stuff appended after --convert-links

2011-08-25 Thread Denis Laplante
Summary: Wget 1.12 (macports) has NULLs and stuff appended after html  
mirror file.


  command: wget -r --convert-links --adjust-extension ...

### RESULT #
- Result: content has many links translated, but junk appended
- Sample: systems.1.html
			- mostly good content with left-sidebar links untranslated, but  
main links translated

- followed by 1307 * NUL
			- followed by 60 lines = 4291 characters from same file (links  
translated) starting at point=31517 of 41150 in middle of left-sidebar  
(links translated).

- All files affected !

I have looked at 
http://savannah.gnu.org/search/?words=convert-linkstype_of_search=bugsSearch=Searchexact=1#options

## COMMAND ##
WG_BASIC=-r --convert-links --adjust-extension --page-requisites --no- 
verbose

WG_HOBBLE=--level=2 --limit-rate=100k --quota=10m --wait-seconds=1
WG_EXCLUDE=--no-parent -- 
reject=*:*,index.php*,Special:*,User:*,Talk:* --exclude- 
directories=/.../Special:*

PD_SESS_COOKIE=qwertyuiop
WG_STARTURL=https://wiki...;

/opt/local/bin/wget ${WG_BASIC} ${WG_RESTRICT} ${WG_EXCLUDE} \
--header Cookie: wikidb_UserName=...; wikidb__session=$ 
{PD_SESS_COOKIE} \

${WG_STARTURL}


 VERSION #
$ wget -V
GNU Wget 1.12 built on darwin9.8.0.

+digest +ipv6 +nls +ntlm +opie +md5/openssl +https -gnutls +openssl
+iri

Wgetrc:
/Users/laplante/.wgetrc (user)
/opt/local/etc/wgetrc (system)
Locale: /opt/local/share/locale
Compile: /usr/bin/gcc-4.0 -DHAVE_CONFIG_H
-DSYSTEM_WGETRC=/opt/local/etc/wgetrc
-DLOCALEDIR=/opt/local/share/locale -I. -I../lib
-I/opt/local/include -O2 -arch i386
Link: /usr/bin/gcc-4.0 -O2 -arch i386 -L/opt/local/lib -liconv -lintl - 
arch

i386 -lssl -lcrypto -lintl -liconv -lc -Wl,-framework
-Wl,CoreFoundation -ldl -lidn ftp-opie.o openssl.o http-ntlm.o
gen-md5.o ../lib/libgnu.a

Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
http://www.gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic hnik...@xemacs.org.
Currently maintained by Micah Cowan mi...@cowan.name.
Please send bug reports and questions to bug-wget@gnu.org.