X-Git-Url: https://pd.if.org/git/?p=pdclib.old;a=blobdiff_plain;f=opt%2Fbasecodecs%2F_PDCLIB_ascii.c;h=a705a7a75b43da5b18e429b681601b0ad7d144dc;hp=ca70a667af84069938925c81605a836c35883317;hb=4fe88a1c445105a96d08b808831d6fc7480a211d;hpb=3d8dbf37294136263403973fec89f50ab9eca402 diff --git a/opt/basecodecs/_PDCLIB_ascii.c b/opt/basecodecs/_PDCLIB_ascii.c index ca70a66..a705a7a 100644 --- a/opt/basecodecs/_PDCLIB_ascii.c +++ b/opt/basecodecs/_PDCLIB_ascii.c @@ -20,10 +20,13 @@ static bool asciitoc32( unsigned char c = **p_inbuf; if(c > 127) return false; - **p_outbuf = c; + + if(p_outbuf) { + **p_outbuf = c; + (*p_outbuf)++; + } (*p_inbuf)++; - (*p_outbuf)++; (*p_insz)--; (*p_outsz)--; } @@ -42,15 +45,24 @@ static bool c32toascii( char32_t c = **p_inbuf; if(c > 127) 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 _PDCLIB_ascii_codec = { + .__mbstoc32s = asciitoc32, + .__c32stombs = c32toascii, +}; + #endif #ifdef TEST