View | Details | Raw Unified | Return to bug 38152
Collapse All | Expand All

(-)util.c (-8 / +28 lines)
Lines 52-57 Link Here
52
#include <stdio.h>
52
#include <stdio.h>
53
#include <stdlib.h>
53
#include <stdlib.h>
54
#include <string.h>
54
#include <string.h>
55
#include <rune.h>
56
#include <wctype.h>
55
57
56
#include "ls.h"
58
#include "ls.h"
57
#include "extern.h"
59
#include "extern.h"
Lines 60-74 Link Here
60
prn_printable(s)
62
prn_printable(s)
61
	const char *s;
63
	const char *s;
62
{
64
{
63
	unsigned char c;
65
	const char *p1, *p2;
64
	int n;
66
	char *r, *ri;
67
	int len, dc;
68
	rune_t c;
65
69
66
	for (n = 0; (c = *s) != '\0'; ++s, ++n)
70
	p1 = s;
67
		if (isprint(c))
71
	dc = len = strlen(s);
68
			putchar(c);
72
	ri = r = (char *)malloc(len + 1);
69
		else
73
	while(*p1 != 0) {
70
			putchar('?');
74
		c = sgetrune(p1, dc, &p2);
71
	return n;
75
		if(c == _INVALID_RUNE) {
76
			p1++;
77
			dc--;
78
			*ri++ = '?';
79
		} else {
80
			dc -= p2 - p1;
81
			if(isprint(c))
82
				while(p1 != p2)
83
					*ri++ = *p1++;
84
			else
85
				while(p1 != p2)
86
					*ri++ = '?';
87
		}
88
	}
89
	*ri = 0;
90
	printf("%s", r);
91
	return len;
72
}
92
}
73
93
74
/*
94
/*

Return to bug 38152