X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=opt%2Fbasecodecs%2F_PDCLIB_latin1.c;h=29903606db810648ad2a9b19cbd6bfc3c6945c69;hb=0e35e82c5e9a0804864839e8fc0e985b1ae41f07;hp=73844f417b6aa32587cf5f1e03346d6330d0e0e1;hpb=d70d75f5f46047f7546b14f424cccad7316bff6a;p=pdclib.old diff --git a/opt/basecodecs/_PDCLIB_latin1.c b/opt/basecodecs/_PDCLIB_latin1.c index 73844f4..2990360 100644 --- a/opt/basecodecs/_PDCLIB_latin1.c +++ b/opt/basecodecs/_PDCLIB_latin1.c @@ -7,6 +7,7 @@ #include #ifndef REGTEST #include +#include <_PDCLIB_encoding.h> static bool latin1toc32( char32_t **restrict p_outbuf, @@ -18,10 +19,13 @@ static bool latin1toc32( { while(*p_outsz && *p_insz) { unsigned char c = **p_inbuf; - **p_outbuf = c; + + if(p_outbuf) { + **p_outbuf = c; + (*p_outbuf)++; + } (*p_inbuf)++; - (*p_outbuf)++; (*p_insz)--; (*p_outsz)--; } @@ -40,15 +44,24 @@ static bool c32tolatin1( char32_t c = **p_inbuf; if(c > 255) return false; - **p_outbuf = c; + + if(p_outbuf) { + **p_outbuf = c; + (*p_outbuf)++; + } (*p_inbuf)++; - (*p_outbuf)++; (*p_insz)--; (*p_outsz)--; } return true; } + +_PDCLIB_charcodec_t _PDCLIB_latin1_codec = { + .__mbstoc32s = latin1toc32, + .__c32stombs = c32tolatin1, +}; + #endif #ifdef TEST