From d9089b0f76f5224ffc6d7f52e0cd6d8306820853 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 11 Dec 2006 18:54:10 +0000 Subject: * generic/tclBasic.c: Another step with all sorting operator commands * generic/tclCompExpr.c: now routing through TEBC via * generic/tclCompile.h: TclSortingOpCmd(). --- ChangeLog | 6 ++++++ generic/tclBasic.c | 14 ++++++------- generic/tclCompExpr.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- generic/tclCompile.h | 5 ++++- 4 files changed, 73 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index a48d227..bc93ee3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-12-11 Don Porter + + * generic/tclBasic.c: Another step with all sorting operator commands + * generic/tclCompExpr.c: now routing through TEBC via + * generic/tclCompile.h: TclSortingOpCmd(). + 2006-12-08 Don Porter * generic/tclBasic.c: Another step down the path of re-using diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 8c43737..9f21b3b 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBasic.c,v 1.228 2006/12/08 20:48:08 dgp Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.229 2006/12/11 18:54:10 dgp Exp $ */ #include "tclInt.h" @@ -298,12 +298,12 @@ static const OpCmdInfo mathOpCmds[] = { { "ni", TclSingleOpCmd, TclCompileNiOpCmd, 2, "value list"}, { "-", TclMinusOpCmd, TclCompileMinusOpCmd, 0, NULL }, { "/", TclDivOpCmd, TclCompileDivOpCmd, 0, NULL }, - { "<", TclLessOpCmd, TclCompileLessOpCmd, 0, NULL }, - { "<=", TclLeqOpCmd, TclCompileLeqOpCmd, 0, NULL }, - { ">", TclGreaterOpCmd, TclCompileGreaterOpCmd, 0, NULL }, - { ">=", TclGeqOpCmd, TclCompileGeqOpCmd, 0, NULL }, - { "==", TclEqOpCmd, TclCompileEqOpCmd, 0, NULL }, - { "eq", TclStreqOpCmd, TclCompileStreqOpCmd, 0, NULL }, + { "<", TclSortingOpCmd, TclCompileLessOpCmd, 0, NULL }, + { "<=", TclSortingOpCmd, TclCompileLeqOpCmd, 0, NULL }, + { ">", TclSortingOpCmd, TclCompileGreaterOpCmd, 0, NULL }, + { ">=", TclSortingOpCmd, TclCompileGeqOpCmd, 0, NULL }, + { "==", TclSortingOpCmd, TclCompileEqOpCmd, 0, NULL }, + { "eq", TclSortingOpCmd, TclCompileStreqOpCmd, 0, NULL }, { NULL, NULL, NULL, 0, NULL } }; diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 195f67e..e893390 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompExpr.c,v 1.42 2006/12/08 20:48:09 dgp Exp $ + * RCS: @(#) $Id: tclCompExpr.c,v 1.43 2006/12/11 18:54:11 dgp Exp $ */ #include "tclInt.h" @@ -2637,6 +2637,61 @@ TclSingleOpCmd( return OpCmd(interp, nodes, objv+1); } +int +TclSortingOpCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *const objv[]) +{ + int code = TCL_OK; + + if (objc < 3) { + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(1)); + } else { + TclOpCmdClientData *occdPtr = (TclOpCmdClientData *)clientData; + Tcl_Obj **litObjv = (Tcl_Obj **) ckalloc(2*(objc-2)*sizeof(Tcl_Obj *)); + OpNode *nodes = (OpNode *) ckalloc(2*(objc-2)*sizeof(OpNode)); + unsigned char lexeme; + int i, lastBitAnd = 1; + + ParseLexeme(occdPtr->operator, strlen(occdPtr->operator), + &lexeme, NULL); + + litObjv[0] = objv[1]; + nodes[0].lexeme = START; + for (i=2; i