Update vis and unvis modules from OpenBSD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
diff --git a/src/unvis.c b/src/unvis.c
index 188edca..53da64b 100644
--- a/src/unvis.c
+++ b/src/unvis.c
@@ -235,7 +235,7 @@ strunvis(char *dst, const char *src)
char *start = dst;
int state = 0;
- while ( (c = *src++) ) {
+ while ((c = *src++)) {
again:
switch (unvis(dst, c, &state, 0)) {
case UNVIS_VALID:
@@ -248,6 +248,7 @@ strunvis(char *dst, const char *src)
case UNVIS_NOCHAR:
break;
default:
+ *dst = '\0';
return (-1);
}
}
@@ -304,8 +305,8 @@ strunvisx(char *dst, const char *src, int flag)
char c;
char *start = dst;
int state = 0;
-
- while ( (c = *src++) ) {
+
+ while ((c = *src++)) {
again:
switch (unvis(dst, c, &state, flag)) {
case UNVIS_VALID:
diff --git a/src/vis.c b/src/vis.c
index 189fde8..6153a7f 100644
--- a/src/vis.c
+++ b/src/vis.c
@@ -50,10 +50,7 @@
* vis - visually encode characters
*/
char *
-vis(dst, c, flag, nextc)
- char *dst;
- int c, nextc;
- int flag;
+vis(char *dst, int c, int flag, int nextc)
{
c = (unsigned char)c;
@@ -173,10 +170,7 @@ done:
* This is useful for encoding a block of data.
*/
int
-strvis(dst, src, flag)
- char *dst;
- const char *src;
- int flag;
+strvis(char *dst, const char *src, int flag)
{
char c;
char *start;
@@ -231,11 +225,8 @@ strnvis(char *dst, const char *src, size_t siz, int flag)
return (dst - start);
}
-strvisx(dst, src, len, flag)
- char *dst;
- const char *src;
- size_t len;
- int flag;
+int
+strvisx(char *dst, const char *src, size_t len, int flag)
{
int c;
char *start;