1
1

* charset.h: Provide new inline functions convert_to_display_c()

and convert_from_input_c().
* view.c: Include charset.h unconditionally, use new conversion
functions that don't require ifdefs.
Этот коммит содержится в:
Pavel Roskin 2002-10-30 23:42:21 +00:00
родитель 4d20330abc
Коммит 2d3c157e52
3 изменённых файлов: 34 добавлений и 26 удалений

Просмотреть файл

@ -1,5 +1,10 @@
2002-10-30 Pavel Roskin <proski@gnu.org>
* charset.h: Provide new inline functions convert_to_display_c()
and convert_from_input_c().
* view.c: Include charset.h unconditionally, use new conversion
functions that don't require ifdefs.
* charset.h [!HAVE_CHARSET]: Provide dummy macros for
convert_to_display and convert_from_input. Eliminate uchar
definition, use unsigned char, adjust dependencies.

Просмотреть файл

@ -11,7 +11,6 @@ extern int n_codepages;
extern unsigned char conv_displ[256];
extern unsigned char conv_input[256];
extern unsigned char printable[256];
struct codepage_desc {
char *id;
@ -29,9 +28,30 @@ void convert_to_display (char *str);
void convert_from_input (char *str);
void convert_string (unsigned char *str);
/* Convert single characters */
static inline int
convert_to_display_c (int c)
{
if (c < 0 || c >= 256)
return c;
return conv_displ[c];
}
static inline int
convert_from_input_c (int c)
{
if (c < 0 || c >= 256)
return c;
return conv_input[c];
}
#else /* !HAVE_CHARSET */
#define convert_to_display(x) do {} while (0)
#define convert_from_input(x) do {} while (0)
#define convert_to_display_c(c) (c)
#define convert_from_input_c(c) (c)
#define convert_to_display(str) do {} while (0)
#define convert_from_input(str) do {} while (0)
#endif /* HAVE_CHARSET */
#endif /* __CHARSETS_H__ */

Просмотреть файл

@ -57,10 +57,8 @@
#define WANT_WIDGETS
#include "view.h"
#ifdef HAVE_CHARSET
#include "charsets.h"
#include "selcodepage.h"
#endif /* HAVE_CHARSET */
#ifndef MAP_FILE
#define MAP_FILE 0
@ -935,9 +933,7 @@ display (WView *view)
/* Print the corresponding ascii character */
view_gotoyx (view, row, text_start + bytes);
#ifdef HAVE_CHARSET
c = conv_displ[c];
#endif
c = convert_to_display_c (c);
if (!is_printable (c))
c = '.';
@ -1024,9 +1020,7 @@ display (WView *view)
&& col < width - view->start_col) {
view_gotoyx (view, row, col + view->start_col);
#ifdef HAVE_CHARSET
c = conv_displ[c];
#endif
c = convert_to_display_c (c);
if (!is_printable (c))
c = '.';
@ -1972,20 +1966,15 @@ normal_search (WView *view, int direction)
exp = old ? old : exp;
#ifdef HAVE_CHARSET
if (*exp)
convert_to_display (exp);
#endif
convert_to_display (exp);
exp = input_dialog (_("Search"), _(" Enter search string:"), exp);
if ((!exp) || (!*exp)) {
if (exp)
g_free (exp);
#ifdef HAVE_CHARSET
if (old && *old)
convert_from_input (old);
#endif
convert_from_input (old);
return;
}
@ -1993,9 +1982,7 @@ normal_search (WView *view, int direction)
g_free (old);
old = exp;
#ifdef HAVE_CHARSET
convert_from_input (exp);
#endif
view->direction = direction;
do_normal_search (view, exp);
@ -2142,11 +2129,7 @@ view_handle_key (WView *view, int c)
set_monitor (view, off);
#ifdef HAVE_CHARSET
if (c >= 128 && c <= 255) {
c = conv_input[c];
}
#endif
c = convert_from_input_c (c);
if (view->hex_mode) {
switch (c) {