~ubuntu-branches/ubuntu/precise/wget/precise-proposed

« back to all changes in this revision

Viewing changes to debian/patches/wget-E_html_behind_file_counting

  • Committer: Bazaar Package Importer
  • Author(s): Noèl Köthe
  • Date: 2005-06-26 16:46:25 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050626164625-jjcde8hyztx7xq7o
Tags: 1.10-2
* wget-fix_error--save-headers patch from upstream
  (closes: Bug#314728)
* don't pattern-match server redirects patch from upstream
  (closes: Bug#163243)
* correct de.po typos
  (closes: Bug#313883)
* wget-E_html_behind_file_counting fix problem with adding the
  numbers after the html extension
* updated Standards-Version: to 3.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
## PATCHNAME by NAME <EMAIL>
 
3
##
 
4
## DP: DESCRIPTION
 
5
 
 
6
if [ $# -lt 1 ]; then
 
7
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
 
8
    exit 1
 
9
fi
 
10
 
 
11
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
 
12
patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
 
13
 
 
14
case "$1" in
 
15
       -patch) patch $patch_opts -p1 < $0;;
 
16
       -unpatch) patch $patch_opts -p1 -R < $0;;
 
17
        *)
 
18
                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
 
19
                exit 1;;
 
20
esac
 
21
 
 
22
exit 0
 
23
 
 
24
@DPATCH@
 
25
--- wget-1.10.orig/src/http.c  2005/06/15 20:26:37     1.191
 
26
+++ wget-1.10/src/http.c  2005/06/17 22:01:53
 
27
@@ -1121,6 +1121,12 @@
 
28
     request_set_header (req, "User-Agent", opt.useragent, rel_none);   \
 
29
 } while (0)
 
30
 
 
31
+/* The flags that allow clobbering the file (opening with "wb").
 
32
+   Defined here to avoid repetition later.  #### This will require
 
33
+   rework.  */
 
34
+#define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \
 
35
+                      || opt.dirstruct || opt.output_document)
 
36
+
 
37
 /* Retrieve a document through HTTP protocol.  It recognizes status
 
38
    code, and correctly handles redirections.  It closes the network
 
39
    socket.  If it receives an error from the functions below it, it
 
40
@@ -1793,18 +1799,28 @@
 
41
        text/html file.  If some case-insensitive variation on ".htm[l]" isn't
 
42
        already the file's suffix, tack on ".html". */
 
43
     {
 
44
-      char*  last_period_in_local_filename = strrchr(*hs->local_file, '.');
 
45
+      char *last_period_in_local_filename = strrchr (*hs->local_file, '.');
 
46
 
 
47
       if (last_period_in_local_filename == NULL
 
48
          || !(0 == strcasecmp (last_period_in_local_filename, ".htm")
 
49
               || 0 == strcasecmp (last_period_in_local_filename, ".html")))
 
50
        {
 
51
-         size_t  local_filename_len = strlen(*hs->local_file);
 
52
-         
 
53
-         *hs->local_file = xrealloc(*hs->local_file,
 
54
-                                    local_filename_len + sizeof(".html"));
 
55
+         int local_filename_len = strlen (*hs->local_file);
 
56
+         /* Resize the local file, allowing for ".html" preceded by
 
57
+            optional ".NUMBER".  */
 
58
+         *hs->local_file = xrealloc (*hs->local_file,
 
59
+                                     local_filename_len + 24 + sizeof (".html"));
 
60
          strcpy(*hs->local_file + local_filename_len, ".html");
 
61
-
 
62
+         /* If clobbering is not allowed and the file, as named,
 
63
+            exists, tack on ".NUMBER.html" instead. */
 
64
+         if (!ALLOW_CLOBBER)
 
65
+           {
 
66
+             int ext_num = 1;
 
67
+             do
 
68
+               sprintf (*hs->local_file + local_filename_len,
 
69
+                        ".%d.html", ext_num++);
 
70
+             while (file_exists_p (*hs->local_file));
 
71
+           }
 
72
          *dt |= ADDED_HTML_EXTENSION;
 
73
        }
 
74
     }
 
75
@@ -1897,8 +1913,7 @@
 
76
        rotate_backups (*hs->local_file);
 
77
       if (hs->restval)
 
78
        fp = fopen (*hs->local_file, "ab");
 
79
-      else if (opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct
 
80
-              || opt.output_document)
 
81
+      else if (ALLOW_CLOBBER)
 
82
        fp = fopen (*hs->local_file, "wb");
 
83
       else
 
84
        {
 
85