From d15379c31d9437ecf3bf390379663b17bd4ea28b Mon Sep 17 00:00:00 2001
From: Slava Zanko <slavazanko@gmail.com>
Date: Fri, 27 Nov 2009 12:54:25 +0200
Subject: [PATCH] REBASE: CLEANUP: for merge with 730ab3937cc3d8d978b51829bfa6ced71d2bd660
run command:
git rebase -i 730ab3937cc3d8d978b51829bfa6ced71d2bd660^
and split this commit with 730ab3937cc3d
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
---
src/ext.c | 63 +++++++++++++++++++++++++++++-------------------------------
1 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/src/ext.c b/src/ext.c
index b9ed2d7..771f85a 100644
a
|
b
|
exec_extension (const char *filename, const char *lc_data, int *move_dir, |
300 | 300 | # define FILE_CMD "file " |
301 | 301 | #endif |
302 | 302 | |
303 | | /* |
| 303 | /* |
304 | 304 | * Run cmd_file with args, put in buf[buflen] result. |
305 | 305 | * If error, put in buf[0] = '\0'; |
306 | 306 | * |
… |
… |
get_popen_information(const char *cmd_file, const char *args, char *buf, int bu |
326 | 326 | read_bytes = (fgets (buf, buflen, f) |
327 | 327 | != NULL); |
328 | 328 | if (read_bytes == 0) |
329 | | /* if(buflen > 0) // ;-) */ |
330 | | buf[0] = 0; |
| 329 | /* if(buflen > 0) // ;-) */ |
| 330 | buf[0] = 0; |
331 | 331 | pclose (f); |
332 | | } else { |
333 | | /* if(buflen > 0) // ;-) */ |
| 332 | } else { |
| 333 | /* if(buflen > 0) // ;-) */ |
334 | 334 | buf[0] = 0; /* Paranoid termination */ |
335 | 335 | return -1; |
336 | 336 | } |
337 | | |
| 337 | |
338 | 338 | /* Paranoid termination */ |
339 | | buf[buflen - 1] = 0; |
| 339 | buf[buflen - 1] = 0; |
340 | 340 | |
341 | 341 | return (read_bytes > 0); |
342 | 342 | } |
… |
… |
get_file_type_local (const char *filename, char *buf, int buflen) |
361 | 361 | static int |
362 | 362 | get_file_encoding_local (const char *filename, char *buf, int buflen) |
363 | 363 | { |
364 | | if(autodetect_codeset[0] != '\0') |
365 | | { |
366 | | int read_bytes = 0; |
367 | | char *tmp = name_quote (filename, 0); |
368 | | char *lang = name_quote (autodetect_codeset, 0); |
369 | | char *args= g_strconcat (" -L", lang, " -i ", tmp, (char *) 0); |
370 | | int ret = get_popen_information("enca", args, buf, buflen); |
371 | | g_free (args); |
372 | | g_free (lang); |
373 | | g_free (tmp); |
374 | | return ret; |
| 364 | if(autodetect_codeset[0] != '\0') { |
| 365 | int read_bytes = 0; |
| 366 | char *tmp = name_quote (filename, 0); |
| 367 | char *lang = name_quote (autodetect_codeset, 0); |
| 368 | char *args= g_strconcat (" -L", lang, " -i ", tmp, (char *) 0); |
| 369 | int ret = get_popen_information("enca", args, buf, buflen); |
| 370 | g_free (args); |
| 371 | g_free (lang); |
| 372 | g_free (tmp); |
| 373 | return ret; |
375 | 374 | } |
376 | | return 0; |
| 375 | return 0; |
377 | 376 | } |
378 | 377 | |
379 | 378 | |
… |
… |
regex_check_type (const char *filename, const char *ptr, int *have_type) |
390 | 389 | |
391 | 390 | /* Following variables are valid if *have_type is 1 */ |
392 | 391 | static char content_string[2048]; |
393 | | static char encoding_id[21]; // CSISO51INISCYRILLIC -- 20 |
| 392 | static char encoding_id[21]; /* CSISO51INISCYRILLIC -- 20 */ |
394 | 393 | static int got_encoding_data = 0; |
395 | 394 | static int content_shift = 0; |
396 | 395 | static int got_data = 0; |
… |
… |
regex_check_type (const char *filename, const char *ptr, int *have_type) |
411 | 410 | |
412 | 411 | realname = localfile; |
413 | 412 | |
414 | | got_encoding_data = |
415 | | get_file_encoding_local (localfile, encoding_id, |
| 413 | got_encoding_data = |
| 414 | get_file_encoding_local (localfile, encoding_id, |
416 | 415 | sizeof (encoding_id)); |
417 | 416 | mc_ungetlocalcopy (filename, localfile, 0); |
418 | 417 | |
419 | | if( got_encoding_data > 0 ) |
420 | | { |
421 | | char *pp; |
422 | | if ((pp = strchr (encoding_id, '\n')) != 0) |
423 | | *pp = 0; |
| 418 | if( got_encoding_data > 0 ) { |
| 419 | char *pp; |
| 420 | if ((pp = strchr (encoding_id, '\n')) != 0) |
| 421 | *pp = 0; |
424 | 422 | |
425 | | source_codepage = get_codepage_index( encoding_id ); |
426 | | if(source_codepage == -1) |
427 | | source_codepage = default_source_codepage; |
428 | | } |
| 423 | source_codepage = get_codepage_index( encoding_id ); |
| 424 | if(source_codepage == -1) |
| 425 | source_codepage = default_source_codepage; |
| 426 | } |
429 | 427 | |
430 | | |
431 | | got_data = |
| 428 | got_data = |
432 | 429 | get_file_type_local (localfile, content_string, |
433 | 430 | sizeof (content_string)); |
434 | 431 | |