chiark / gitweb /
scriptinv is correct about not leaking xargs. do not pointlessly trash the args...
[chiark-tcl.git] / hbytes / parse.c
index 1d9123876097e82940bcb2e014a9772290322254..0fa5acdd4705d942ca158f5475e1691b5651e5ac 100644 (file)
@@ -23,6 +23,23 @@ int pat_string(Tcl_Interp *ip, Tcl_Obj *obj, const char **val) {
   return TCL_OK;
 }
 
+int pat_constv(Tcl_Interp *ip, Tcl_Obj *var,
+              Tcl_Obj **val_r, Tcl_ObjType *type) {
+  int rc;
+  Tcl_Obj *val;
+  
+  val= Tcl_ObjGetVar2(ip,var,0,TCL_LEAVE_ERR_MSG);
+  if (!val) return TCL_ERROR;
+
+  if (type) {
+    rc= Tcl_ConvertToType(ip,val,type);
+    if (rc) return rc;
+  }
+
+  *val_r= val;
+  return TCL_OK;
+}
+
 void init_somethingv(Something_Var *sth) {
   sth->obj=0; sth->var=0; sth->copied=0;
 }