gtk+3: fix dependencies for new gnome/accessibility/at-spi2-core
[oi-userland.git] / components / desktop / gftp / patches / 04-g11n-lc-time.patch
blob3f78dac02fb36cda0d2b0f2deb67fbb249da3c0f
1 --- gftp-2.9.1b/lib/ftp-dir-listing.c.old 2024-07-01 21:03:44.877313412 -0400
2 +++ gftp-2.9.1b/lib/ftp-dir-listing.c 2024-07-01 21:07:51.201734399 -0400
3 @@ -140,7 +140,7 @@
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 @@ -170,7 +170,18 @@
13 /* Jul 06 12:57 or Jul 6 1999 */
14 if (strchr (str, ':') != NULL)
16 - tmppos = strptime (str, "%h %d %H:%M", &curtime);
17 +#ifndef __sun
18 + tmppos = strptime (str, "%h %d %H:%M", &curtime);
19 +#else
20 +# if ENABLE_NLS
21 + format = dcgettext ("SUNW_OST_OSCMD", " %b %e %H:%M", LC_TIME);
22 + if (format && *format == ' ')
23 + format++;
24 + tmppos = strptime (str, format, &curtime);
25 +# else
26 + tmppos = strptime (str, "%b %e %H:%M", &curtime);
27 +# endif
28 +#endif
29 t = time (NULL);
30 loctime = localtime (&t);
32 @@ -417,6 +428,7 @@
34 //DEBUG_TRACE("LSUNIX: %s\n", str);
35 char *endpos, *startpos, *pos, *attribs;
36 + char *backup_lc_time, *remote_lc_time;
37 int cols;
38 ftp_protocol_data * ftpdat = request->protocol_data;
40 @@ -525,7 +537,17 @@
41 while (*startpos == ' ')
42 startpos++;
44 - fle->datetime = parse_time (startpos, &startpos);
45 +#if ENABLE_NLS
46 + backup_lc_time = setlocale (LC_TIME, NULL);
47 + gftp_lookup_request_option (request, "remote_lc_time", &remote_lc_time);
48 + if (backup_lc_time && remote_lc_time != NULL && *remote_lc_time != '\0')
49 + setlocale (LC_TIME, remote_lc_time);
50 +#endif
51 + fle->datetime = parse_time (startpos, &startpos);
52 +#if ENABLE_NLS
53 + if (backup_lc_time && remote_lc_time != NULL && *remote_lc_time != '\0')
54 + setlocale (LC_TIME, backup_lc_time);
55 +#endif
57 /* Skip the blanks till we get to the next entry */
58 startpos = goto_next_token (startpos);
59 --- gftp-2.9.1b/lib/protocols.c.old 2024-07-01 21:08:53.175365431 -0400
60 +++ gftp-2.9.1b/lib/protocols.c 2024-07-01 21:12:17.445866678 -0400
61 @@ -352,12 +352,13 @@
62 gftp_list_files (gftp_request * request)
64 DEBUG_PRINT_FUNC
65 - char *remote_lc_time, *locret;
66 - int fd;
67 + char *backup_lc_time, *remote_lc_time, *locret;
68 + int fd, ret;
70 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
72 #if ENABLE_NLS
73 + backup_lc_time = setlocale (LC_TIME, NULL);
74 gftp_lookup_request_option (request, "remote_lc_time", &remote_lc_time);
75 if (remote_lc_time != NULL && *remote_lc_time != '\0')
76 locret = setlocale (LC_TIME, remote_lc_time);
77 @@ -384,6 +385,9 @@
79 request->cachefd = fd;
80 request->cached = 1;
81 +#if ENABLE_NLS
82 + setlocale (LC_TIME, backup_lc_time);
83 +#endif
84 return (0);
86 else if (request->use_cache)
87 @@ -397,9 +401,18 @@
90 if (request->list_files == NULL)
91 - return (GFTP_EFATAL);
92 + {
93 +#if ENABLE_NLS
94 + setlocale (LC_TIME, backup_lc_time);
95 +#endif
96 + return (GFTP_EFATAL);
97 + }
99 - return (request->list_files (request));
100 + ret = request->list_files (request);
101 +#if ENABLE_NLS
102 + setlocale (LC_TIME, backup_lc_time);
103 +#endif
104 + return (ret);
108 @@ -809,6 +822,12 @@
109 gftp_set_directory (gftp_request * request, const char *directory)
111 DEBUG_PRINT_FUNC
112 + mode_t st_mode;
113 + off_t linksize;
114 + char *locale_directory = NULL;
115 + int fd;
116 + size_t dest_len;
118 g_return_val_if_fail (request != NULL, GFTP_EFATAL);
119 g_return_val_if_fail (directory != NULL, GFTP_EFATAL);
121 @@ -822,6 +841,29 @@
123 return (0);
125 + else if (request->url_prefix && !strcmp (request->url_prefix, "file"))
127 + st_mode = 0;
128 + linksize = 0;
129 + gftp_stat_filename (request, directory, &st_mode, &linksize);
130 + if (!S_ISDIR (st_mode))
132 + locale_directory = gftp_filename_from_utf8 (request, directory, &dest_len);
133 + if (locale_directory != NULL &&
134 + (fd = gftp_fd_open (request, locale_directory, O_RDONLY, 0)) != -1)
136 + close (fd);
137 + request->directory = g_strdup (directory);
139 + else if ((fd = gftp_fd_open (request, directory, O_RDONLY, 0)) != -1)
141 + close (fd);
142 + request->directory = g_strdup (directory);
144 + g_free (locale_directory);
145 + return (0);
148 else if (request->chdir == NULL)
149 return (GFTP_EFATAL);
150 return (request->chdir (request, directory));