From 12cb589d468d6c93b04dfabe645ce761a81c5328 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 8 Sep 2002 17:10:35 +0000 Subject: [PATCH] hbytes compare --- base/chiark-tcl.h | 7 +++++++ base/hook.c | 20 ++++++++++++++++++++ base/tables-examples.tct | 4 ++++ hbytes/hbytes.h | 7 +++++++ hbytes/hook.c | 20 ++++++++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/base/chiark-tcl.h b/base/chiark-tcl.h index 37697bb..4422d32 100644 --- a/base/chiark-tcl.h +++ b/base/chiark-tcl.h @@ -13,6 +13,13 @@ * hbytes chopto VAR NEWVARLENGTH => suffix (removed from VAR) * (too short? error) * + * hbytes compare A B + * => -2 A is lexically earlier than B and not a prefix of B (A worked? (always 1 for p) * hbytes pkcs5 pn|un VAR BLOCKSIZE => worked? (always 1 for p) * hbytes blockcipher d|e VAR ALG KEY MODE [IV] => IV diff --git a/base/hook.c b/base/hook.c index e53af08..8774f7b 100644 --- a/base/hook.c +++ b/base/hook.c @@ -177,6 +177,26 @@ int do_hbytes_zeroes(ClientData cd, Tcl_Interp *ip, return TCL_OK; } +int do_hbytes_compare(ClientData cd, Tcl_Interp *ip, + HBytes_Value a, HBytes_Value b, int *result) { + int al, bl, minl, r; + + al= hbytes_len(&a); + bl= hbytes_len(&b); + minl= al0) *result= +2; + else { + if (albl) *result= +1; + else *result= 0; + } + return TCL_OK; +} + int do__hbytes(ClientData cd, Tcl_Interp *ip, const HBytes_SubCommand *subcmd, int objc, Tcl_Obj *const *objv) { diff --git a/base/tables-examples.tct b/base/tables-examples.tct index 37286ad..6bdc7ff 100644 --- a/base/tables-examples.tct +++ b/base/tables-examples.tct @@ -43,6 +43,10 @@ Table hbytes HBytes_SubCommand length v hb => int + compare + a hb + b hb + => int prepend v hbv str ... diff --git a/hbytes/hbytes.h b/hbytes/hbytes.h index 37697bb..4422d32 100644 --- a/hbytes/hbytes.h +++ b/hbytes/hbytes.h @@ -13,6 +13,13 @@ * hbytes chopto VAR NEWVARLENGTH => suffix (removed from VAR) * (too short? error) * + * hbytes compare A B + * => -2 A is lexically earlier than B and not a prefix of B (A worked? (always 1 for p) * hbytes pkcs5 pn|un VAR BLOCKSIZE => worked? (always 1 for p) * hbytes blockcipher d|e VAR ALG KEY MODE [IV] => IV diff --git a/hbytes/hook.c b/hbytes/hook.c index e53af08..8774f7b 100644 --- a/hbytes/hook.c +++ b/hbytes/hook.c @@ -177,6 +177,26 @@ int do_hbytes_zeroes(ClientData cd, Tcl_Interp *ip, return TCL_OK; } +int do_hbytes_compare(ClientData cd, Tcl_Interp *ip, + HBytes_Value a, HBytes_Value b, int *result) { + int al, bl, minl, r; + + al= hbytes_len(&a); + bl= hbytes_len(&b); + minl= al0) *result= +2; + else { + if (albl) *result= +1; + else *result= 0; + } + return TCL_OK; +} + int do__hbytes(ClientData cd, Tcl_Interp *ip, const HBytes_SubCommand *subcmd, int objc, Tcl_Obj *const *objv) { -- 2.30.2