Mercurial > hg > sidinfo
changeset 357:199284ba94ea
Cleanup and few comments added.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 27 Jan 2020 02:33:13 +0200 |
parents | 811eb6c6695e |
children | a5131cd64110 |
files | sidutil.c |
diffstat | 1 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/sidutil.c Mon Jan 27 02:32:59 2020 +0200 +++ b/sidutil.c Mon Jan 27 02:33:13 2020 +0200 @@ -162,9 +162,14 @@ }; +#define SI_PUTCH(xch) th_strbuf_putch(&outBuf, &outSize, &outLen, (xch)) + + +// +// Convert _ONLY_ FROM ISO-8859-1 encoding to few other encodings +// static char *sidutil_chconv_internal(SIDUtilChConvCtx *ctx, const char *src) { - // Fallback conversion of ISO-8859-1 to X const uint8_t *srcPtr = (const uint8_t *) src; const uint8_t *convTable; size_t outSize, outLen; @@ -185,26 +190,26 @@ // Not 100% correct really, but close enough if (*srcPtr < 0x80) { - if (!th_strbuf_putch(&outBuf, &outSize, &outLen, *srcPtr)) + if (!SI_PUTCH(*srcPtr)) goto err; } else if (*srcPtr < 0xBF) { - if (!th_strbuf_putch(&outBuf, &outSize, &outLen, 0xC2) || - !th_strbuf_putch(&outBuf, &outSize, &outLen, *srcPtr)) + if (!SI_PUTCH(0xC2) || + !SI_PUTCH(*srcPtr)) goto err; } else { - if (!th_strbuf_putch(&outBuf, &outSize, &outLen, 0xC3) || - !th_strbuf_putch(&outBuf, &outSize, &outLen, *srcPtr - 0x40)) + if (!SI_PUTCH(0xC3) || + !SI_PUTCH(*srcPtr - 0x40)) goto err; } break; case TH_LANG_ISO88591: - if (!th_strbuf_putch(&outBuf, &outSize, &outLen, *srcPtr)) + if (!SI_PUTCH(*srcPtr)) goto err; break; @@ -224,13 +229,13 @@ else outByte = '?'; - if (!th_strbuf_putch(&outBuf, &outSize, &outLen, outByte)) + if (!SI_PUTCH(outByte)) goto err; break; } } - if (!th_strbuf_putch(&outBuf, &outSize, &outLen, *srcPtr)) + if (!SI_PUTCH(*srcPtr)) goto err; return outBuf;