mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-28 21:02:38 +00:00
simplify iconv_convert() a bit (exit early on error)
This commit is contained in:
parent
938af98ff3
commit
d9dbd528c4
@ -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);
|
||||||
@ -109,7 +111,6 @@ void iconv_convert(size_t *a, char *buff_in, char *p, size_t p_max_size)
|
|||||||
//a = outptr - p;
|
//a = outptr - p;
|
||||||
//(*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)
|
||||||
|
Loading…
Reference in New Issue
Block a user