perl/XML-Simple: rebuild for Perl 5.40 and obsolete package for Perl 5.34
[oi-userland.git] / components / desktop / gftp / patches / 04-g11n-lc-time.patch
blobb49a89c08655b66dba9a4536d5075bd103c67dcc
1 --- gftp-2.0.19/lib/parse-dir-listing.c.orig 2008-12-09 11:58:27.338209964 +0900
2 +++ gftp-2.0.19/lib/parse-dir-listing.c 2008-12-09 12:06:12.492612579 +0900
3 @@ -97,7 +97,7 @@ parse_time (char *str, char **endpos)
5 struct tm curtime, *loctime;
6 time_t t, ret;
7 - char *tmppos;
8 + char *tmppos, *format;
9 size_t slen;
10 int i, num;
12 @@ -131,7 +131,18 @@ parse_time (char *str, char **endpos)
14 if (strchr (str, ':') != NULL)
16 +#ifndef __sun
17 tmppos = strptime (str, "%h %d %H:%M", &curtime);
18 +#else
19 +# if ENABLE_NLS
20 + format = dcgettext ("SUNW_OST_OSCMD", " %b %e %H:%M", LC_TIME);
21 + if (format && *format == ' ')
22 + format++;
23 + tmppos = strptime (str, format, &curtime);
24 +# else
25 + tmppos = strptime (str, "%b %e %H:%M", &curtime);
26 +# endif
27 +#endif
28 t = time (NULL);
29 loctime = localtime (&t);
31 @@ -141,7 +152,20 @@ parse_time (char *str, char **endpos)
32 curtime.tm_year = loctime->tm_year;
34 else
35 - tmppos = strptime (str, "%h %d %Y", &curtime);
36 + {
37 +#ifndef __sun
38 + tmppos = strptime (str, "%h %d %Y", &curtime);
39 +#else
40 +# if ENABLE_NLS
41 + format = dcgettext ("SUNW_OST_OSCMD", " %b %e %Y", LC_TIME);
42 + if (format && *format == ' ')
43 + format++;
44 + tmppos = strptime (str, format, &curtime);
45 +# else
46 + tmppos = strptime (str, "%b %e %Y", &curtime);
47 +# endif
48 +#endif
49 + }
52 if (tmppos != NULL)
53 @@ -387,6 +411,7 @@ gftp_parse_ls_unix (gftp_request * reque
54 gftp_file * fle)
56 char *endpos, *startpos, *pos, *attribs;
57 + char *backup_lc_time, *remote_lc_time;
58 int cols;
60 /* If there is no space between the attribs and links field, just make one */
61 @@ -494,7 +519,17 @@ gftp_parse_ls_unix (gftp_request * reque
62 while (*startpos == ' ')
63 startpos++;
65 +#if ENABLE_NLS
66 + backup_lc_time = setlocale (LC_TIME, NULL);
67 + gftp_lookup_request_option (request, "remote_lc_time", &remote_lc_time);
68 + if (backup_lc_time && remote_lc_time != NULL && *remote_lc_time != '\0')
69 + setlocale (LC_TIME, remote_lc_time);
70 +#endif
71 fle->datetime = parse_time (startpos, &startpos);
72 +#if ENABLE_NLS
73 + if (backup_lc_time && remote_lc_time != NULL && *remote_lc_time != '\0')
74 + setlocale (LC_TIME, backup_lc_time);
75 +#endif
77 /* Skip the blanks till we get to the next entry */
78 startpos = goto_next_token (startpos);
79 --- gftp-2.0.19/lib/protocols.c.orig 2008-12-09 11:42:25.720946263 +0900
80 +++ gftp-2.0.19/lib/protocols.c 2008-12-09 14:18:02.831821587 +0900
81 @@ -362,12 +362,13 @@ gftp_stat_filename (gftp_request * reque
82 int
83 gftp_list_files (gftp_request * request)
85 - char *remote_lc_time, *locret;
86 - int fd;
87 + char *backup_lc_time, *remote_lc_time, *locret;
88 + int fd, ret;
90 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
92 #if ENABLE_NLS
93 + backup_lc_time = setlocale (LC_TIME, NULL);
94 gftp_lookup_request_option (request, "remote_lc_time", &remote_lc_time);
95 if (remote_lc_time != NULL && *remote_lc_time != '\0')
96 locret = setlocale (LC_TIME, remote_lc_time);
97 @@ -394,6 +395,9 @@ gftp_list_files (gftp_request * request)
99 request->cachefd = fd;
100 request->cached = 1;
101 +#if ENABLE_NLS
102 + setlocale (LC_TIME, backup_lc_time);
103 +#endif
104 return (0);
106 else if (request->use_cache)
107 @@ -407,9 +411,18 @@ gftp_list_files (gftp_request * request)
110 if (request->list_files == NULL)
111 - return (GFTP_EFATAL);
113 +#if ENABLE_NLS
114 + setlocale (LC_TIME, backup_lc_time);
115 +#endif
116 + return (GFTP_EFATAL);
119 - return (request->list_files (request));
120 + ret = request->list_files (request);
121 +#if ENABLE_NLS
122 + setlocale (LC_TIME, backup_lc_time);
123 +#endif
124 + return (ret);
128 @@ -795,6 +808,12 @@ gftp_set_account (gftp_request * request
130 gftp_set_directory (gftp_request * request, const char *directory)
132 + mode_t st_mode;
133 + off_t linksize;
134 + char *locale_directory = NULL;
135 + int fd;
136 + size_t dest_len;
138 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
139 g_return_val_if_fail (directory != NULL, GFTP_EFATAL);
141 @@ -809,6 +828,29 @@ gftp_set_directory (gftp_request * reque
143 return (0);
145 + else if (request->url_prefix && !strcmp (request->url_prefix, "file"))
147 + st_mode = 0;
148 + linksize = 0;
149 + gftp_stat_filename (request, directory, &st_mode, &linksize);
150 + if (!S_ISDIR (st_mode))
152 + locale_directory = gftp_filename_from_utf8 (request, directory, &dest_len);
153 + if (locale_directory != NULL &&
154 + (fd = gftp_fd_open (request, locale_directory, O_RDONLY, 0)) != -1)
156 + close (fd);
157 + request->directory = g_strdup (directory);
159 + else if ((fd = gftp_fd_open (request, directory, O_RDONLY, 0)) != -1)
161 + close (fd);
162 + request->directory = g_strdup (directory);
164 + g_free (locale_directory);
165 + return (0);
168 else if (request->chdir == NULL)
169 return (GFTP_EFATAL);
170 return (request->chdir (request, directory));