respect snarf length

This commit is contained in:
Russ Cox 2007-01-28 16:10:13 +00:00
parent ffc8608e72
commit c0963c9a12

View File

@ -629,7 +629,7 @@ clipread(void)
CFIndex length = CFDataGetLength(cfdata); CFIndex length = CFDataGetLength(cfdata);
if (length > sizeof rsnarf) length = sizeof rsnarf; if (length > sizeof rsnarf) length = sizeof rsnarf;
CFDataGetBytes(cfdata, CFRangeMake(0, length), (uint8_t *)rsnarf); CFDataGetBytes(cfdata, CFRangeMake(0, length), (uint8_t *)rsnarf);
snprint(snarf, sizeof snarf, "%S", rsnarf); snprint(snarf, sizeof snarf, "%.*S", length, rsnarf);
char *s = snarf; char *s = snarf;
while (*s) { while (*s) {
if (*s == '\r') *s = '\n'; if (*s == '\r') *s = '\n';