1 | diff -c -r mc-4.7.0-pre4/misc/mc.ext.in mc-4.7.0-pre4_cp_asm/misc/mc.ext.in |
---|
2 | *** mc-4.7.0-pre4/misc/mc.ext.in 2009-10-29 19:02:37.000000000 +0000 |
---|
3 | --- mc-4.7.0-pre4_cp_asm/misc/mc.ext.in 2009-11-20 09:21:03.000000000 +0000 |
---|
4 | *************** |
---|
5 | *** 103,108 **** |
---|
6 | --- 103,112 ---- |
---|
7 | # |
---|
8 | # Maybe: Open/XOpen/GOpen/KOpen/... for Console/X/GNOME/KDE/etc. |
---|
9 | |
---|
10 | + ### Set encoding ### |
---|
11 | + |
---|
12 | + type/text |
---|
13 | + Codepage=enca -L none -r %f |
---|
14 | |
---|
15 | ### Archives ### |
---|
16 | |
---|
17 | diff -c -r mc-4.7.0-pre4/src/charsets.c mc-4.7.0-pre4_cp_asm/src/charsets.c |
---|
18 | *** mc-4.7.0-pre4/src/charsets.c 2009-10-28 20:54:51.000000000 +0000 |
---|
19 | --- mc-4.7.0-pre4_cp_asm/src/charsets.c 2009-11-20 10:37:17.000000000 +0000 |
---|
20 | *************** |
---|
21 | *** 36,42 **** |
---|
22 | --- 36,46 ---- |
---|
23 | #include "util.h" /* concat_dir_and_file() */ |
---|
24 | #include "fileloc.h" |
---|
25 | |
---|
26 | + // Add extnumber encoding. |
---|
27 | + #define EXT_COUNT 10 |
---|
28 | + |
---|
29 | int n_codepages = 0; |
---|
30 | + int max_codepages = 0; |
---|
31 | |
---|
32 | struct codepage_desc *codepages; |
---|
33 | |
---|
34 | *************** |
---|
35 | *** 81,87 **** |
---|
36 | ++n_codepages; |
---|
37 | rewind (f); |
---|
38 | |
---|
39 | ! codepages = g_new0 (struct codepage_desc, n_codepages + 1); |
---|
40 | |
---|
41 | for (n_codepages = 0; fgets (buf, sizeof buf, f);) { |
---|
42 | /* split string into id and cpname */ |
---|
43 | --- 85,92 ---- |
---|
44 | ++n_codepages; |
---|
45 | rewind (f); |
---|
46 | |
---|
47 | ! max_codepages = n_codepages + 1 + EXT_COUNT; |
---|
48 | ! codepages = g_new0 (struct codepage_desc, max_codepages ); |
---|
49 | |
---|
50 | for (n_codepages = 0; fgets (buf, sizeof buf, f);) { |
---|
51 | /* split string into id and cpname */ |
---|
52 | *************** |
---|
53 | *** 155,162 **** |
---|
54 | if (codepages == NULL) |
---|
55 | return -1; |
---|
56 | for (i = 0; codepages[i].id; ++i) |
---|
57 | ! if (strcmp (id, codepages[i].id) == 0) |
---|
58 | return i; |
---|
59 | return -1; |
---|
60 | } |
---|
61 | |
---|
62 | --- 160,186 ---- |
---|
63 | if (codepages == NULL) |
---|
64 | return -1; |
---|
65 | for (i = 0; codepages[i].id; ++i) |
---|
66 | ! if (strcmp (id, codepages[i].id) == 0) |
---|
67 | return i; |
---|
68 | + |
---|
69 | + //if(n_codepages == max_codepages ) // Dynamic variant |
---|
70 | + //{ |
---|
71 | + // FIXME glib don't include function g_renew0. |
---|
72 | + // max_codepages += EXT_COUNT; |
---|
73 | + // struct codepage_desc* c = g_renew0(struct codepage_desc, codepages, max_codepages); |
---|
74 | + // if(c) |
---|
75 | + // { |
---|
76 | + // codepage_desc = c; |
---|
77 | + // .... |
---|
78 | + |
---|
79 | + if(n_codepages < max_codepages ) // Static variant |
---|
80 | + { |
---|
81 | + codepages[n_codepages].id = g_strdup (id); |
---|
82 | + codepages[n_codepages].name = g_strdup (_("External")); |
---|
83 | + n_codepages++; |
---|
84 | + return n_codepages-1; |
---|
85 | + } |
---|
86 | + |
---|
87 | return -1; |
---|
88 | } |
---|
89 | |
---|
90 | diff -c -r mc-4.7.0-pre4/src/ext.c mc-4.7.0-pre4_cp_asm/src/ext.c |
---|
91 | *** mc-4.7.0-pre4/src/ext.c 2009-10-30 18:44:39.000000000 +0000 |
---|
92 | --- mc-4.7.0-pre4_cp_asm/src/ext.c 2009-11-20 10:40:38.000000000 +0000 |
---|
93 | *************** |
---|
94 | *** 63,71 **** |
---|
95 | |
---|
96 | typedef char *(*quote_func_t) (const char *name, int quote_percent); |
---|
97 | |
---|
98 | static void |
---|
99 | ! exec_extension (const char *filename, const char *lc_data, int *move_dir, |
---|
100 | ! int start_line) |
---|
101 | { |
---|
102 | char *fn; |
---|
103 | char *file_name; |
---|
104 | --- 63,86 ---- |
---|
105 | |
---|
106 | typedef char *(*quote_func_t) (const char *name, int quote_percent); |
---|
107 | |
---|
108 | + |
---|
109 | + #ifdef HAVE_CHARSET |
---|
110 | + static void |
---|
111 | + exec_extension_full (const char *filename, const char *lc_data, int *move_dir, |
---|
112 | + int start_line, char *get_result); |
---|
113 | + static void |
---|
114 | + |
---|
115 | + exec_extension (const char *filename, const char *lc_data, int *move_dir, int start_line) |
---|
116 | + { |
---|
117 | + exec_extension_full (filename, lc_data, move_dir, start_line, 0); |
---|
118 | + } |
---|
119 | + |
---|
120 | static void |
---|
121 | ! exec_extension_full (const char *filename, const char *lc_data, int *move_dir, |
---|
122 | ! int start_line, char *get_result ) |
---|
123 | ! #else |
---|
124 | ! exec_extension (const char *filename, const char *lc_data, int *move_dir, int start_line) |
---|
125 | ! #endif /* HAVE_CHARSET */ |
---|
126 | { |
---|
127 | char *fn; |
---|
128 | char *file_name; |
---|
129 | *************** |
---|
130 | *** 270,276 **** |
---|
131 | q[1] = 0; |
---|
132 | do_cd (p, cd_parse_command); |
---|
133 | } else { |
---|
134 | ! shell_execute (cmd, EXECUTE_INTERNAL); |
---|
135 | if (console_flag) { |
---|
136 | handle_console (CONSOLE_SAVE); |
---|
137 | if (output_lines && keybar_visible) { |
---|
138 | --- 285,313 ---- |
---|
139 | q[1] = 0; |
---|
140 | do_cd (p, cd_parse_command); |
---|
141 | } else { |
---|
142 | ! |
---|
143 | ! #ifdef HAVE_CHARSET |
---|
144 | ! #define MAX_CODEPAGE_TEXT_LEN 10 |
---|
145 | ! if( get_result != 0){ // get_result != 0 -- need get result from stdout. |
---|
146 | ! FILE *f = popen (cmd, "r"); |
---|
147 | ! if(f) { |
---|
148 | ! #ifdef __QNXNTO__ |
---|
149 | ! if (setvbuf (f, NULL, _IOFBF, 0) != 0) { |
---|
150 | ! (void)pclose (f); |
---|
151 | ! }else{ |
---|
152 | ! #endif |
---|
153 | ! fgets(get_result, sizeof(get_result) * MAX_CODEPAGE_TEXT_LEN, f); |
---|
154 | ! get_result[strlen(get_result)-1]='\0'; |
---|
155 | ! pclose(f); |
---|
156 | ! #ifdef __QNXNTO__ |
---|
157 | ! } |
---|
158 | ! #endif |
---|
159 | ! } |
---|
160 | ! } else { |
---|
161 | ! #endif /* HAVE_CHARSET */ |
---|
162 | ! |
---|
163 | ! |
---|
164 | ! shell_execute (cmd, EXECUTE_INTERNAL); |
---|
165 | if (console_flag) { |
---|
166 | handle_console (CONSOLE_SAVE); |
---|
167 | if (output_lines && keybar_visible) { |
---|
168 | *************** |
---|
169 | *** 281,286 **** |
---|
170 | --- 318,324 ---- |
---|
171 | |
---|
172 | } |
---|
173 | } |
---|
174 | + } |
---|
175 | } |
---|
176 | |
---|
177 | g_free (file_name); |
---|
178 | *************** |
---|
179 | *** 590,599 **** |
---|
180 | break; |
---|
181 | continue; |
---|
182 | } |
---|
183 | ! if (!strcmp (action, p)) { |
---|
184 | ! *r = c; |
---|
185 | ! for (p = r + 1; *p == ' ' || *p == '\t'; p++); |
---|
186 | ! |
---|
187 | /* Empty commands just stop searching |
---|
188 | * through, they don't do anything |
---|
189 | * |
---|
190 | --- 628,655 ---- |
---|
191 | break; |
---|
192 | continue; |
---|
193 | } |
---|
194 | ! |
---|
195 | ! #ifdef HAVE_CHARSET |
---|
196 | ! if (strcmp (p, "Codepage") == 0) |
---|
197 | ! { |
---|
198 | ! char cmd[MAX_CODEPAGE_TEXT_LEN + 1]="\0"; |
---|
199 | ! |
---|
200 | ! char *filename_copy = g_strdup (filename); |
---|
201 | ! exec_extension_full (filename_copy, r + 1, move_dir, |
---|
202 | ! view_at_line_number, cmd); |
---|
203 | ! g_free (filename_copy); |
---|
204 | ! |
---|
205 | ! source_codepage = get_codepage_index( cmd ); |
---|
206 | ! |
---|
207 | ! *r = c; |
---|
208 | ! continue; |
---|
209 | ! } |
---|
210 | ! #endif |
---|
211 | ! |
---|
212 | ! if (!strcmp (action, p)) { |
---|
213 | ! *r = c; |
---|
214 | ! for (p = r + 1; *p == ' ' || *p == '\t'; p++); |
---|
215 | ! |
---|
216 | /* Empty commands just stop searching |
---|
217 | * through, they don't do anything |
---|
218 | * |
---|
219 | *************** |
---|
220 | *** 602,608 **** |
---|
221 | * filename parameter invalid (ie, most of the time, |
---|
222 | * we get filename as a pointer from current_panel->dir). |
---|
223 | */ |
---|
224 | ! if (p < q) { |
---|
225 | char *filename_copy = g_strdup (filename); |
---|
226 | |
---|
227 | exec_extension (filename_copy, r + 1, move_dir, |
---|
228 | --- 658,664 ---- |
---|
229 | * filename parameter invalid (ie, most of the time, |
---|
230 | * we get filename as a pointer from current_panel->dir). |
---|
231 | */ |
---|
232 | ! if (p < q) { |
---|
233 | char *filename_copy = g_strdup (filename); |
---|
234 | |
---|
235 | exec_extension (filename_copy, r + 1, move_dir, |
---|