]> git.pld-linux.org Git - packages/elinks.git/blame - elinks-bug899.patch
- rel 3
[packages/elinks.git] / elinks-bug899.patch
CommitLineData
402c6500
AG
1diff --git a/src/osdep/types.h b/src/osdep/types.h
2index 9d0f282..2404ac0 100644
3--- a/src/osdep/types.h
4+++ b/src/osdep/types.h
5@@ -53,6 +53,28 @@
6 #endif
7 #endif
8
9+#if defined(HAVE_LONG_LONG) && !defined(LLONG_MAX)
10+#ifdef MAXLLONG
11+#define LLONG_MAX MAXLLONG
12+#elif SIZEOF_LONG_LONG == 8
13+#define LLONG_MAX 9223372036854775807LL
14+#elif SIZEOF_LONG_LONG == 4
15+#define LLONG_MAX LONG_MAX
16+#endif
17+#endif
18+
19+#ifndef OFFT_MAX
20+#if defined(HAVE_LONG_LONG) && SIZEOF_OFF_T == SIZEOF_LONG_LONG
21+#define OFFT_MAX LLONG_MAX
22+#elif SIZEOF_OFF_T == SIZEOF_LONG
23+#define OFFT_MAX LONG_MAX
24+#elif SIZEOF_OFF_T == SIZEOF_INT
25+#define OFFT_MAX INT_MAX
26+#elif SIZEOF_OFF_T == SIZEOF_SHORT
27+#define OFFT_MAX SHRT_MAX
28+#endif
29+#endif
30+
31 #ifndef HAVE_UINT16_T
32 #if SIZEOF_CHAR == 2
33 typedef unsigned char uint16_t;
34diff --git a/src/protocol/ftp/ftp.c b/src/protocol/ftp/ftp.c
35index 87ec444..01e301b 100644
36--- a/src/protocol/ftp/ftp.c
37+++ b/src/protocol/ftp/ftp.c
38@@ -1091,7 +1091,7 @@ display_dir_entry(struct cache_entry *cached, off_t *pos, int *tries,
39 add_to_string(&string, " 1 ftp ftp ");
40
41 if (ftp_info->size != FTP_SIZE_UNKNOWN) {
42- add_format_to_string(&string, "%12lu ", ftp_info->size);
43+ add_format_to_string(&string, "%12" OFF_T_FORMAT " ", ftp_info->size);
44 } else {
45 add_to_string(&string, " - ");
46 }
47diff --git a/src/protocol/ftp/parse.c b/src/protocol/ftp/parse.c
48index b5caeba..be4326e 100644
49--- a/src/protocol/ftp/parse.c
50+++ b/src/protocol/ftp/parse.c
51@@ -41,10 +41,10 @@
52 #define skip_nonspace_end(src, end) \
53 do { while ((src) < (end) && *(src) != ' ') (src)++; } while (0)
54
55-static long
56-parse_ftp_number(unsigned char **src, unsigned char *end, long from, long to)
57+static off_t
58+parse_ftp_number(unsigned char **src, unsigned char *end, off_t from, off_t to)
59 {
60- long number = 0;
61+ off_t number = 0;
62 unsigned char *pos = *src;
63
64 for (; pos < end && isdigit(*pos); pos++)
65@@ -104,7 +104,7 @@ parse_ftp_eplf_response(struct ftp_file_info *info, unsigned char *src, int len)
66
67 case FTP_EPLF_SIZE:
68 if (src >= pos) break;
69- info->size = parse_ftp_number(&src, pos, 0, LONG_MAX);
70+ info->size = parse_ftp_number(&src, pos, 0, OFFT_MAX);
71 break;
72
73 case FTP_EPLF_MTIME:
74@@ -278,7 +278,7 @@ parse_ftp_unix_response(struct ftp_file_info *info, unsigned char *src, int len)
75 break;
76 }
77
78- info->size = parse_ftp_number(&src, pos, 0, LONG_MAX);
79+ info->size = parse_ftp_number(&src, pos, 0, OFFT_MAX);
80 break;
81
82 case FTP_UNIX_DAY:
83@@ -543,7 +543,7 @@ parse_ftp_winnt_response(struct ftp_file_info *info, unsigned char *src, int len
84 memset(&mtime, 0, sizeof(mtime));
85 mtime.tm_isdst = -1;
86
87- mtime.tm_mon = parse_ftp_number(&src, end, 1, 12);
88+ mtime.tm_mon = (int) parse_ftp_number(&src, end, 1, 12);
89 if (src + 2 >= end || *src != '-')
90 return NULL;
91
92@@ -587,7 +587,7 @@ parse_ftp_winnt_response(struct ftp_file_info *info, unsigned char *src, int len
93
94 } else if (isdigit(*src)) {
95 info->type = FTP_FILE_PLAINFILE;
96- info->size = parse_ftp_number(&src, end, 0, LONG_MAX);
97+ info->size = parse_ftp_number(&src, end, 0, OFFT_MAX);
98 info->permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
99
100 } else {
101diff --git a/src/protocol/ftp/parse.h b/src/protocol/ftp/parse.h
102index e777398..18cfacd 100644
103--- a/src/protocol/ftp/parse.h
104+++ b/src/protocol/ftp/parse.h
105@@ -19,7 +19,7 @@ struct ftp_file_info {
106 enum ftp_file_type type; /* File type */
107 struct string name; /* File name */
108 struct string symlink; /* Link to which file points */
109- long size; /* File size. -1 if unknown. */
110+ off_t size; /* File size. -1 if unknown. */
111 time_t mtime; /* Modification time */
112 unsigned int local_time_zone:1; /* What format the mtime is in */
113 mode_t permissions; /* File permissions */
This page took 0.098977 seconds and 4 git commands to generate.