Changeset 204


Ignore:
Timestamp:
Aug 20, 2002, 10:06:08 AM (18 years ago)
Author:
jkh
Message:

Add in-place string sed function, strsed

Location:
trunk/base/Tcl/port1.0
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/Tcl/port1.0/Pextlib.c

    r203 r204  
    226226}
    227227
     228int StrsedCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
     229{
     230        char *pattern, *string, *res;
     231        Tcl_Obj *tcl_result;
     232
     233        if (objc != 3) {
     234                Tcl_WrongNumArgs(interp, 1, objv, "pattern string");
     235                return TCL_ERROR;
     236        }
     237
     238        pattern = Tcl_GetString(objv[1]);
     239        string = Tcl_GetString(objv[2]);
     240        res = strsed(string, pattern, 0);
     241        if (!res) {
     242                Tcl_SetResult(interp, "strsed failed", TCL_STATIC);
     243                return TCL_ERROR;
     244        }
     245        Tcl_SetResult(interp, res, free);
     246        return TCL_OK;
     247}
     248
    228249int Pextlib_Init(Tcl_Interp *interp)
    229250{
     
    231252        Tcl_CreateObjCommand(interp, "flock", FlockCmd, NULL, NULL);
    232253        Tcl_CreateObjCommand(interp, "readdir", ReaddirCmd, NULL, NULL);
     254        Tcl_CreateObjCommand(interp, "strsed", StrsedCmd, NULL, NULL);
    233255        if(Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
    234256                return TCL_ERROR;
Note: See TracChangeset for help on using the changeset viewer.