summaryrefslogtreecommitdiff
path: root/sys/src/cmd/sed.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-12-31 21:09:46 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2012-12-31 21:09:46 +0100
commit6cadd03bbeace1c256ba875c2e6a877f924877cd (patch)
tree8079ea6f6ccdb1c2cbb2b7813f618837617cb33e /sys/src/cmd/sed.c
parent6d99096136278f06f6333f927da34105a8dfe0bf (diff)
fix utf and rune handling in preparation for 32bit runes
Diffstat (limited to 'sys/src/cmd/sed.c')
-rw-r--r--sys/src/cmd/sed.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/src/cmd/sed.c b/sys/src/cmd/sed.c
index 96c3eb493..790f2ed51 100644
--- a/sys/src/cmd/sed.c
+++ b/sys/src/cmd/sed.c
@@ -625,7 +625,7 @@ compsub(Rune *rhs, Rune *end)
while ((r = *cp++) != '\0') {
if(r == '\\') {
if (rhs < end)
- *rhs++ = 0xFFFF;
+ *rhs++ = Runemax;
else
return 0;
r = *cp++;
@@ -1055,7 +1055,7 @@ dosub(Rune *rhsbuf)
sp = place(sp, loc1, loc2);
continue;
}
- if (c == 0xFFFF && (c = *rp++) >= '1' && c < MAXSUB + '0') {
+ if (c == Runemax && (c = *rp++) >= '1' && c < MAXSUB + '0') {
n = c-'0';
if (subexp[n].rsp && subexp[n].rep) {
sp = place(sp, subexp[n].rsp, subexp[n].rep);
@@ -1336,7 +1336,7 @@ void
arout(void)
{
int c;
- char *s;
+ char *s, *e;
char buf[128];
Rune *p1;
Biobuf *fi;
@@ -1347,7 +1347,7 @@ arout(void)
Bputrune(&fout, *p1);
Bputc(&fout, '\n');
} else {
- for(s = buf, p1 = (*aptr)->text; *p1; p1++)
+ for(s = buf, e = buf+sizeof(buf)-UTFmax-1, p1 = (*aptr)->text; *p1 && s < e; p1++)
s += runetochar(s, p1);
*s = '\0';
if((fi = Bopen(buf, OREAD)) == 0)