Made use of iconv wrapper function unconditionally.

Obsoleted macro Libisofs_with_iso_iconV.
This commit is contained in:
Thomas Schmitt 2009-05-26 18:23:59 +02:00
parent e8fc149423
commit ef96f3588c
2 changed files with 0 additions and 181 deletions

View File

@ -5425,14 +5425,6 @@ struct burn_source {
#define Libisofs_aaip_2_0 yes #define Libisofs_aaip_2_0 yes
/* Encapsulation : Use iso_iconv*() wrappers.
They can print errno messages and they
can avoid iconv() if the identical mapping is desired.
One could install own simple conversion capabilities.
*/
#define Libisofs_with_iso_iconV yes
/* ---------------------------- Experiments ---------------------------- */ /* ---------------------------- Experiments ---------------------------- */
/* Hardlinks : During image generation accompany the tree of IsoFileSrc /* Hardlinks : During image generation accompany the tree of IsoFileSrc

View File

@ -32,9 +32,6 @@
#endif #endif
#ifdef Libisofs_with_iso_iconV
/* Produce possibly inflationary error messages directly to stderr */ /* Produce possibly inflationary error messages directly to stderr */
static int iso_iconv_debug = 0; static int iso_iconv_debug = 0;
@ -141,8 +138,6 @@ int iso_iconv_close(struct iso_iconv_handle *handle, int flag)
return ret; return ret;
} }
#endif /* Libisofs_with_iso_iconV */
int int_pow(int base, int power) int int_pow(int base, int power)
{ {
@ -183,13 +178,8 @@ int strconv(const char *str, const char *icharset, const char *ocharset,
size_t inbytes; size_t inbytes;
size_t outbytes; size_t outbytes;
size_t n; size_t n;
#ifdef Libisofs_with_iso_iconV
struct iso_iconv_handle conv; struct iso_iconv_handle conv;
int conv_ret; int conv_ret;
#else
iconv_t conv;
#endif
char *out = NULL; char *out = NULL;
char *src; char *src;
@ -204,43 +194,22 @@ int strconv(const char *str, const char *icharset, const char *ocharset,
goto ex; goto ex;
} }
#ifdef Libisofs_with_iso_iconV
conv_ret = iso_iconv_open(&conv, (char *) ocharset, (char *) icharset, 0); conv_ret = iso_iconv_open(&conv, (char *) ocharset, (char *) icharset, 0);
if (conv_ret <= 0) { if (conv_ret <= 0) {
#else
conv = iconv_open(ocharset, icharset);
if (conv == (iconv_t)(-1)) {
#endif
retval = ISO_CHARSET_CONV_ERROR; retval = ISO_CHARSET_CONV_ERROR;
goto ex; goto ex;
} }
src = (char *)str; src = (char *)str;
ret = (char *)out; ret = (char *)out;
#ifdef Libisofs_with_iso_iconV
n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0); n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0);
if (n == -1) { if (n == -1) {
/* error */ /* error */
iso_iconv_close(&conv, 0); iso_iconv_close(&conv, 0);
#else
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
if (n == -1) {
/* error */
iconv_close(conv);
#endif
retval = ISO_CHARSET_CONV_ERROR; retval = ISO_CHARSET_CONV_ERROR;
goto ex; goto ex;
} }
*ret = '\0'; *ret = '\0';
#ifdef Libisofs_with_iso_iconV
iso_iconv_close(&conv, 0); iso_iconv_close(&conv, 0);
#else
iconv_close(conv);
#endif
*output = malloc(ret - out + 1); *output = malloc(ret - out + 1);
if (*output == NULL) { if (*output == NULL) {
@ -261,14 +230,8 @@ int strnconv(const char *str, const char *icharset, const char *ocharset,
size_t inbytes; size_t inbytes;
size_t outbytes; size_t outbytes;
size_t n; size_t n;
#ifdef Libisofs_with_iso_iconV
struct iso_iconv_handle conv; struct iso_iconv_handle conv;
int conv_ret; int conv_ret;
#else
iconv_t conv;
#endif
char *out = NULL; char *out = NULL;
char *src; char *src;
char *ret; char *ret;
@ -281,43 +244,22 @@ int strnconv(const char *str, const char *icharset, const char *ocharset,
retval = ISO_OUT_OF_MEM; retval = ISO_OUT_OF_MEM;
goto ex; goto ex;
} }
#ifdef Libisofs_with_iso_iconV
conv_ret = iso_iconv_open(&conv, (char *) ocharset, (char *) icharset, 0); conv_ret = iso_iconv_open(&conv, (char *) ocharset, (char *) icharset, 0);
if (conv_ret <= 0) { if (conv_ret <= 0) {
#else
conv = iconv_open(ocharset, icharset);
if (conv == (iconv_t)(-1)) {
#endif
retval = ISO_CHARSET_CONV_ERROR; retval = ISO_CHARSET_CONV_ERROR;
goto ex; goto ex;
} }
src = (char *)str; src = (char *)str;
ret = (char *)out; ret = (char *)out;
#ifdef Libisofs_with_iso_iconV
n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0); n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0);
if (n == -1) { if (n == -1) {
/* error */ /* error */
iso_iconv_close(&conv, 0); iso_iconv_close(&conv, 0);
#else
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
if (n == -1) {
/* error */
iconv_close(conv);
#endif
retval = ISO_CHARSET_CONV_ERROR; retval = ISO_CHARSET_CONV_ERROR;
goto ex; goto ex;
} }
*ret = '\0'; *ret = '\0';
#ifdef Libisofs_with_iso_iconV
iso_iconv_close(&conv, 0); iso_iconv_close(&conv, 0);
#else
iconv_close(conv);
#endif
*output = malloc(ret - out + 1); *output = malloc(ret - out + 1);
if (*output == NULL) { if (*output == NULL) {
@ -342,13 +284,8 @@ ex:;
static static
int str2wchar(const char *icharset, const char *input, wchar_t **output) int str2wchar(const char *icharset, const char *input, wchar_t **output)
{ {
#ifdef Libisofs_with_iso_iconV
struct iso_iconv_handle conv; struct iso_iconv_handle conv;
int conv_ret; int conv_ret;
#else
iconv_t conv;
#endif
/* That while loop smells like a potential show stopper */ /* That while loop smells like a potential show stopper */
size_t loop_counter = 0, loop_limit = 3; size_t loop_counter = 0, loop_limit = 3;
@ -364,15 +301,8 @@ int str2wchar(const char *icharset, const char *input, wchar_t **output)
return ISO_NULL_POINTER; return ISO_NULL_POINTER;
} }
#ifdef Libisofs_with_iso_iconV
conv_ret = iso_iconv_open(&conv, "WCHAR_T", (char *) icharset, 0); conv_ret = iso_iconv_open(&conv, "WCHAR_T", (char *) icharset, 0);
if (conv_ret <= 0) { if (conv_ret <= 0) {
#else
conv = iconv_open("WCHAR_T", icharset);
if (conv == (iconv_t)-1) {
#endif
return ISO_CHARSET_CONV_ERROR; return ISO_CHARSET_CONV_ERROR;
} }
@ -388,13 +318,7 @@ int str2wchar(const char *icharset, const char *input, wchar_t **output)
ret = (char *)wstr; ret = (char *)wstr;
src = (char *)input; src = (char *)input;
#ifdef Libisofs_with_iso_iconV
n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0); n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0);
#else
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
#endif
while (n == -1) { while (n == -1) {
if (errno == E2BIG) { if (errno == E2BIG) {
@ -424,34 +348,16 @@ int str2wchar(const char *icharset, const char *input, wchar_t **output)
loop_counter++; loop_counter++;
if (loop_counter > loop_limit) if (loop_counter > loop_limit)
goto conv_error; goto conv_error;
#ifdef Libisofs_with_iso_iconV
n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0); n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0);
#else
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
#endif
} }
} }
#ifdef Libisofs_with_iso_iconV
iso_iconv_close(&conv, 0); iso_iconv_close(&conv, 0);
#else
iconv_close(conv);
#endif
*( (wchar_t *)ret )='\0'; *( (wchar_t *)ret )='\0';
*output = wstr; *output = wstr;
return ISO_SUCCESS; return ISO_SUCCESS;
conv_error:; conv_error:;
#ifdef Libisofs_with_iso_iconV
iso_iconv_close(&conv, 0); iso_iconv_close(&conv, 0);
#else
iconv_close(conv);
#endif
free(wstr); free(wstr);
return ISO_CHARSET_CONV_ERROR; return ISO_CHARSET_CONV_ERROR;
} }
@ -463,13 +369,8 @@ int str2ascii(const char *icharset, const char *input, char **output)
char *ret; char *ret;
char *ret_; char *ret_;
char *src; char *src;
#ifdef Libisofs_with_iso_iconV
struct iso_iconv_handle conv; struct iso_iconv_handle conv;
int conv_ret; int conv_ret;
#else
iconv_t conv;
#endif
/* That while loop smells like a potential show stopper */ /* That while loop smells like a potential show stopper */
size_t loop_counter = 0, loop_limit = 3; size_t loop_counter = 0, loop_limit = 3;
@ -509,27 +410,14 @@ int str2ascii(const char *icharset, const char *input, char **output)
ret = ret_; ret = ret_;
/* initialize iconv */ /* initialize iconv */
#ifdef Libisofs_with_iso_iconV
conv_ret = iso_iconv_open(&conv, "ASCII", "WCHAR_T", 0); conv_ret = iso_iconv_open(&conv, "ASCII", "WCHAR_T", 0);
if (conv_ret <= 0) { if (conv_ret <= 0) {
#else
conv = iconv_open("ASCII", "WCHAR_T");
if (conv == (iconv_t)-1) {
#endif
free(wsrc_); free(wsrc_);
free(ret_); free(ret_);
goto fallback; goto fallback;
} }
#ifdef Libisofs_with_iso_iconV
n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0); n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0);
#else
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
#endif
while (n == -1) { while (n == -1) {
/* The destination buffer is too small. Stops here. */ /* The destination buffer is too small. Stops here. */
if (errno == E2BIG) if (errno == E2BIG)
@ -563,21 +451,9 @@ int str2ascii(const char *icharset, const char *input, char **output)
loop_counter++; loop_counter++;
if (loop_counter > loop_limit) if (loop_counter > loop_limit)
break; break;
#ifdef Libisofs_with_iso_iconV
n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0); n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0);
#else
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
#endif
} }
#ifdef Libisofs_with_iso_iconV
iso_iconv_close(&conv, 0); iso_iconv_close(&conv, 0);
#else
iconv_close(conv);
#endif
*ret='\0'; *ret='\0';
free(wsrc_); free(wsrc_);
@ -628,13 +504,8 @@ int str2ucs(const char *icharset, const char *input, uint16_t **output)
char *src; char *src;
char *ret; char *ret;
char *ret_; char *ret_;
#ifdef Libisofs_with_iso_iconV
struct iso_iconv_handle conv; struct iso_iconv_handle conv;
int conv_ret; int conv_ret;
#else
iconv_t conv;
#endif
/* That while loop smells like a potential show stopper */ /* That while loop smells like a potential show stopper */
size_t loop_counter = 0, loop_limit = 3; size_t loop_counter = 0, loop_limit = 3;
@ -670,27 +541,14 @@ int str2ucs(const char *icharset, const char *input, uint16_t **output)
ret = ret_; ret = ret_;
/* initialize iconv */ /* initialize iconv */
#ifdef Libisofs_with_iso_iconV
conv_ret = iso_iconv_open(&conv, "UCS-2BE", "WCHAR_T", 0); conv_ret = iso_iconv_open(&conv, "UCS-2BE", "WCHAR_T", 0);
if (conv_ret <= 0) { if (conv_ret <= 0) {
#else
conv = iconv_open("UCS-2BE", "WCHAR_T");
if (conv == (iconv_t)-1) {
#endif
free(wsrc_); free(wsrc_);
free(ret_); free(ret_);
return ISO_CHARSET_CONV_ERROR; return ISO_CHARSET_CONV_ERROR;
} }
#ifdef Libisofs_with_iso_iconV
n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0); n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0);
#else
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
#endif
while (n == -1) { while (n == -1) {
/* The destination buffer is too small. Stops here. */ /* The destination buffer is too small. Stops here. */
if (errno == E2BIG) if (errno == E2BIG)
@ -724,20 +582,9 @@ int str2ucs(const char *icharset, const char *input, uint16_t **output)
loop_counter++; loop_counter++;
if (loop_counter > loop_limit) if (loop_counter > loop_limit)
break; break;
#ifdef Libisofs_with_iso_iconV
n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0); n = iso_iconv(&conv, &src, &inbytes, &ret, &outbytes, 0);
#else
n = iconv(conv, &src, &inbytes, &ret, &outbytes);
#endif
} }
#ifdef Libisofs_with_iso_iconV
iso_iconv_close(&conv, 0); iso_iconv_close(&conv, 0);
#else
iconv_close(conv);
#endif
/* close the ucs string */ /* close the ucs string */
set_ucsbe((uint16_t*) ret, '\0'); set_ucsbe((uint16_t*) ret, '\0');
@ -1566,14 +1413,8 @@ char *ucs2str(const char *buf, size_t len)
{ {
size_t outbytes, inbytes; size_t outbytes, inbytes;
char *str, *src, *out = NULL, *retval = NULL; char *str, *src, *out = NULL, *retval = NULL;
#ifdef Libisofs_with_iso_iconV
struct iso_iconv_handle conv; struct iso_iconv_handle conv;
int conv_ret; int conv_ret;
#else
iconv_t conv;
#endif
size_t n; size_t n;
inbytes = len; inbytes = len;
@ -1584,29 +1425,15 @@ char *ucs2str(const char *buf, size_t len)
out = calloc(outbytes, 1); out = calloc(outbytes, 1);
/* convert to local charset */ /* convert to local charset */
#ifdef Libisofs_with_iso_iconV
conv_ret = iso_iconv_open(&conv, iso_get_local_charset(0), "UCS-2BE", 0); conv_ret = iso_iconv_open(&conv, iso_get_local_charset(0), "UCS-2BE", 0);
if (conv_ret <= 0) { if (conv_ret <= 0) {
#else
conv = iconv_open(iso_get_local_charset(0), "UCS-2BE");
if (conv == (iconv_t)(-1)) {
#endif
goto ex; goto ex;
} }
src = (char *)buf; src = (char *)buf;
str = (char *)out; str = (char *)out;
#ifdef Libisofs_with_iso_iconV
n = iso_iconv(&conv, &src, &inbytes, &str, &outbytes, 0); n = iso_iconv(&conv, &src, &inbytes, &str, &outbytes, 0);
iso_iconv_close(&conv, 0); iso_iconv_close(&conv, 0);
#else
n = iconv(conv, &src, &inbytes, &str, &outbytes);
iconv_close(conv);
#endif
if (n == -1) { if (n == -1) {
/* error */ /* error */
goto ex; goto ex;