strutil.h: replaced iconv_t to GIConv in INVALID_CONV definition.

Removed <iconv.h> include. Add "global.h" include.
Moved str_isutf8 function declaration under header guard.
Formatting.

view.c: used symbolic constant.
Formatting.
This commit is contained in:
Andrew Borodin 2009-04-19 17:45:10 +04:00
parent 9c713d2128
commit 6a638f25b3
2 changed files with 16 additions and 14 deletions

View File

@ -1,6 +1,8 @@
#ifndef MC_STRUTIL_H #ifndef MC_STRUTIL_H
#define MC_STRUTIL_H #define MC_STRUTIL_H
#include "global.h" /* include glib.h */
/* Header file for strutil.c, strutilascii.c, strutil8bit.c, strutilutf8.c. /* Header file for strutil.c, strutilascii.c, strutil8bit.c, strutilutf8.c.
* There are two sort of functions: * There are two sort of functions:
* 1. functions for working with growing strings and conversion strings between * 1. functions for working with growing strings and conversion strings between
@ -33,7 +35,6 @@
* prefix in second string. However, str_prefix return number of characters in * prefix in second string. However, str_prefix return number of characters in
* decompose form. (used in do_search (screen.c)) * decompose form. (used in do_search (screen.c))
*/ */
#include <iconv.h>
/* errors for conversion function: /* errors for conversion function:
* problem means, that not every characters was successfully converted (They are * problem means, that not every characters was successfully converted (They are
@ -59,13 +60,12 @@
#define HIDE_FIT(x) ((x) & 0x000f) #define HIDE_FIT(x) ((x) & 0x000f)
// fit alignment, if string is to long, is truncated with '~' // fit alignment, if string is to long, is truncated with '~'
#define J_LEFT_FIT 0x11 #define J_LEFT_FIT 0x11
#define J_RIGHT_FIT 0x12 #define J_RIGHT_FIT 0x12
#define J_CENTER_FIT 0x13 #define J_CENTER_FIT 0x13
#define J_CENTER_LEFT_FIT 0x14 #define J_CENTER_LEFT_FIT 0x14
// redefinition of iconv_t, so is not needed include iconv.h in other files. #define INVALID_CONV ((GIConv) (-1))
#define INVALID_CONV ((iconv_t) (-1))
// standard convertors // standard convertors
extern GIConv str_cnv_to_term; extern GIConv str_cnv_to_term;
@ -486,9 +486,9 @@ int str_key_collate (const char *t1, const char *t2, int case_sen);
*/ */
void str_release_key (char *key, int case_sen); void str_release_key (char *key, int case_sen);
#endif
/* return 1 if codeset_name is utf8 or utf-8 /* return 1 if codeset_name is utf8 or utf-8
* I * I
*/ */
int str_isutf8 (const char *codeset_name); int str_isutf8 (const char *codeset_name);
#endif /* MC_STRUTIL_H*/

View File

@ -2008,7 +2008,8 @@ view_load (WView *view, const char *command, const char *file,
enc = vfs_get_encoding (canon_fname); enc = vfs_get_encoding (canon_fname);
if (enc != NULL) { if (enc != NULL) {
view->converter = str_crt_conv_from (enc); view->converter = str_crt_conv_from (enc);
if (view->converter == (iconv_t) (-1)) view->converter = str_cnv_from_term; if (view->converter == INVALID_CONV)
view->converter = str_cnv_from_term;
} }
g_free (canon_fname); g_free (canon_fname);
} }
@ -3661,14 +3662,15 @@ view_select_encoding (WView *view)
enc = g_strdup( get_codepage_id ( source_codepage ) ); enc = g_strdup( get_codepage_id ( source_codepage ) );
if (enc != NULL) { if (enc != NULL) {
conv = str_crt_conv_from (enc); conv = str_crt_conv_from (enc);
if (conv != (iconv_t)(-1)) { if (conv != INVALID_CONV) {
if (view->converter != str_cnv_from_term) str_close_conv (view->converter); if (view->converter != str_cnv_from_term)
str_close_conv (view->converter);
view->converter = conv; view->converter = conv;
view_reset_cache_lines (view); view_reset_cache_lines (view);
line = view_offset_to_line (view, view->dpy_start); line = view_offset_to_line (view, view->dpy_start);
view_set_first_showed (view, line); view_set_first_showed (view, line);
} }
g_free(enc); g_free(enc);
} }
} }