1
1

* charset.h [!HAVE_CHARSET]: Provide dummy macros for

convert_to_display and convert_from_input.  Eliminate uchar
definition, use unsigned char, adjust dependencies.
* charsets.c (convert_to_display): Tolerate NULL argument.
(convert_from_input): Likewise.
Этот коммит содержится в:
Pavel Roskin 2002-10-30 23:14:26 +00:00
родитель a305ec68f9
Коммит 517243efa0
3 изменённых файлов: 98 добавлений и 74 удалений

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

@ -1,5 +1,11 @@
2002-10-30 Pavel Roskin <proski@gnu.org>
* charset.h [!HAVE_CHARSET]: Provide dummy macros for
convert_to_display and convert_from_input. Eliminate uchar
definition, use unsigned char, adjust dependencies.
* charsets.c (convert_to_display): Tolerate NULL argument.
(convert_from_input): Likewise.
* ext.c (exec_extension): Don't create self-destructing scripts
for the viewer - remove those scripts manually after calling
view(). This fixes the problem with double F8 in the viewer on

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

@ -32,10 +32,11 @@ int n_codepages = 0;
struct codepage_desc *codepages;
uchar conv_displ[256];
uchar conv_input[256];
unsigned char conv_displ[256];
unsigned char conv_input[256];
int load_codepages_list(void)
int
load_codepages_list (void)
{
int result = -1;
FILE *f;
@ -103,7 +104,8 @@ fail:
return result;
}
void free_codepages_list (void)
void
free_codepages_list (void)
{
if (n_codepages > 0) {
int i;
@ -119,12 +121,14 @@ void free_codepages_list (void)
#define OTHER_8BIT "Other_8_bit"
char *get_codepage_id( int n )
char *
get_codepage_id (int n)
{
return (n < 0) ? OTHER_8BIT : codepages[n].id;
}
int get_codepage_index( const char *id )
int
get_codepage_index (const char *id)
{
int i;
if (strcmp (id, OTHER_8BIT) == 0)
@ -135,14 +139,16 @@ int get_codepage_index( const char *id )
return -1;
}
static char translate_character( iconv_t cd, char c )
static char
translate_character (iconv_t cd, char c)
{
char outbuf[4], *obuf;
size_t ibuflen, obuflen, count;
ICONV_CONST char *ibuf = &c;
obuf = outbuf;
ibuflen = 1; obuflen = 4;
ibuflen = 1;
obuflen = 4;
count = iconv (cd, &ibuf, &ibuflen, &obuf, &obuflen);
if (count >= 0 && ibuflen == 0)
@ -159,7 +165,8 @@ char errbuf[255];
*/
#define CP_ASCII 0
char* init_translation_table( int cpsource, int cpdisplay )
char *
init_translation_table (int cpsource, int cpdisplay)
{
int i;
iconv_t cd;
@ -207,7 +214,7 @@ char* init_translation_table( int cpsource, int cpdisplay )
}
for (i = 128; i <= 255; ++i) {
uchar ch;
unsigned char ch;
ch = translate_character (cd, i);
conv_input[i] = (ch == UNKNCHAR) ? i : ch;
}
@ -217,15 +224,23 @@ char* init_translation_table( int cpsource, int cpdisplay )
return NULL;
}
void convert_to_display( char *str )
void
convert_to_display (char *str)
{
while ((*str = conv_displ[ (uchar) *str ]))
if (!str)
return;
while ((*str = conv_displ[(unsigned char) *str]))
str++;
}
void convert_from_input( char *str )
void
convert_from_input (char *str)
{
while ((*str = conv_input[ (uchar) *str ]))
if (!str)
return;
while ((*str = conv_input[(unsigned char) *str]))
str++;
}
#endif /* HAVE_CHARSET */

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

@ -1,18 +1,17 @@
#ifdef HAVE_CHARSET
#ifndef __CHARSETS_H__
#define __CHARSETS_H__
#ifdef HAVE_CHARSET
#define UNKNCHAR '\001'
#define CHARSETS_INDEX "mc.charsets"
typedef unsigned char uchar;
extern int n_codepages;
extern uchar conv_displ[256];
extern uchar conv_input[256];
extern uchar printable[256];
extern unsigned char conv_displ[256];
extern unsigned char conv_input[256];
extern unsigned char printable[256];
struct codepage_desc {
char *id;
@ -28,7 +27,11 @@ void free_codepages_list(void);
char *init_translation_table (int cpsource, int cpdisplay);
void convert_to_display (char *str);
void convert_from_input (char *str);
void convert_string( uchar *str );
void convert_string (unsigned char *str);
#else /* !HAVE_CHARSET */
#define convert_to_display(x) do {} while (0)
#define convert_from_input(x) do {} while (0)
#endif /* HAVE_CHARSET */
#endif /* __CHARSETS_H__ */
#endif /* HAVE_CHARSET */