mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-01-24 02:51:43 +01:00
Update vis and unvis modules from OpenBSD
This commit is contained in:
parent
8103fe1486
commit
7b3873bc1e
@ -235,7 +235,7 @@ strunvis(char *dst, const char *src)
|
|||||||
char *start = dst;
|
char *start = dst;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
|
|
||||||
while ( (c = *src++) ) {
|
while ((c = *src++)) {
|
||||||
again:
|
again:
|
||||||
switch (unvis(dst, c, &state, 0)) {
|
switch (unvis(dst, c, &state, 0)) {
|
||||||
case UNVIS_VALID:
|
case UNVIS_VALID:
|
||||||
@ -248,6 +248,7 @@ strunvis(char *dst, const char *src)
|
|||||||
case UNVIS_NOCHAR:
|
case UNVIS_NOCHAR:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
*dst = '\0';
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,8 +305,8 @@ strunvisx(char *dst, const char *src, int flag)
|
|||||||
char c;
|
char c;
|
||||||
char *start = dst;
|
char *start = dst;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
|
|
||||||
while ( (c = *src++) ) {
|
while ((c = *src++)) {
|
||||||
again:
|
again:
|
||||||
switch (unvis(dst, c, &state, flag)) {
|
switch (unvis(dst, c, &state, flag)) {
|
||||||
case UNVIS_VALID:
|
case UNVIS_VALID:
|
||||||
|
17
src/vis.c
17
src/vis.c
@ -50,10 +50,7 @@
|
|||||||
* vis - visually encode characters
|
* vis - visually encode characters
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
vis(dst, c, flag, nextc)
|
vis(char *dst, int c, int flag, int nextc)
|
||||||
char *dst;
|
|
||||||
int c, nextc;
|
|
||||||
int flag;
|
|
||||||
{
|
{
|
||||||
c = (unsigned char)c;
|
c = (unsigned char)c;
|
||||||
|
|
||||||
@ -173,10 +170,7 @@ done:
|
|||||||
* This is useful for encoding a block of data.
|
* This is useful for encoding a block of data.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
strvis(dst, src, flag)
|
strvis(char *dst, const char *src, int flag)
|
||||||
char *dst;
|
|
||||||
const char *src;
|
|
||||||
int flag;
|
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
char *start;
|
char *start;
|
||||||
@ -231,11 +225,8 @@ strnvis(char *dst, const char *src, size_t siz, int flag)
|
|||||||
return (dst - start);
|
return (dst - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
strvisx(dst, src, len, flag)
|
int
|
||||||
char *dst;
|
strvisx(char *dst, const char *src, size_t len, int flag)
|
||||||
const char *src;
|
|
||||||
size_t len;
|
|
||||||
int flag;
|
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
char *start;
|
char *start;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user