summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rw-r--r--appl/lib/convcs/utf16_btos.b66
-rw-r--r--appl/lib/convcs/utf16_stob.b47
-rw-r--r--dis/lib/convcs/utf16_btos.disbin0 -> 533 bytes
-rw-r--r--dis/lib/convcs/utf16_stob.disbin0 -> 433 bytes
-rw-r--r--utils/NOTICE2
6 files changed, 118 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 99299a87..c871fe5f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+20070131
+ add /appl/lib/convcs/utf16_btos.b, utf16_stob.b etc [rog]
+20070130
+ fix wording in some of the licence files (eg, remove references to old liberal licence)
20070123
check lengths properly in devenv.c
move all of doc into lib/proto/inferno from lib/proto/src
diff --git a/appl/lib/convcs/utf16_btos.b b/appl/lib/convcs/utf16_btos.b
new file mode 100644
index 00000000..c08e04eb
--- /dev/null
+++ b/appl/lib/convcs/utf16_btos.b
@@ -0,0 +1,66 @@
+implement Btos;
+
+include "sys.m";
+include "convcs.m";
+
+Littleendian, Bigendian: con iota;
+
+sys : Sys;
+default := Bigendian;
+
+init(arg : string) : string
+{
+ sys = load Sys Sys->PATH;
+ case arg {
+ "le" =>
+ default = Littleendian;
+ "be" =>
+ default = Bigendian;
+ }
+ return nil;
+}
+
+
+btos(state : Convcs->State, b : array of byte, n : int) : (Convcs->State, string, int)
+{
+ endian: int;
+ i := 0;
+ if(state != nil)
+ endian = state[0];
+ else if (len b >= 2) {
+ state = " ";
+ # XXX should probably not do this if we've been told the endianness
+ case (int b[0] << 8) | int b[1] {
+ 16rfeff =>
+ endian = Bigendian;
+ i += 2;
+ 16rfffe =>
+ endian = Littleendian;
+ i += 2;
+ * =>
+ endian = guessendian(b);
+ }
+ state[0] = endian;
+ }
+ nb := len b & ~1;
+ if(n > 0 && nb - i > n * 2)
+ nb = i + n * 2;
+ out := "";
+ if(endian == Bigendian){
+ for(; i < nb; i += 2)
+ out[len out] = (int b[i] << 8) | int b[i + 1];
+ }else{
+ for(; i < nb; i += 2)
+ out[len out] = int b[i] | int b[i + 1] << 8;
+ }
+ if(n == 0 && i < len b)
+ out[len out] = Sys->UTFerror;
+
+ return (state, out, i);
+}
+
+guessendian(nil: array of byte): int
+{
+ # XXX might be able to do better than this in the absence of endian hints.
+ return default;
+}
diff --git a/appl/lib/convcs/utf16_stob.b b/appl/lib/convcs/utf16_stob.b
new file mode 100644
index 00000000..312add88
--- /dev/null
+++ b/appl/lib/convcs/utf16_stob.b
@@ -0,0 +1,47 @@
+implement Stob;
+
+include "sys.m";
+ sys: Sys;
+include "convcs.m";
+
+bigendian := 1;
+header := 1;
+
+init(arg : string) : string
+{
+ sys = load Sys Sys->PATH;
+ case arg {
+ "le" =>
+ bigendian = 0;
+ header = 0;
+ "be" =>
+ header = 0;
+ }
+ return nil;
+}
+
+stob(state : Convcs->State, s : string) : (Convcs->State, array of byte)
+{
+ if(state == nil){
+ if(header)
+ s = sys->sprint("%c", 16rfeff) + s;
+ state = "doneheader";
+ }
+
+ b := array[len s * 2] of byte;
+ j := 0;
+ if(bigendian){
+ for(i := 0; i < len s; i++){
+ c := s[i];
+ b[j++] = byte (c >> 8);
+ b[j++] = byte c;
+ }
+ }else{
+ for(i := 0; i < len s; i++){
+ c := s[i];
+ b[j++] = byte c;
+ b[j++] = byte (c >> 8);
+ }
+ }
+ return (state, b);
+}
diff --git a/dis/lib/convcs/utf16_btos.dis b/dis/lib/convcs/utf16_btos.dis
new file mode 100644
index 00000000..945b144c
--- /dev/null
+++ b/dis/lib/convcs/utf16_btos.dis
Binary files differ
diff --git a/dis/lib/convcs/utf16_stob.dis b/dis/lib/convcs/utf16_stob.dis
new file mode 100644
index 00000000..fde1a69e
--- /dev/null
+++ b/dis/lib/convcs/utf16_stob.dis
Binary files differ
diff --git a/utils/NOTICE b/utils/NOTICE
index 23704de9..682cb8cd 100644
--- a/utils/NOTICE
+++ b/utils/NOTICE
@@ -12,7 +12,7 @@ file such as NOTICE, LICENCE or COPYING.
Portions Copyright © 2000-2006 Vita Nuova Holdings Limited (www.vitanuova.com)
Portions Copyright © 2004,2006 Bruce Ellis
Portions Copyright © 2006,2006 C H Forsyth (forsyth@terzarima.net)
- Revisions Copyright © 2000-2006 Lucent Technologies Inc. and others
+ Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal