1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-29 05:12:41 +00:00

simplify iconv_convert() a bit (exit early on error)

This commit is contained in:
Phil Sutter 2009-11-29 14:28:30 +01:00
parent 938af98ff3
commit d9dbd528c4

View File

@ -79,8 +79,6 @@ void free_iconv(struct text_object *obj)
void iconv_convert(size_t *a, char *buff_in, char *p, size_t p_max_size) void iconv_convert(size_t *a, char *buff_in, char *p, size_t p_max_size)
{ {
if (*a > 0 && iconv_converting && iconv_selected > 0
&& (iconv_cd[iconv_selected - 1] != (iconv_t) (-1))) {
int bytes; int bytes;
size_t dummy1, dummy2; size_t dummy1, dummy2;
#ifdef __FreeBSD__ #ifdef __FreeBSD__
@ -90,6 +88,10 @@ void iconv_convert(size_t *a, char *buff_in, char *p, size_t p_max_size)
#endif #endif
char *outptr = p; char *outptr = p;
if (*a <= 0 || !iconv_converting || iconv_selected <= 0
|| iconv_cd[iconv_selected - 1] == (iconv_t) (-1))
return;
dummy1 = dummy2 = *a; dummy1 = dummy2 = *a;
strncpy(buff_in, p, p_max_size); strncpy(buff_in, p, p_max_size);
@ -110,7 +112,6 @@ void iconv_convert(size_t *a, char *buff_in, char *p, size_t p_max_size)
//(*a) = *a - dummy2; //(*a) = *a - dummy2;
(*a) = outptr - p; (*a) = outptr - p;
} }
}
void init_iconv_start(struct text_object *obj, void *free_at_crash, const char *arg) void init_iconv_start(struct text_object *obj, void *free_at_crash, const char *arg)
{ {