chiark / gitweb /
does modexps, makes signatures, needs sane hexstring handling
authorian <ian>
Wed, 11 Sep 2002 01:58:36 +0000 (01:58 +0000)
committerian <ian>
Wed, 11 Sep 2002 01:58:36 +0000 (01:58 +0000)
base/chiark-tcl.h
base/hook.c
base/tables-examples.tct
hbytes/hbytes.h
hbytes/hook.c

index 23cad209c11840758e99052d62198efd632bca04..f482cc57f0e99ee63593eb271f5eca266aed0ea1 100644 (file)
@@ -15,6 +15,7 @@
  *
  *  hbytes range VALUE START SIZE                => substring (or error)
  *  hbytes overwrite VAR START VALUE
  *
  *  hbytes range VALUE START SIZE                => substring (or error)
  *  hbytes overwrite VAR START VALUE
+ *  hbytes trimleft VALUE                        removes any leading 0 octets
  *  hbytes repeat VALUE COUNT                    => COUNT copies of VALUE
  *
  *  hbytes h2ulong HEX                           => ulong  (HEX len must be 4)
  *  hbytes repeat VALUE COUNT                    => COUNT copies of VALUE
  *
  *  hbytes h2ulong HEX                           => ulong  (HEX len must be 4)
index f364978c200db68dde9b2ba53c0a3e8faa898533..0adb6b5d5804bb54e7669ef485987a69fb38a9a9 100644 (file)
@@ -210,6 +210,18 @@ int do_hbytes_overwrite(ClientData cd, Tcl_Interp *ip,
   return TCL_OK;
 }
 
   return TCL_OK;
 }
 
+int do_hbytes_trimleft(ClientData cd, Tcl_Interp *ip, HBytes_Var v) {
+  const Byte *o, *p, *e;
+  o= p= hbytes_data(v.hb);
+  e= p + hbytes_len(v.hb);
+
+  while (p<e && !*p) p++;
+  if (p != o)
+    hbytes_unprepend(v.hb, p-o);
+
+  return TCL_OK;
+}
+
 int do_hbytes_repeat(ClientData cd, Tcl_Interp *ip,
                     HBytes_Value sub, int count, HBytes_Value *result) {
   int sub_l;
 int do_hbytes_repeat(ClientData cd, Tcl_Interp *ip,
                     HBytes_Value sub, int count, HBytes_Value *result) {
   int sub_l;
index f2146a552c6dc23b1c3518ce7604a415c27ca09a..d2e00384f7af16f552ff4c2f2d5c140336892be3 100644 (file)
@@ -112,6 +112,8 @@ Table hbytes HBytes_SubCommand
                v       hbv
                start   int
                sub     hb
                v       hbv
                start   int
                sub     hb
+       trimleft
+               v       hbv
        zeroes
                length  int
                =>      hb
        zeroes
                length  int
                =>      hb
index 23cad209c11840758e99052d62198efd632bca04..f482cc57f0e99ee63593eb271f5eca266aed0ea1 100644 (file)
@@ -15,6 +15,7 @@
  *
  *  hbytes range VALUE START SIZE                => substring (or error)
  *  hbytes overwrite VAR START VALUE
  *
  *  hbytes range VALUE START SIZE                => substring (or error)
  *  hbytes overwrite VAR START VALUE
+ *  hbytes trimleft VALUE                        removes any leading 0 octets
  *  hbytes repeat VALUE COUNT                    => COUNT copies of VALUE
  *
  *  hbytes h2ulong HEX                           => ulong  (HEX len must be 4)
  *  hbytes repeat VALUE COUNT                    => COUNT copies of VALUE
  *
  *  hbytes h2ulong HEX                           => ulong  (HEX len must be 4)
index f364978c200db68dde9b2ba53c0a3e8faa898533..0adb6b5d5804bb54e7669ef485987a69fb38a9a9 100644 (file)
@@ -210,6 +210,18 @@ int do_hbytes_overwrite(ClientData cd, Tcl_Interp *ip,
   return TCL_OK;
 }
 
   return TCL_OK;
 }
 
+int do_hbytes_trimleft(ClientData cd, Tcl_Interp *ip, HBytes_Var v) {
+  const Byte *o, *p, *e;
+  o= p= hbytes_data(v.hb);
+  e= p + hbytes_len(v.hb);
+
+  while (p<e && !*p) p++;
+  if (p != o)
+    hbytes_unprepend(v.hb, p-o);
+
+  return TCL_OK;
+}
+
 int do_hbytes_repeat(ClientData cd, Tcl_Interp *ip,
                     HBytes_Value sub, int count, HBytes_Value *result) {
   int sub_l;
 int do_hbytes_repeat(ClientData cd, Tcl_Interp *ip,
                     HBytes_Value sub, int count, HBytes_Value *result) {
   int sub_l;