+
+/*
+ * strvis - visually encode characters from src into dst
+ *
+ * If len >= 0, encodes exactly len chars from src (including NULL's).
+ * Otherwise, stops before first NULL in src. In all cases, dst is
+ * NULL terminated.
+ *
+ * Dst must be 4 times the size of src to account for possible
+ * expansion. The length of dst, not including the trailing NULL,
+ * is returned.
+ */
+strvis(dst, src, len, flag)
+ register char *dst, *src;
+ register int len;
+{
+ char *start = dst;
+
+ for (;;) {
+ if (len > 0) {
+ if (len-- == 0)
+ break;
+ } else if (!*src)
+ break;
+ dst = vis(dst, *src, flag | VIS_NEXTC, *(src+1));
+ src++;
+ }
+
+ return (dst - start);
+}