Ejemplo n.º 1
0
        private static void addFileToResult(Interp interp, string fileName, string separators, TclObject resultList)
        {
            string prettyFileName = fileName;
            int    prettyLen      = fileName.Length;

            // Java IO reuqires Windows volumes [A-Za-z]: to be followed by '\\'.

            if ((JACL.PLATFORM == JACL.PLATFORM_WINDOWS) && (prettyLen >= 2) && (fileName[1] == ':'))
            {
                if (prettyLen == 2)
                {
                    fileName = fileName + '\\';
                }
                else if (fileName[2] != '\\')
                {
                    fileName = fileName.Substring(0, (2) - (0)) + '\\' + fileName.Substring(2);
                }
            }

            TclObject[] arrayObj = TclList.getElements(interp, FileUtil.splitAndTranslate(interp, fileName));
            fileName = FileUtil.joinPath(interp, arrayObj, 0, arrayObj.Length);

            FileInfo f;

            if (FileUtil.getPathType(fileName) == FileUtil.PATH_ABSOLUTE)
            {
                f = FileUtil.getNewFileObj(interp, fileName);
            }
            else
            {
                f = new FileInfo(interp.getWorkingDir().FullName + "\\" + fileName);
            }

            // If the last character is a spearator, make sure the file is an
            // existing directory, otherwise check that the file exists.

            if ((prettyLen > 0) && (separators.IndexOf((System.Char)prettyFileName[prettyLen - 1]) != -1))
            {
                if (Directory.Exists(f.FullName))
                {
                    TclList.append(interp, resultList, TclString.newInstance(prettyFileName));
                }
            }
            else
            {
                bool tmpBool;
                if (File.Exists(f.FullName))
                {
                    tmpBool = true;
                }
                else
                {
                    tmpBool = Directory.Exists(f.FullName);
                }
                if (tmpBool)
                {
                    TclList.append(interp, resultList, TclString.newInstance(prettyFileName));
                }
            }
        }
Ejemplo n.º 2
0
        public TclPosixException(Interp interp, int errno, bool appendPosixMsg, string errorMsg)
            : base(TCL.CompletionCode.ERROR)
        {
            string msg = getPosixMsg(errno);

            TclObject threeEltListObj = TclList.newInstance();

            TclList.append(interp, threeEltListObj, TclString.newInstance("POSIX"));
            TclList.append(interp, threeEltListObj, TclString.newInstance(getPosixId(errno)));
            TclList.append(interp, threeEltListObj, TclString.newInstance(msg));

            interp.setErrorCode(threeEltListObj);

            if (interp != null)
            {
                if (appendPosixMsg)
                {
                    interp.setResult(errorMsg + ": " + msg);
                }
                else
                {
                    interp.setResult(errorMsg);
                }
            }
        }
Ejemplo n.º 3
0
        /*
         *----------------------------------------------------------------------
         *
         * AppendLocals --
         *
         *	Append the local variables for the current frame to the
         *	specified list object.
         *
         * Results:
         *	None.
         *
         * Side effects:
         *	None.
         *
         *----------------------------------------------------------------------
         */

        private static void AppendLocals(Interp interp, TclObject list, string pattern, bool includeLinks)
        {
            Var                   var;
            string                varName;
            Hashtable             localVarTable;
            IDictionaryEnumerator search;

            localVarTable = interp.varFrame.varTable;

            // Compiled locals do not exist in Jacl

            if (localVarTable != null)
            {
                for (search = localVarTable.GetEnumerator(); search.MoveNext();)
                {
                    var     = (Var)search.Value;
                    varName = (string)search.Key;
                    if (!var.isVarUndefined() && (includeLinks || !var.isVarLink()))
                    {
                        if (((System.Object)pattern == null) || Util.stringMatch(varName, pattern))
                        {
                            TclList.append(interp, list, TclString.newInstance(varName));
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /*
         *----------------------------------------------------------------------
         *
         * InfoArgsCmd --
         *
         *      Called to implement the "info args" command that returns the
         *      argument list for a procedure. Handles the following syntax:
         *
         *          info args procName
         *
         * Results:
         *      Returns if successful, raises TclException otherwise.
         *
         * Side effects:
         *      Returns a result in the interpreter's result object.
         *
         *----------------------------------------------------------------------
         */

        private static void InfoArgsCmd(Interp interp, TclObject[] objv)
        {
            string    name;
            Procedure proc;
            TclObject listObj;

            if (objv.Length != 3)
            {
                throw new TclNumArgsException(interp, 2, objv, "procname");
            }

            name = objv[2].ToString();
            proc = Procedure.findProc(interp, name);
            if (proc == null)
            {
                throw new TclException(interp, "\"" + name + "\" isn't a procedure");
            }

            // Build a return list containing the arguments.

            listObj = TclList.newInstance();
            for (int i = 0; i < proc.argList.Length; i++)
            {
                TclObject s = TclString.newInstance(proc.argList[i][0]);
                TclList.append(interp, listObj, s);
            }
            interp.setResult(listObj);
            return;
        }
Ejemplo n.º 5
0
        internal BgErrorMgr(Interp i)
        {
            InitBlock();
            interp        = i;
            bgerrorCmdObj = TclString.newInstance("bgerror");
            bgerrorCmdObj.preserve();

            errors = new ArrayList(10);
        }
Ejemplo n.º 6
0
        /// <summary> This procedure is invoked to process the "gets" Tcl command.
        /// See the user documentation for details on what it does.
        ///
        /// </summary>
        /// <param name="interp">the current interpreter.
        /// </param>
        /// <param name="argv">command arguments.
        /// </param>

        public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
        {
            bool      writeToVar = false; // If true write to var passes as arg
            string    varName    = "";    // The variable to write value to
            Channel   chan;               // The channel being operated on
            int       lineLen;
            TclObject line;

            if ((argv.Length < 2) || (argv.Length > 3))
            {
                throw new TclNumArgsException(interp, 1, argv, "channelId ?varName?");
            }

            if (argv.Length == 3)
            {
                writeToVar = true;

                varName = argv[2].ToString();
            }


            chan = TclIO.getChannel(interp, argv[1].ToString());
            if (chan == null)
            {
                throw new TclException(interp, "can not find channel named \"" + argv[1].ToString() + "\"");
            }

            try
            {
                line    = TclString.newInstance(new StringBuilder(64));
                lineLen = chan.read(interp, line, TclIO.READ_LINE, 0);
                if (lineLen < 0)
                {
                    // FIXME: Need more specific posix error codes!
                    if (!chan.eof() && !chan.isBlocked(interp))
                    {
                        throw new TclPosixException(interp, TclPosixException.EIO, true, "error reading \"" + argv[1].ToString() + "\"");
                    }
                    lineLen = -1;
                }
                if (writeToVar)
                {
                    interp.setVar(varName, line, 0);
                    interp.setResult(lineLen);
                }
                else
                {
                    interp.setResult(line);
                }
            }
            catch (IOException e)
            {
                throw new TclRuntimeError("GetsCmd.cmdProc() Error: IOException when getting " + chan.ChanName + ": " + e.Message);
            }
            return(TCL.CompletionCode.RETURN);
        }
Ejemplo n.º 7
0
        /*
         *----------------------------------------------------------------------
         *
         * InfoLevelCmd --
         *
         *      Called to implement the "info level" command that returns
         *      information about the call stack. Handles the following syntax:
         *
         *          info level ?number?
         *
         * Results:
         *      Returns if successful, raises TclException otherwise.
         *
         * Side effects:
         *      Returns a result in the interpreter's result object.
         *
         *----------------------------------------------------------------------
         */

        private static void InfoLevelCmd(Interp interp, TclObject[] objv)
        {
            int       level;
            CallFrame frame;
            TclObject list;

            if (objv.Length == 2)
            {
                // just "info level"
                if (interp.varFrame == null)
                {
                    interp.setResult(0);
                }
                else
                {
                    interp.setResult(interp.varFrame.level);
                }
                return;
            }
            else if (objv.Length == 3)
            {
                level = TclInteger.get(interp, objv[2]);

                if (level <= 0)
                {
                    if (interp.varFrame == null)
                    {
                        throw new TclException(interp, "bad level \"" + objv[2].ToString() + "\"");
                    }

                    level += interp.varFrame.level;
                }

                for (frame = interp.varFrame; frame != null; frame = frame.callerVar)
                {
                    if (frame.level == level)
                    {
                        break;
                    }
                }
                if ((frame == null) || frame.objv == null)
                {
                    throw new TclException(interp, "bad level \"" + objv[2].ToString() + "\"");
                }

                list = TclList.newInstance();
                for (int i = 0; i < frame.objv.Length; i++)
                {
                    TclList.append(interp, list, TclString.newInstance(frame.objv[i]));
                }
                interp.setResult(list);
                return;
            }

            throw new TclNumArgsException(interp, 2, objv, "?number?");
        }
Ejemplo n.º 8
0
        public static TclObject Tcl_GetVar2Ex(Interp interp, string part1, string part2, VarFlag flags)
        {
            try
            {
                Var[] result = Var.lookupVar(interp, part1, part2, flags, "read", false, true);
                if (result == null)
                {
                    // lookupVar() returns null only if VarFlag.LEAVE_ERR_MSG is
                    // not part of the flags argument, return null in this case.

                    return(null);
                }

                Var       var   = result[0];
                Var       array = result[1];
                TclObject to    = null;

                if (var.isVarScalar() && !var.isVarUndefined())
                {
                    to = (TclObject)var.value;
                    //if ( to.typePtr != "String" )
                    //{
                    //  double D = 0;
                    //  if ( !Double.TryParse( to.ToString(), out D ) ) { if ( String.IsNullOrEmpty( to.typePtr ) ) to.typePtr = "string"; }
                    //  else if ( to.typePtr == "ByteArray" )
                    //    to.typePtr = "bytearray";
                    //  else if ( to.ToString().Contains( "." ) )
                    //    to.typePtr = "double";
                    //  else
                    //    to.typePtr = "int";
                    //}
                    return(to);
                }
                else if (var.isSQLITE3_Link())
                {
                    to = (TclObject)var.sqlite3_get();
                }
                else
                {
                    to = TclList.newInstance();
                    foreach (string key in ((Hashtable)array.value).Keys)
                    {
                        Var s = (Var)((Hashtable)array.value)[key];
                        if (s.value != null)
                        {
                            TclList.append(null, to, TclString.newInstance(s.value.ToString()));
                        }
                    }
                }
                return(to);
            }
            catch (Exception e)
            {
                return(null);
            };
        }
 public static TclObject Tcl_NewStringObj(byte[] value, int iLength)
 {
     if (iLength > 0 && iLength < value.Length)
     {
         return(TclString.newInstance(Encoding.UTF8.GetString(value, 0, iLength)));
     }
     else
     {
         return(TclString.newInstance(Encoding.UTF8.GetString(value)));
     }
 }
Ejemplo n.º 10
0
 private TclObject getCmdObject(TclObject[] argv)
 // Argument list passed to the "after" command.
 {
     if (argv.Length == 3)
     {
         return(argv[2]);
     }
     else
     {
         TclObject cmd = TclString.newInstance(Util.concat(2, argv.Length - 1, argv));
         return(cmd);
     }
 }
Ejemplo n.º 11
0
        /*
         *----------------------------------------------------------------------
         *
         * InfoProcsCmd --
         *
         *      Called to implement the "info procs" command that returns the
         *      procedures in the current namespace that match an optional pattern.
         *      Handles the following syntax:
         *
         *          info procs ?pattern?
         *
         * Results:
         *      Returns if successful, raises TclException otherwise.
         *
         * Side effects:
         *      Returns a result in the interpreter's result object.
         *
         *----------------------------------------------------------------------
         */

        private static void InfoProcsCmd(Interp interp, TclObject[] objv)
        {
            string cmdName, pattern;

            NamespaceCmd.Namespace currNs = NamespaceCmd.getCurrentNamespace(interp);
            IDictionaryEnumerator  search;
            WrappedCommand         cmd, realCmd;
            TclObject list;

            if (objv.Length == 2)
            {
                pattern = null;
            }
            else if (objv.Length == 3)
            {
                pattern = objv[2].ToString();
            }
            else
            {
                throw new TclNumArgsException(interp, 2, objv, "?pattern?");
            }

            // Scan through the current namespace's command table and return a list
            // of all procs that match the pattern.

            list = TclList.newInstance();
            for (search = currNs.cmdTable.GetEnumerator(); search.MoveNext();)
            {
                cmdName = ((string)search.Key);
                cmd     = (WrappedCommand)search.Value;

                // If the command isn't itself a proc, it still might be an
                // imported command that points to a "real" proc in a different
                // namespace.

                realCmd = NamespaceCmd.getOriginalCommand(cmd);

                if (Procedure.isProc(cmd) || ((realCmd != null) && Procedure.isProc(realCmd)))
                {
                    if (((System.Object)pattern == null) || Util.stringMatch(cmdName, pattern))
                    {
                        TclList.append(interp, list, TclString.newInstance(cmdName));
                    }
                }
            }

            interp.setResult(list);
            return;
        }
 public static TclObject Tcl_NewStringObj(string value, int iLength)
 {
     if (value == null)
     {
         value = "";
     }
     else
     {
         value = value.Split('\0')[0];
     }
     if (iLength <= 0)
     {
         iLength = value.Length;
     }
     return(TclString.newInstance(value.Substring(0, iLength)));
 }
Ejemplo n.º 13
0
        public static string translateFileName(Interp interp, string path)
        {
            string fileName = "";

            if ((path.Length == 0) || (path[0] != '~'))
            {
                //      fileName = path;
                TclObject[] joinArrayObj = new TclObject[1];
                joinArrayObj[0] = TclString.newInstance(path);
                fileName        = joinPath(interp, joinArrayObj, 0, 1);
            }
            else
            {
                TclObject[] splitArrayObj = TclList.getElements(interp, splitPath(interp, path));


                string user = splitArrayObj[0].ToString().Substring(1);


                // Strip the trailing ':' off of a Mac path
                // before passing the user name to DoTildeSubst.

                if ((JACL.PLATFORM == JACL.PLATFORM_MAC) && (user.EndsWith(":")))
                {
                    user = user.Substring(0, (user.Length - 1) - (0));
                }

                user = doTildeSubst(interp, user);

                //  if (splitArrayObj.length < 2) {
                //      fileName = user;
                //  } else {
                splitArrayObj[0] = TclString.newInstance(user);
                fileName         = joinPath(interp, splitArrayObj, 0, splitArrayObj.Length);
                //  }
            }


            // Convert forward slashes to backslashes in Windows paths because
            // some system interfaces don't accept forward slashes.

            if (JACL.PLATFORM == JACL.PLATFORM_WINDOWS)
            {
                fileName = fileName.Replace('/', '\\');
            }
            return(fileName);
        }
Ejemplo n.º 14
0
        /// <summary> Tcl_ListObjAppendElement -> TclList.append()
        ///
        /// Appends a TclObject element to a list object.
        ///
        /// </summary>
        /// <param name="interp">current interpreter.
        /// </param>
        /// <param name="tobj">the TclObject to append an element to.
        /// </param>
        /// <param name="elemObj">the element to append to the object.
        /// </param>
        /// <exception cref=""> TclException if tobj cannot be converted into a list.
        /// </exception>
        public static void append(Interp interp, TclObject tobj, TclObject elemObj)
        {
            if (tobj.Shared)
            {
                throw new TclRuntimeError("TclList.append() called with shared object");
            }
            setListFromAny(interp, tobj);
            tobj.invalidateStringRep();

            TclList tlist = (TclList)tobj.InternalRep;

            if (!String.IsNullOrEmpty(elemObj.stringRep) && elemObj.stringRep[0] == '{')
            {
                elemObj = TclString.newInstance(elemObj.stringRep.Substring(1, elemObj.stringRep.Length - 2));
            }
            elemObj.preserve();
            tlist.vector.Add(elemObj);
        }
Ejemplo n.º 15
0
        /*
         *----------------------------------------------------------------------
         *
         *  InfoGlobalsCmd --
         *
         *      Called to implement the "info globals" command that returns the list
         *      of global variables matching an optional pattern. Handles the
         *      following syntax:
         *
         *          info globals ?pattern?*
         *
         * Results:
         *      Returns if successful, raises TclException otherwise.
         *
         * Side effects:
         *      Returns a result in the interpreter's result object.
         *
         *----------------------------------------------------------------------
         */

        private static void InfoGlobalsCmd(Interp interp, TclObject[] objv)
        {
            string varName, pattern;

            NamespaceCmd.Namespace globalNs = NamespaceCmd.getGlobalNamespace(interp);
            IDictionaryEnumerator  search;
            Var       var;
            TclObject list;

            if (objv.Length == 2)
            {
                pattern = null;
            }
            else if (objv.Length == 3)
            {
                pattern = objv[2].ToString();
            }
            else
            {
                throw new TclNumArgsException(interp, 2, objv, "?pattern?");
            }

            // Scan through the global :: namespace's variable table and create a
            // list of all global variables that match the pattern.

            list = TclList.newInstance();

            for (search = globalNs.varTable.GetEnumerator(); search.MoveNext();)
            {
                varName = ((string)search.Key);
                var     = (Var)search.Value;
                if (var.isVarUndefined())
                {
                    continue;
                }
                if (((System.Object)pattern == null) || Util.stringMatch(varName, pattern))
                {
                    TclList.append(interp, list, TclString.newInstance(varName));
                }
            }

            interp.setResult(list);
            return;
        }
Ejemplo n.º 16
0
        internal static void  hidden(Interp interp, Interp slaveInterp)
        {
            if (slaveInterp.hiddenCmdTable == null)
            {
                return;
            }

            TclObject result = TclList.newInstance();

            interp.setResult(result);

            IEnumerator hiddenCmds = slaveInterp.hiddenCmdTable.Keys.GetEnumerator();

            while (hiddenCmds.MoveNext())
            {
                string cmdName = (string)hiddenCmds.Current;
                TclList.append(interp, result, TclString.newInstance(cmdName));
            }
        }
Ejemplo n.º 17
0
        /*
         *----------------------------------------------------------------------
         *
         * initOptStr --
         *
         *	This static method is called when the TraceCmd class is loaded
         *	into the VM. It initializes the opStr array.
         *
         * Results:
         *	Initial value for opStr.
         *
         * Side effects:
         *	The TclObjects stored in opStr are preserve()'ed.
         *
         *----------------------------------------------------------------------
         */

        private static TclObject[] initOptStr()
        {
            TclObject[] strings = new TclObject[8];
            strings[0] = TclString.newInstance("error");
            strings[1] = TclString.newInstance("r");
            strings[2] = TclString.newInstance("w");
            strings[3] = TclString.newInstance("rw");
            strings[4] = TclString.newInstance("u");
            strings[5] = TclString.newInstance("ru");
            strings[6] = TclString.newInstance("wu");
            strings[7] = TclString.newInstance("rwu");

            for (int i = 0; i < 8; i++)
            {
                strings[i].preserve();
            }

            return(strings);
        }
Ejemplo n.º 18
0
        /// <summary> Splits a list (in string rep) up into its constituent fields.
        ///
        /// </summary>
        /// <param name="interp">current interpreter.
        /// </param>
        /// <param name="v">store the list elements in this vector.
        /// </param>
        /// <param name="s">the string to convert into a list.
        /// </param>
        /// <exception cref=""> TclException if the object doesn't contain a valid list.
        /// </exception>
        private static void splitList(Interp interp, ArrayList v, string s)
        {
            int len = s.Length;
            int i   = 0;

            while (i < len)
            {
                FindElemResult res = Util.findElement(interp, s, i, len);
                if (res == null)
                {
                    break;
                }
                else
                {
                    TclObject tobj = TclString.newInstance(res.elem);
                    tobj.preserve();
                    v.Add(tobj);
                }
                i = res.elemEnd;
            }
        }
Ejemplo n.º 19
0
        /*
         *----------------------------------------------------------------------
         *
         * InfoNameOfExecutableCmd --
         *
         *      Called to implement the "info nameofexecutable" command that returns
         *      the name of the binary file running this application. Handles the
         *      following syntax:
         *
         *          info nameofexecutable
         *
         * Results:
         *      Returns if successful, raises TclException otherwise.
         *
         * Side effects:
         *      Returns a result in the interpreter's result object.
         *
         *----------------------------------------------------------------------
         */

        private static void InfoNameOfExecutableCmd(Interp interp, TclObject[] objv)
        {
            if (objv.Length != 2)
            {
                throw new TclNumArgsException(interp, 2, objv, null);
            }

            // We depend on a user defined property named "JAVA" since
            // the JDK provides no means to learn the name of the executable
            // that launched the application.

            string nameOfExecutable = "nacl";

            if ((System.Object)nameOfExecutable != null)
            {
                TclObject result = TclList.newInstance();
                TclList.append(interp, result, TclString.newInstance(nameOfExecutable));
                TclList.append(interp, result, TclString.newInstance("tcl.lang.Shell"));
                interp.setResult(result);
            }

            return;
        }
Ejemplo n.º 20
0
        /// <summary> See Tcl user documentation for details.</summary>

        public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
        {
            if ((argv.Length < 2) || (argv.Length > 3))
            {
                throw new TclNumArgsException(interp, 1, argv, "script ?count?");
            }

            int count;

            if (argv.Length == 2)
            {
                count = 1;
            }
            else
            {
                count = TclInteger.get(interp, argv[2]);
            }

            long startTime = System.DateTime.Now.Ticks;

            for (int i = 0; i < count; i++)
            {
                interp.eval(argv[1], 0);
            }
            long endTime = System.DateTime.Now.Ticks;
            long uSecs   = (((endTime - startTime) / 10) / count);

            if (uSecs == 1)
            {
                interp.setResult(TclString.newInstance("1 microsecond per iteration"));
            }
            else
            {
                interp.setResult(TclString.newInstance(uSecs + " microseconds per iteration"));
            }
            return(TCL.CompletionCode.RETURN);
        }
Ejemplo n.º 21
0
        private static void  fileCopyRename(Interp interp, TclObject[] argv, bool copyFlag)
        {
            int  firstSource = 2;
            bool force       = false;

            for (bool last = false; (firstSource < argv.Length) && (!last); firstSource++)
            {
                if (!argv[firstSource].ToString().StartsWith("-"))
                {
                    break;
                }
                int opt = TclIndex.get(interp, argv[firstSource], validOptions, "option", 1);
                switch (opt)
                {
                case OPT_FORCE:
                    force = true;
                    break;

                case OPT_LAST:
                    last = true;
                    break;

                default:
                    throw new TclRuntimeError("FileCmd.cmdProc: bad option " + opt + " index to validOptions");
                }
            }

            if (firstSource >= (argv.Length - 1))
            {
                throw new TclNumArgsException(interp, firstSource, argv, "?options? source ?source ...? target");
            }

            // WARNING:  ignoring links because Java does not support them.

            int target = argv.Length - 1;

            string targetName = argv[target].ToString();

            System.IO.FileInfo targetObj = FileUtil.getNewFileObj(interp, targetName);
            if (System.IO.Directory.Exists(targetObj.FullName))
            {
                // If the target is a directory, move each source file into target
                // directory.  Extract the tailname from each source, and append it to
                // the end of the target path.

                for (int source = firstSource; source < target; source++)
                {
                    string sourceName = argv[source].ToString();

                    if (targetName.Length == 0)
                    {
                        copyRenameOneFile(interp, sourceName, targetName, copyFlag, force);
                    }
                    else
                    {
                        string tailName = getTail(interp, sourceName);

                        TclObject[] joinArrayObj = new TclObject[2];
                        joinArrayObj[0] = TclString.newInstance(targetName);
                        joinArrayObj[1] = TclString.newInstance(tailName);

                        string fullTargetName = FileUtil.joinPath(interp, joinArrayObj, 0, 2);

                        copyRenameOneFile(interp, sourceName, fullTargetName, copyFlag, force);
                    }
                }
            }
            else
            {
                // If there is more than 1 source file and the target is not a
                // directory, then throw an exception.

                if (firstSource + 1 != target)
                {
                    string action;
                    if (copyFlag)
                    {
                        action = "copying";
                    }
                    else
                    {
                        action = "renaming";
                    }

                    throw new TclPosixException(interp, TclPosixException.ENOTDIR, "error " + action + ": target \"" + argv[target].ToString() + "\" is not a directory");
                }

                string sourceName = argv[firstSource].ToString();
                copyRenameOneFile(interp, sourceName, targetName, copyFlag, force);
            }
        }
Ejemplo n.º 22
0
        private static void  deleteOneFile(Interp interp, string fileName, bool force)
        {
            if (fileName == ":memory:")
            {
                return;
            }
            bool isDeleted = true;

            System.IO.FileInfo fileObj = FileUtil.getNewFileObj(interp, fileName);

            // Trying to delete a file that does not exist is not
            // considered an error, just a no-op

            bool tmpBool;

            if (System.IO.File.Exists(fileObj.FullName))
            {
                tmpBool = true;
            }
            else
            {
                tmpBool = System.IO.Directory.Exists(fileObj.FullName);
            }
            if ((!tmpBool) || (fileName.Length == 0))
            {
                return;
            }

            // If the file is a non-empty directory, recursively delete its children if
            // the -force option was chosen.  Otherwise, throw an error.

            if (System.IO.Directory.Exists(fileObj.FullName) && (System.IO.Directory.GetFileSystemEntries(fileObj.FullName).Length > 0))
            {
                if (force)
                {
                    string[] fileList = System.IO.Directory.GetFileSystemEntries(fileObj.FullName);
                    for (int i = 0; i < fileList.Length; i++)
                    {
                        TclObject[] joinArrayObj = new TclObject[2];
                        joinArrayObj[0] = TclString.newInstance(fileName);
                        joinArrayObj[1] = TclString.newInstance(fileList[i]);

                        string child = FileUtil.joinPath(interp, joinArrayObj, 0, 2);
                        deleteOneFile(interp, child, force);
                    }
                }
                else
                {
                    throw new TclPosixException(interp, TclPosixException.ENOTEMPTY, "error deleting \"" + fileName + "\": directory not empty");
                }
            }
            try
            {
                bool tmpBool2;
                if (System.IO.File.Exists(fileObj.FullName))
                {
                    fileObj.Attributes = System.IO.FileAttributes.Normal;
                    System.IO.File.Delete(fileObj.FullName);
                    tmpBool2 = true;
                }
                else if (System.IO.Directory.Exists(fileObj.FullName))
                {
                    System.IO.Directory.Delete(fileObj.FullName);
                    tmpBool2 = true;
                }
                else
                {
                    tmpBool2 = false;
                }
                isDeleted = tmpBool2;
            }
            catch (System.IO.IOException e) {
                throw new TclException(interp, e.Message);
            }
            catch (System.Security.SecurityException e)
            {
                throw new TclException(interp, e.Message);
            }
            if (!isDeleted)
            {
                throw new TclPosixException(interp, TclPosixException.EACCES, true, "error deleting \"" + fileName + "\":  best guess at reason");
            }
        }
Ejemplo n.º 23
0
        public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
        {
            if (argv.Length < 2)
            {
                throw new TclNumArgsException(interp, 1, argv, "option ?arg ...?");
            }

            int    opt = TclIndex.get(interp, argv[1], validCmds, "option", 0);
            string path;

            System.IO.FileInfo fileObj = null;

            switch (opt)
            {
            case OPT_ATIME:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                // FIXME:  Currently returns the same thing as MTIME.
                // Java does not support retrieval of access time.



                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());

                interp.setResult(getMtime(interp, argv[2].ToString(), fileObj));
                return(TCL.CompletionCode.RETURN);


            case OPT_ATTRIBUTES:
                if (argv[3].ToString() == "-readonly")
                {
                    fileSetReadOnly(interp, argv);
                }
                else
                {
                    throw new TclException(interp, "sorry, \"file attributes\" is not implemented yet");
                }
                return(TCL.CompletionCode.RETURN);


            case OPT_CHANNELS:

                throw new TclException(interp, "sorry, \"file channels\" is not implemented yet");


            case OPT_COPY:
                fileCopyRename(interp, argv, true);
                return(TCL.CompletionCode.RETURN);


            case OPT_DELETE:
                fileDelete(interp, argv);
                return(TCL.CompletionCode.RETURN);


            case OPT_DIRNAME:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                path = argv[2].ToString();

                // Return all but the last component.  If there is only one
                // component, return it if the path was non-relative, otherwise
                // return the current directory.


                TclObject[] splitArrayObj = TclList.getElements(interp, FileUtil.splitAndTranslate(interp, path));

                if (splitArrayObj.Length > 1)
                {
                    interp.setResult(FileUtil.joinPath(interp, splitArrayObj, 0, splitArrayObj.Length - 1));
                }
                else if ((splitArrayObj.Length == 0) || (FileUtil.getPathType(path) == FileUtil.PATH_RELATIVE))
                {
                    if (JACL.PLATFORM == JACL.PLATFORM_MAC)
                    {
                        interp.setResult(":");
                    }
                    else
                    {
                        interp.setResult(".");
                    }
                }
                else
                {
                    interp.setResult(splitArrayObj[0].ToString());
                }
                return(TCL.CompletionCode.RETURN);


            case OPT_EXECUTABLE:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }
                bool isExe = false;

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());

                // A file must exist to be executable.  Directories are always
                // executable.

                bool tmpBool;
                if (System.IO.File.Exists(fileObj.FullName))
                {
                    tmpBool = true;
                }
                else
                {
                    tmpBool = System.IO.Directory.Exists(fileObj.FullName);
                }
                if (tmpBool)
                {
                    isExe = System.IO.Directory.Exists(fileObj.FullName);
                    if (isExe)
                    {
                        interp.setResult(isExe);
                        return(TCL.CompletionCode.RETURN);
                    }

                    if (Util.Windows)
                    {
                        // File that ends with .exe, .com, or .bat is executable.


                        string fileName = argv[2].ToString();
                        isExe = (fileName.EndsWith(".exe") || fileName.EndsWith(".com") || fileName.EndsWith(".bat"));
                    }
                    else if (Util.Mac)
                    {
                        // FIXME:  Not yet implemented on Mac.  For now, return true.
                        // Java does not support executability checking.

                        isExe = true;
                    }
                    else
                    {
                        // FIXME:  Not yet implemented on Unix.  For now, return true.
                        // Java does not support executability checking.

                        isExe = true;
                    }
                }
                interp.setResult(isExe);
                return(TCL.CompletionCode.RETURN);


            case OPT_EXISTS:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());
                bool tmpBool2;
                if (System.IO.File.Exists(fileObj.FullName))
                {
                    tmpBool2 = true;
                }
                else
                {
                    tmpBool2 = System.IO.Directory.Exists(fileObj.FullName);
                }
                interp.setResult(tmpBool2);
                return(TCL.CompletionCode.RETURN);


            case OPT_EXTENSION:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                interp.setResult(getExtension(argv[2].ToString()));
                return(TCL.CompletionCode.RETURN);


            case OPT_ISDIRECTORY:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());
                interp.setResult(System.IO.Directory.Exists(fileObj.FullName));
                return(TCL.CompletionCode.RETURN);


            case OPT_ISFILE:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());
                interp.setResult(System.IO.File.Exists(fileObj.FullName));
                return(TCL.CompletionCode.RETURN);


            case OPT_JOIN:
                if (argv.Length < 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name ?name ...?");
                }
                interp.setResult(FileUtil.joinPath(interp, argv, 2, argv.Length));
                return(TCL.CompletionCode.RETURN);


            case OPT_LINK:

                throw new TclException(interp, "sorry, \"file link\" is not implemented yet");


            case OPT_LSTAT:
                if (argv.Length != 4)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name varName");
                }

                // FIXME:  Not yet implemented.
                // Java does not support link access.


                throw new TclException(interp, "file command with opt " + argv[1].ToString() + " is not yet implemented");



            case OPT_MTIME:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());

                interp.setResult(getMtime(interp, argv[2].ToString(), fileObj));
                return(TCL.CompletionCode.RETURN);


            case OPT_MKDIR:
                fileMakeDirs(interp, argv);
                return(TCL.CompletionCode.RETURN);


            case OPT_NATIVENAME:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }


                interp.setResult(FileUtil.translateFileName(interp, argv[2].ToString()));
                return(TCL.CompletionCode.RETURN);


            case OPT_NORMALIZE:

                throw new TclException(interp, "sorry, \"file normalize\" is not implemented yet");


            case OPT_OWNED:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());
                interp.setResult(isOwner(interp, fileObj));
                return(TCL.CompletionCode.RETURN);


            case OPT_PATHTYPE:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                switch (FileUtil.getPathType(argv[2].ToString()))
                {
                case FileUtil.PATH_RELATIVE:
                    interp.setResult("relative");
                    return(TCL.CompletionCode.RETURN);

                case FileUtil.PATH_VOLUME_RELATIVE:
                    interp.setResult("volumerelative");
                    return(TCL.CompletionCode.RETURN);

                case FileUtil.PATH_ABSOLUTE:
                    interp.setResult("absolute");
                    break;
                }
                return(TCL.CompletionCode.RETURN);


            case OPT_READABLE:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());

                // interp.setResult(fileObj.canRead());
                // HACK
                interp.setResult(true);
                return(TCL.CompletionCode.RETURN);


            case OPT_READLINK:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                // FIXME:  Not yet implemented.
                // Java does not support link access.


                throw new TclException(interp, "file command with opt " + argv[1].ToString() + " is not yet implemented");


            case OPT_RENAME:
                fileCopyRename(interp, argv, false);
                return(TCL.CompletionCode.RETURN);


            case OPT_ROOTNAME:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                string fileName2  = argv[2].ToString();
                string extension  = getExtension(fileName2);
                int    diffLength = fileName2.Length - extension.Length;
                interp.setResult(fileName2.Substring(0, (diffLength) - (0)));
                return(TCL.CompletionCode.RETURN);


            case OPT_SEPARATOR:

                throw new TclException(interp, "sorry, \"file separator\" is not implemented yet");


            case OPT_SIZE:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());
                bool tmpBool3;
                if (System.IO.File.Exists(fileObj.FullName))
                {
                    tmpBool3 = true;
                }
                else
                {
                    tmpBool3 = System.IO.Directory.Exists(fileObj.FullName);
                }
                if (!tmpBool3)
                {
                    throw new TclPosixException(interp, TclPosixException.ENOENT, true, "could not read \"" + argv[2].ToString() + "\"");
                }
                interp.setResult((int)SupportClass.FileLength(fileObj));
                return(TCL.CompletionCode.RETURN);


            case OPT_SPLIT:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                interp.setResult(FileUtil.splitPath(interp, argv[2].ToString()));
                return(TCL.CompletionCode.RETURN);


            case OPT_STAT:
                if (argv.Length != 4)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name varName");
                }

                getAndStoreStatData(interp, argv[2].ToString(), argv[3].ToString());
                return(TCL.CompletionCode.RETURN);


            case OPT_SYSTEM:

                throw new TclException(interp, "sorry, \"file system\" is not implemented yet");


            case OPT_TAIL:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                interp.setResult(getTail(interp, argv[2].ToString()));
                return(TCL.CompletionCode.RETURN);


            case OPT_TYPE:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());

                interp.setResult(getType(interp, argv[2].ToString(), fileObj));
                return(TCL.CompletionCode.RETURN);


            case OPT_VOLUMES:
                if (argv.Length != 2)
                {
                    throw new TclNumArgsException(interp, 2, argv, null);
                }

                // use Java 1.2's File.listRoots() method if available

                if (listRootsMethod == null)
                {
                    throw new TclException(interp, "\"file volumes\" is not supported");
                }

                try
                {
                    System.IO.FileInfo[] roots = (System.IO.FileInfo[])listRootsMethod.Invoke(null, (System.Object[]) new System.Object[0]);
                    if (roots != null)
                    {
                        TclObject list = TclList.newInstance();
                        for (int i = 0; i < roots.Length; i++)
                        {
                            string root = roots[i].FullName;
                            TclList.append(interp, list, TclString.newInstance(root));
                        }
                        interp.setResult(list);
                    }
                }
                catch (System.UnauthorizedAccessException ex)
                {
                    throw new TclRuntimeError("IllegalAccessException in volumes cmd");
                }
                catch (System.ArgumentException ex)
                {
                    throw new TclRuntimeError("IllegalArgumentException in volumes cmd");
                }
                catch (System.Reflection.TargetInvocationException ex)
                {
                    System.Exception t = ex.GetBaseException();

                    if (t is System.ApplicationException)
                    {
                        throw (System.ApplicationException)t;
                    }
                    else
                    {
                        throw new TclRuntimeError("unexected exception in volumes cmd");
                    }
                }

                return(TCL.CompletionCode.RETURN);

            case OPT_WRITABLE:
                if (argv.Length != 3)
                {
                    throw new TclNumArgsException(interp, 2, argv, "name");
                }

                fileObj = FileUtil.getNewFileObj(interp, argv[2].ToString());
                interp.setResult(SupportClass.FileCanWrite(fileObj));
                return(TCL.CompletionCode.RETURN);

            default:

                throw new TclRuntimeError("file command with opt " + argv[1].ToString() + " is not implemented");
            }
        }
Ejemplo n.º 24
0
        private static void  getAndStoreStatData(Interp interp, string fileName, string varName)
        {
            System.IO.FileInfo fileObj = FileUtil.getNewFileObj(interp, fileName);

            bool tmpBool;

            if (System.IO.File.Exists(fileObj.FullName))
            {
                tmpBool = true;
            }
            else
            {
                tmpBool = System.IO.Directory.Exists(fileObj.FullName);
            }
            if (!tmpBool)
            {
                throw new TclPosixException(interp, TclPosixException.ENOENT, true, "could not read \"" + fileName + "\"");
            }

            try
            {
                int       mtime    = getMtime(interp, fileName, fileObj);
                TclObject mtimeObj = TclInteger.newInstance(mtime);
                TclObject atimeObj = TclInteger.newInstance(mtime);
                TclObject ctimeObj = TclInteger.newInstance(mtime);
                interp.setVar(varName, "atime", atimeObj, 0);
                interp.setVar(varName, "ctime", ctimeObj, 0);
                interp.setVar(varName, "mtime", mtimeObj, 0);
            }
            catch (System.Security.SecurityException e)
            {
                throw new TclException(interp, e.Message);
            }
            catch (TclException e)
            {
                throw new TclException(interp, "can't set \"" + varName + "(dev)\": variable isn't array");
            }

            try
            {
                TclObject sizeObj = TclInteger.newInstance((int)SupportClass.FileLength(fileObj));
                interp.setVar(varName, "size", sizeObj, 0);
            }
            catch (System.Exception e)
            {
                // Do nothing.
            }

            try
            {
                TclObject typeObj = TclString.newInstance(getType(interp, fileName, fileObj));
                interp.setVar(varName, "type", typeObj, 0);
            }
            catch (System.Exception e)
            {
            }

            try
            {
                TclObject uidObj = TclBoolean.newInstance(isOwner(interp, fileObj));
                interp.setVar(varName, "uid", uidObj, 0);
            }
            catch (TclException e)
            {
                // Do nothing.
            }
        }
Ejemplo n.º 25
0
        public TCL.CompletionCode cmdProc(Interp interp, TclObject[] objv)
        {
            string    optLevel;
            int       result;
            CallFrame savedVarFrame, frame;
            int       objc = objv.Length;
            int       objv_index;
            TclObject cmd;

            if (objv.Length < 2)
            {
                throw new TclNumArgsException(interp, 1, objv, "?level? command ?arg ...?");
            }

            // Find the level to use for executing the command.


            optLevel = objv[1].ToString();
            // Java does not support passing a reference by refernece so use an array
            CallFrame[] frameArr = new CallFrame[1];
            result = CallFrame.getFrame(interp, optLevel, frameArr);
            frame  = frameArr[0];

            objc -= (result + 1);
            if (objc == 0)
            {
                throw new TclNumArgsException(interp, 1, objv, "?level? command ?arg ...?");
            }
            objv_index = (result + 1);

            // Modify the interpreter state to execute in the given frame.

            savedVarFrame   = interp.varFrame;
            interp.varFrame = frame;

            // Execute the residual arguments as a command.

            if (objc == 1)
            {
                cmd = objv[objv_index];
            }
            else
            {
                cmd = TclString.newInstance(Util.concat(objv_index, objv.Length - 1, objv));
            }
            cmd.preserve();

            try
            {
                interp.eval(cmd, 0);
            }
            catch (TclException e)
            {
                if (e.getCompletionCode() == TCL.CompletionCode.ERROR)
                {
                    interp.addErrorInfo("\n    (\"uplevel\" body line " + interp.errorLine + ")");
                }
                throw;
            }
            finally
            {
                interp.varFrame = savedVarFrame;
                cmd.release();
            }
            return(TCL.CompletionCode.RETURN);
        }
Ejemplo n.º 26
0
        /// <summary> This procedure is invoked to process the "scan" Tcl command.
        /// See the user documentation for details on what it does.
        ///
        /// Each iteration of the cmdProc compares the scanArr's current index to
        /// the frmtArr's index.  If the chars are equal then the indicies are
        /// incremented.  If a '%' is found in the frmtArr, the formatSpecifier
        /// is parced from the frmtArr, the corresponding value is extracted from
        /// the scanArr, and that value is set in the Tcl Interp.
        ///
        /// If the chars are not equal, or the conversion fails, the boolean
        /// scanArrDone is set to true, indicating the scanArr is not to be
        /// parced and no new values are to be set.  However the frmtArr is still
        /// parced because of the priority of error messages.  In the C version
        /// of Tcl, bad format specifiers throw errors before incorrect argument
        /// input or other scan errors.  Thus we need to parce the entire frmtArr
        /// to verify correct formating.  This is dumb and inefficient but it is
        /// consistent w/ the current C-version of Tcl.
        /// </summary>

        public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
        {
            if (argv.Length < 3)
            {
                throw new TclNumArgsException(interp, 1, argv, "string format ?varName varName ...?");
            }
            ;

            StrtoulResult strul;             // Return value for parcing the scanArr when
            // extracting integers/longs
            StrtodResult strd;;              // Return value for parcing the scanArr when

            // extracting doubles
            char[] scanArr;    // Array containing parce info
            char[] frmtArr;    // Array containing info on how to
            // parse the scanArr
            int  scanIndex;    // Index into the scan array
            int  frmtIndex;    // Index into the frmt array
            int  tempIndex;    // Temporary index holder
            int  argIndex;     // Index into the current arg
            int  width;        // Stores the user specified result width
            int  base_;        // Base of the integer being converted
            int  numUnMatched; // Number of fields actually set.
            int  numMatched;   // Number of fields actually matched.
            int  negateScan;   // Mult by result, set to -1 if true
            int  i;            // Generic variable
            char ch;           // Generic variable
            bool cont;         // Used in loops to indicate when to stop
            bool scanOK;       // Set to false if strtoul/strtod fails
            bool scanArrDone;  // Set to false if strtoul/strtod fails
            bool widthFlag;    // True is width is specified
            bool discardFlag;  // If a "%*" is in the formatString dont

            // write output to arg


            scanArr = argv[1].ToString().ToCharArray();

            frmtArr     = argv[2].ToString().ToCharArray();
            width       = base_ = numMatched = numUnMatched = 0;
            scanIndex   = frmtIndex = 0;
            scanOK      = true;
            scanArrDone = false;
            argIndex    = 3;

            // Skip all (if any) of the white space before getting to a char

            frmtIndex = skipWhiteSpace(frmtArr, frmtIndex);

            // Search through the frmtArr.  If the next char is a '%' parse the
            // next chars and determine the type (if any) of the format specifier.
            // If the scanArr has been fully searched, do nothing but incerment
            // "numUnMatched".  The reason to continue the frmtArr search is for
            // consistency in output.  Previously scan format errors were reported
            // before arg input mismatch, so this maintains the same level of error
            // checking.

            while (frmtIndex < frmtArr.Length)
            {
                discardFlag = widthFlag = false;
                negateScan  = 1;
                cont        = true;

                // Parce the format array and read in the correct value from the
                // scan array.  When the correct value is retrieved, set the
                // variable (from argv) in the interp.

                if (frmtArr[frmtIndex] == '%')
                {
                    frmtIndex++;
                    checkOverFlow(interp, frmtArr, frmtIndex);

                    // Two '%'s in a row, do nothing...

                    if (frmtArr[frmtIndex] == '%')
                    {
                        frmtIndex++;
                        scanIndex++;
                        continue;
                    }

                    // Check for a discard field flag

                    if (frmtArr[frmtIndex] == '*')
                    {
                        discardFlag = true;
                        frmtIndex++;
                        checkOverFlow(interp, frmtArr, frmtIndex);
                    }

                    // Check for a width field and accept the 'h', 'l', 'L'
                    // characters, but do nothing with them.
                    //
                    // Note: The order of the width specifier and the other
                    // chars is unordered, so we need to iterate until all
                    // of the specifiers are identified.

                    while (cont)
                    {
                        cont = false;

                        switch (frmtArr[frmtIndex])
                        {
                        case 'h':
                        case 'l':
                        case 'L':  {
                            // Just ignore these values

                            frmtIndex++;
                            cont = true;
                            break;
                        }

                        default:  {
                            if (System.Char.IsDigit(frmtArr[frmtIndex]))
                            {
                                strul     = Util.strtoul(new string(frmtArr), frmtIndex, base_);
                                frmtIndex = strul.index;
                                width     = (int)strul.value;
                                widthFlag = true;
                                cont      = true;
                            }
                        }
                        break;
                        }
                        checkOverFlow(interp, frmtArr, frmtIndex);
                    }

                    // On all conversion specifiers except 'c', move the
                    // scanIndex to the next non-whitespace.

                    ch = frmtArr[frmtIndex];
                    if ((ch != 'c') && (ch != '[') && !scanArrDone)
                    {
                        scanIndex = skipWhiteSpace(scanArr, scanIndex);
                    }
                    if (scanIndex >= scanArr.Length)
                    {
                        scanArrDone = true;
                    }

                    if ((scanIndex < scanArr.Length) && (ch != 'c') && (ch != '['))
                    {
                        // Since strtoul dosent take signed numbers, make the
                        // value positive and store the sign.

                        if (scanArr[scanIndex] == '-')
                        {
                            negateScan = -1;
                            scanIndex++;
                            width--;
                        }
                        else if (scanArr[scanIndex] == '+')
                        {
                            scanIndex++;
                            width--;
                        }

                        // The width+scanIndex might be greater than
                        // the scanArr so we need to re-adjust when this
                        // happens.

                        if (widthFlag && (width + scanIndex > scanArr.Length))
                        {
                            width = scanArr.Length - scanIndex;
                        }
                    }

                    if (scanIndex >= scanArr.Length)
                    {
                        scanArrDone = true;
                    }

                    // Foreach iteration we want strul and strd to be
                    // null since we error check on this case.

                    strul = null;
                    strd  = null;

                    switch (ch)
                    {
                    case 'd':
                    case 'o':
                    case 'x':  {
                        if (!scanArrDone)
                        {
                            if (ch == 'd')
                            {
                                base_ = 10;
                            }
                            else if (ch == 'o')
                            {
                                base_ = 8;
                            }
                            else
                            {
                                base_ = 16;
                            }

                            // If the widthFlag is set then convert only
                            // "width" characters to an ascii representation,
                            // else read in until the end of the integer.  The
                            // scanIndex is moved to the point where we stop
                            // reading in.

                            if (widthFlag)
                            {
                                strul = Util.strtoul(new string(scanArr, 0, width + scanIndex), scanIndex, base_);
                            }
                            else
                            {
                                strul = Util.strtoul(new string(scanArr), scanIndex, base_);
                            }
                            if (strul.errno != 0)
                            {
                                scanOK = false;
                                break;
                            }
                            scanIndex = strul.index;

                            if (!discardFlag)
                            {
                                i = (int)strul.value * negateScan;
                                if (argIndex == argv.Length)
                                {
                                    numMatched--;
                                }
                                else
                                {
                                    testAndSetVar(interp, argv, argIndex++, TclInteger.newInstance(i));
                                }
                            }
                        }
                        break;
                    }

                    case 'c':  {
                        if (widthFlag)
                        {
                            errorCharFieldWidth(interp);
                        }
                        if (!discardFlag && !scanArrDone)
                        {
                            testAndSetVar(interp, argv, argIndex++, TclInteger.newInstance(scanArr[scanIndex++]));
                        }
                        break;
                    }

                    case 's':  {
                        if (!scanArrDone)
                        {
                            // If the widthFlag is set then read only "width"
                            // characters into the string, else read in until
                            // the first whitespace or endArr is found.  The
                            // scanIndex is moved to the point where we stop
                            // reading in.

                            tempIndex = scanIndex;
                            if (!widthFlag)
                            {
                                width = scanArr.Length;
                            }
                            for (i = 0; (scanIndex < scanArr.Length) && (i < width); i++)
                            {
                                ch = scanArr[scanIndex];
                                if ((ch == ' ') || (ch == '\n') || (ch == '\r') || (ch == '\t') || (ch == '\f'))
                                {
                                    break;
                                }
                                scanIndex++;
                            }

                            if (!discardFlag)
                            {
                                string str = new string(scanArr, tempIndex, scanIndex - tempIndex);
                                testAndSetVar(interp, argv, argIndex++, TclString.newInstance(str));
                            }
                        }
                        break;
                    }

                    case 'e':
                    case 'f':
                    case 'g':  {
                        if (!scanArrDone)
                        {
                            // If the wisthFlag is set then read only "width"
                            // characters into the string, else read in until
                            // the first whitespace or endArr is found.  The
                            // scanIndex is moved to the point where we stop
                            // reading in.

                            if (widthFlag)
                            {
                                strd = Util.strtod(new string(scanArr, 0, width + scanIndex), scanIndex);
                            }
                            else
                            {
                                strd = Util.strtod(new string(scanArr), scanIndex);
                            }
                            if (strd.errno != 0)
                            {
                                scanOK = false;
                                break;
                            }
                            scanIndex = strd.index;

                            if (!discardFlag)
                            {
                                double d = strd.value * negateScan;
                                testAndSetVar(interp, argv, argIndex++, TclDouble.newInstance(d));
                            }
                        }
                        break;
                    }

                    case '[':  {
                        bool   charMatchFound = false;
                        bool   charNotMatch   = false;
                        char[] tempArr;
                        int    startIndex;
                        int    endIndex;
                        string unmatched = "unmatched [ in format string";

                        if ((++frmtIndex) >= frmtArr.Length)
                        {
                            throw new TclException(interp, unmatched);
                        }

                        if (frmtArr[frmtIndex] == '^')
                        {
                            charNotMatch = true;
                            frmtIndex   += 2;
                        }
                        else
                        {
                            frmtIndex++;
                        }
                        tempIndex = frmtIndex - 1;

                        if (frmtIndex >= frmtArr.Length)
                        {
                            throw new TclException(interp, unmatched);
                        }

                        // Extract the list of chars for matching.

                        while (frmtArr[frmtIndex] != ']')
                        {
                            if ((++frmtIndex) >= frmtArr.Length)
                            {
                                throw new TclException(interp, unmatched);
                            }
                        }
                        tempArr = new string(frmtArr, tempIndex, frmtIndex - tempIndex).ToCharArray();

                        startIndex = scanIndex;
                        if (charNotMatch)
                        {
                            // Format specifier contained a '^' so interate
                            // until one of the chars in tempArr is found.

                            while (scanOK && !charMatchFound)
                            {
                                if (scanIndex >= scanArr.Length)
                                {
                                    scanOK = false;
                                    break;
                                }
                                for (i = 0; i < tempArr.Length; i++)
                                {
                                    if (tempArr[i] == scanArr[scanIndex])
                                    {
                                        charMatchFound = true;
                                        break;
                                    }
                                }
                                if (widthFlag && ((scanIndex - startIndex) >= width))
                                {
                                    break;
                                }
                                if (!charMatchFound)
                                {
                                    scanIndex++;
                                }
                            }
                        }
                        else
                        {
                            // Iterate until the char in the scanArr is not
                            // in the tempArr.

                            charMatchFound = true;
                            while (scanOK && charMatchFound)
                            {
                                if (scanIndex >= scanArr.Length)
                                {
                                    scanOK = false;
                                    break;
                                }
                                charMatchFound = false;
                                for (i = 0; i < tempArr.Length; i++)
                                {
                                    if (tempArr[i] == scanArr[scanIndex])
                                    {
                                        charMatchFound = true;
                                        break;
                                    }
                                }
                                if (widthFlag && (scanIndex - startIndex) >= width)
                                {
                                    break;
                                }
                                if (charMatchFound)
                                {
                                    scanIndex++;
                                }
                            }
                        }

                        // Indicates nothing was found.

                        endIndex = scanIndex - startIndex;
                        if (endIndex <= 0)
                        {
                            scanOK = false;
                            break;
                        }

                        if (!discardFlag)
                        {
                            string str = new string(scanArr, startIndex, endIndex);
                            testAndSetVar(interp, argv, argIndex++, TclString.newInstance(str));
                        }
                        break;
                    }

                    default:  {
                        errorBadField(interp, ch);
                    }
                    break;
                    }

                    // As long as the scan was successful (scanOK), the format
                    // specifier did not contain a '*' (discardFlag), and
                    // we are not at the end of the scanArr (scanArrDone);
                    // increment the num of vars set in the interp.  Otherwise
                    // increment the number of valid format specifiers.

                    if (scanOK && !discardFlag && !scanArrDone)
                    {
                        numMatched++;
                    }
                    else if ((scanArrDone || !scanOK) && !discardFlag)
                    {
                        numUnMatched++;
                    }
                    frmtIndex++;
                }
                else if (scanIndex < scanArr.Length && scanArr[scanIndex] == frmtArr[frmtIndex])
                {
                    // No '%' was found, but the characters matched

                    scanIndex++;
                    frmtIndex++;
                }
                else
                {
                    // No '%' found and the characters int frmtArr & scanArr
                    // did not match.

                    frmtIndex++;
                }
            }

            // The numMatched is the return value: a count of the num of vars set.
            // While the numUnMatched is the number of formatSpecifiers that
            // passed the parsing stage, but did not match anything in the scanArr.

            if ((numMatched + numUnMatched) != (argv.Length - 3))
            {
                errorDiffVars(interp);
            }
            interp.setResult(TclInteger.newInstance(numMatched));
            return(TCL.CompletionCode.RETURN);
        }
Ejemplo n.º 27
0
        /*
         *----------------------------------------------------------------------
         *
         * InfoVarsCmd --
         *
         *	Called to implement the "info vars" command that returns the
         *	list of variables in the interpreter that match an optional pattern.
         *	The pattern, if any, consists of an optional sequence of namespace
         *	names separated by "::" qualifiers, which is followed by a
         *	glob-style pattern that restricts which variables are returned.
         *	Handles the following syntax:
         *
         *          info vars ?pattern?
         *
         * Results:
         *      Returns if successful, raises TclException otherwise.
         *
         * Side effects:
         *      Returns a result in the interpreter's result object.
         *
         *----------------------------------------------------------------------
         */

        private static void InfoVarsCmd(Interp interp, TclObject[] objv)
        {
            string varName, pattern, simplePattern;
            IDictionaryEnumerator search;
            Var var;

            NamespaceCmd.Namespace ns;
            NamespaceCmd.Namespace globalNs = NamespaceCmd.getGlobalNamespace(interp);
            NamespaceCmd.Namespace currNs = NamespaceCmd.getCurrentNamespace(interp);
            TclObject list, elemObj;
            bool      specificNsInPattern = false; // Init. to avoid compiler warning.

            // Get the pattern and find the "effective namespace" in which to
            // list variables. We only use this effective namespace if there's
            // no active Tcl procedure frame.

            if (objv.Length == 2)
            {
                simplePattern       = null;
                ns                  = currNs;
                specificNsInPattern = false;
            }
            else if (objv.Length == 3)
            {
                // From the pattern, get the effective namespace and the simple
                // pattern (no namespace qualifiers or ::'s) at the end. If an
                // error was found while parsing the pattern, return it. Otherwise,
                // if the namespace wasn't found, just leave ns = null: we will
                // return an empty list since no variables there can be found.


                pattern = objv[2].ToString();

                // Java does not support passing an address so we pass
                // an array of size 1 and then assign arr[0] to the value
                NamespaceCmd.Namespace[] nsArr     = new NamespaceCmd.Namespace[1];
                NamespaceCmd.Namespace[] dummy1Arr = new NamespaceCmd.Namespace[1];
                NamespaceCmd.Namespace[] dummy2Arr = new NamespaceCmd.Namespace[1];
                string[] simplePatternArr          = new string[1];

                NamespaceCmd.getNamespaceForQualName(interp, pattern, null, 0, nsArr, dummy1Arr, dummy2Arr, simplePatternArr);

                // Get the values out of the arrays!
                ns            = nsArr[0];
                simplePattern = simplePatternArr[0];

                if (ns != null)
                {
                    // we successfully found the pattern's ns
                    specificNsInPattern = (simplePattern.CompareTo(pattern) != 0);
                }
            }
            else
            {
                throw new TclNumArgsException(interp, 2, objv, "?pattern?");
            }

            // If the namespace specified in the pattern wasn't found, just return.

            if (ns == null)
            {
                return;
            }

            list = TclList.newInstance();

            if ((interp.varFrame == null) || !interp.varFrame.isProcCallFrame || specificNsInPattern)
            {
                // There is no frame pointer, the frame pointer was pushed only
                // to activate a namespace, or we are in a procedure call frame
                // but a specific namespace was specified. Create a list containing
                // only the variables in the effective namespace's variable table.

                search = ns.varTable.GetEnumerator();
                while (search.MoveNext())
                {
                    varName = ((string)search.Key);
                    var     = (Var)search.Value;
                    if (!var.isVarUndefined() || ((var.flags & VarFlags.NAMESPACE_VAR) != 0))
                    {
                        if (((System.Object)simplePattern == null) || Util.stringMatch(varName, simplePattern))
                        {
                            if (specificNsInPattern)
                            {
                                elemObj = TclString.newInstance(Var.getVariableFullName(interp, var));
                            }
                            else
                            {
                                elemObj = TclString.newInstance(varName);
                            }
                            TclList.append(interp, list, elemObj);
                        }
                    }
                }

                // If the effective namespace isn't the global :: namespace, and a
                // specific namespace wasn't requested in the pattern (i.e., the
                // pattern only specifies variable names), then add in all global ::
                // variables that match the simple pattern. Of course, add in only
                // those variables that aren't hidden by a variable in the effective
                // namespace.

                if ((ns != globalNs) && !specificNsInPattern)
                {
                    search = globalNs.varTable.GetEnumerator();
                    while (search.MoveNext())
                    {
                        varName = ((string)search.Key);
                        var     = (Var)search.Value;
                        if (!var.isVarUndefined() || ((var.flags & VarFlags.NAMESPACE_VAR) != 0))
                        {
                            if (((System.Object)simplePattern == null) || Util.stringMatch(varName, simplePattern))
                            {
                                // Skip vars defined in current namespace
                                if (ns.varTable[varName] == null)
                                {
                                    TclList.append(interp, list, TclString.newInstance(varName));
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                AppendLocals(interp, list, simplePattern, true);
            }

            interp.setResult(list);
            return;
        }
Ejemplo n.º 28
0
        /// <summary> This procedure is invoked to process the "read" Tcl command.
        /// See the user documentation for details on what it does.
        ///
        /// </summary>
        /// <param name="interp">the current interpreter.
        /// </param>
        /// <param name="argv">command arguments.
        /// </param>

        public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
        {
            Channel chan;                // The channel being operated on this
            // method
            int       i      = 1;        // Index to the next arg in argv
            int       toRead = 0;        // Number of bytes or chars to read from channel
            int       charactersRead;    // Number of bytes or chars read from channel
            bool      readAll   = true;  // If true read-all else toRead
            bool      noNewline = false; // If true, strip the newline if there
            TclObject result;


            if ((argv.Length != 2) && (argv.Length != 3))
            {
                errorWrongNumArgs(interp, argv[0].ToString());
            }


            if (argv[i].ToString().Equals("-nonewline"))
            {
                noNewline = true;
                i++;
            }

            if (i == argv.Length)
            {
                errorWrongNumArgs(interp, argv[0].ToString());
            }


            chan = TclIO.getChannel(interp, argv[i].ToString());
            if (chan == null)
            {
                throw new TclException(interp, "can not find channel named \"" + argv[i].ToString() + "\"");
            }

            // Consumed channel name.

            i++;

            // Compute how many bytes or chars to read, and see whether the final
            // noNewline should be dropped.

            if (i < argv.Length)
            {
                string arg = argv[i].ToString();

                if (System.Char.IsDigit(arg[0]))
                {
                    toRead  = TclInteger.get(interp, argv[i]);
                    readAll = false;
                }
                else if (arg.Equals("nonewline"))
                {
                    noNewline = true;
                }
                else
                {
                    throw new TclException(interp, "bad argument \"" + arg + "\": should be \"nonewline\"");
                }
            }

            try
            {
                if ((System.Object)chan.Encoding == null)
                {
                    result = TclByteArray.newInstance();
                }
                else
                {
                    result = TclString.newInstance(new System.Text.StringBuilder(64));
                }
                if (readAll)
                {
                    charactersRead = chan.read(interp, result, TclIO.READ_ALL, 0);

                    // If -nonewline was specified, and we have not hit EOF
                    // and the last char is a "\n", then remove it and return.

                    if (noNewline)
                    {
                        string inStr = result.ToString();
                        if ((charactersRead > 0) && (inStr[charactersRead - 1] == '\n'))
                        {
                            interp.setResult(inStr.Substring(0, ((charactersRead - 1)) - (0)));
                            return(TCL.CompletionCode.RETURN);
                        }
                    }
                }
                else
                {
                    // FIXME: Bug here, the -nonewline flag must be respected
                    // when reading a set number of bytes
                    charactersRead = chan.read(interp, result, TclIO.READ_N_BYTES, toRead);
                }

                /*
                 * // FIXME: Port this -nonewline logic from the C code.
                 * if (charactersRead < 0) {
                 * Tcl_ResetResult(interp);
                 * Tcl_AppendResult(interp, "error reading \"", name, "\": ",
                 * Tcl_PosixError(interp), (char *) NULL);
                 * Tcl_DecrRefCount(resultPtr);
                 * return TCL_ERROR;
                 * }
                 *
                 * // If requested, remove the last newline in the channel if at EOF.
                 *
                 * if ((charactersRead > 0) && (newline != 0)) {
                 * char *result;
                 * int length;
                 *
                 * result = Tcl_GetStringFromObj(resultPtr, length);
                 * if (result[length - 1] == '\n') {
                 * Tcl_SetObjLength(resultPtr, length - 1);
                 * }
                 * }
                 *
                 */

                interp.setResult(result);
            }
            catch (System.IO.IOException e)
            {
                throw new TclRuntimeError("ReadCmd.cmdProc() Error: IOException when reading " + chan.ChanName);
            }
            return(TCL.CompletionCode.RETURN);
        }
Ejemplo n.º 29
0
            public override int processEvent(int flags)
            {
                // See if the command is a complete Tcl command

                if (Interp.commandComplete(command))
                {
                    if (tcl.lang.ConsoleThread.debug)
                    {
                        WriteLine("line was a complete command");
                    }

                    bool      eval_exception = true;
                    TclObject commandObj     = TclString.newInstance(command);

                    try
                    {
                        commandObj.preserve();
                        Enclosing_Instance.interp.recordAndEval(commandObj, 0);
                        eval_exception = false;
                    }
                    catch (TclException e)
                    {
                        if (tcl.lang.ConsoleThread.debug)
                        {
                            WriteLine("eval returned exceptional condition");
                        }

                        TCL.CompletionCode code = e.getCompletionCode();
                        switch (code)
                        {
                        case TCL.CompletionCode.ERROR:

                            Enclosing_Instance.putLine(Enclosing_Instance.err, Enclosing_Instance.interp.getResult().ToString());
                            break;

                        case TCL.CompletionCode.BREAK:
                            Enclosing_Instance.putLine(Enclosing_Instance.err, "invoked \"break\" outside of a loop");
                            break;

                        case TCL.CompletionCode.CONTINUE:
                            Enclosing_Instance.putLine(Enclosing_Instance.err, "invoked \"continue\" outside of a loop");
                            break;

                        default:
                            Enclosing_Instance.putLine(Enclosing_Instance.err, "command returned bad code: " + code);
                            break;
                        }
                    }
                    finally
                    {
                        commandObj.release();
                    }

                    if (!eval_exception)
                    {
                        if (tcl.lang.ConsoleThread.debug)
                        {
                            WriteLine("eval returned normally");
                        }


                        string evalResult = Enclosing_Instance.interp.getResult().ToString();

                        if (tcl.lang.ConsoleThread.debug)
                        {
                            WriteLine("eval result was \"" + evalResult + "\"");
                        }

                        if (evalResult.Length > 0)
                        {
                            Enclosing_Instance.putLine(Enclosing_Instance.out_Renamed, evalResult);
                        }
                    }

                    // Empty out the incoming command buffer
                    Enclosing_Instance.sbuf.Length = 0;

                    // See if the user set a custom shell prompt for the next command

                    TclObject prompt;

                    try
                    {
                        prompt = Enclosing_Instance.interp.getVar("tcl_prompt1", TCL.VarFlag.GLOBAL_ONLY);
                    }
                    catch (TclException e)
                    {
                        prompt = null;
                    }
                    if (prompt != null)
                    {
                        try
                        {
                            Enclosing_Instance.interp.eval(prompt.ToString(), TCL.EVAL_GLOBAL);
                        }
                        catch (TclException e)
                        {
                            Enclosing_Instance.put(Enclosing_Instance.out_Renamed, "% ");
                        }
                    }
                    else
                    {
                        Enclosing_Instance.put(Enclosing_Instance.out_Renamed, "% ");
                    }

                    return(1);
                }
                else
                {
                    // Interp.commandComplete() returned false

                    if (tcl.lang.ConsoleThread.debug)
                    {
                        WriteLine("line was not a complete command");
                    }

                    // We don't have a complete command yet. Print out a level 2
                    // prompt message and wait for further inputs.

                    TclObject prompt;

                    try
                    {
                        prompt = Enclosing_Instance.interp.getVar("tcl_prompt2", TCL.VarFlag.GLOBAL_ONLY);
                    }
                    catch (TclException)
                    {
                        prompt = null;
                    }
                    if (prompt != null)
                    {
                        try
                        {
                            Enclosing_Instance.interp.eval(prompt.ToString(), TCL.EVAL_GLOBAL);
                        }
                        catch (TclException e)
                        {
                            Enclosing_Instance.put(Enclosing_Instance.out_Renamed, "");
                        }
                    }
                    else
                    {
                        Enclosing_Instance.put(Enclosing_Instance.out_Renamed, "");
                    }

                    return(1);
                }
            } // end processEvent method
Ejemplo n.º 30
0
        /*
         *----------------------------------------------------------------------
         *
         * InfoCommandsCmd --
         *
         *	Called to implement the "info commands" command that returns the
         *	list of commands in the interpreter that match an optional pattern.
         *	The pattern, if any, consists of an optional sequence of namespace
         *	names separated by "::" qualifiers, which is followed by a
         *	glob-style pattern that restricts which commands are returned.
         *	Handles the following syntax:
         *
         *          info commands ?pattern?
         *
         * Results:
         *      Returns if successful, raises TclException otherwise.
         *
         * Side effects:
         *      Returns a result in the interpreter's result object.
         *
         *----------------------------------------------------------------------
         */

        private static void InfoCommandsCmd(Interp interp, TclObject[] objv)
        {
            string cmdName, pattern, simplePattern;
            IDictionaryEnumerator search;

            NamespaceCmd.Namespace ns;
            NamespaceCmd.Namespace globalNs = NamespaceCmd.getGlobalNamespace(interp);
            NamespaceCmd.Namespace currNs = NamespaceCmd.getCurrentNamespace(interp);
            TclObject      list, elemObj;
            bool           specificNsInPattern = false; // Init. to avoid compiler warning.
            WrappedCommand cmd;

            // Get the pattern and find the "effective namespace" in which to
            // list commands.

            if (objv.Length == 2)
            {
                simplePattern       = null;
                ns                  = currNs;
                specificNsInPattern = false;
            }
            else if (objv.Length == 3)
            {
                // From the pattern, get the effective namespace and the simple
                // pattern (no namespace qualifiers or ::'s) at the end. If an
                // error was found while parsing the pattern, return it. Otherwise,
                // if the namespace wasn't found, just leave ns NULL: we will
                // return an empty list since no commands there can be found.


                pattern = objv[2].ToString();

                // Java does not support passing an address so we pass
                // an array of size 1 and then assign arr[0] to the value
                NamespaceCmd.Namespace[] nsArr     = new NamespaceCmd.Namespace[1];
                NamespaceCmd.Namespace[] dummy1Arr = new NamespaceCmd.Namespace[1];
                NamespaceCmd.Namespace[] dummy2Arr = new NamespaceCmd.Namespace[1];
                string[] simplePatternArr          = new string[1];

                NamespaceCmd.getNamespaceForQualName(interp, pattern, null, 0, nsArr, dummy1Arr, dummy2Arr, simplePatternArr);

                // Get the values out of the arrays!
                ns            = nsArr[0];
                simplePattern = simplePatternArr[0];

                if (ns != null)
                {
                    // we successfully found the pattern's ns
                    specificNsInPattern = (simplePattern.CompareTo(pattern) != 0);
                }
            }
            else
            {
                throw new TclNumArgsException(interp, 2, objv, "?pattern?");
            }

            // Scan through the effective namespace's command table and create a
            // list with all commands that match the pattern. If a specific
            // namespace was requested in the pattern, qualify the command names
            // with the namespace name.

            list = TclList.newInstance();

            if (ns != null)
            {
                search = ns.cmdTable.GetEnumerator();
                while (search.MoveNext())
                {
                    cmdName = ((string)search.Key);
                    if (((System.Object)simplePattern == null) || Util.stringMatch(cmdName, simplePattern))
                    {
                        if (specificNsInPattern)
                        {
                            cmd     = (WrappedCommand)search.Value;
                            elemObj = TclString.newInstance(interp.getCommandFullName(cmd));
                        }
                        else
                        {
                            elemObj = TclString.newInstance(cmdName);
                        }
                        TclList.append(interp, list, elemObj);
                    }
                }

                // If the effective namespace isn't the global :: namespace, and a
                // specific namespace wasn't requested in the pattern, then add in
                // all global :: commands that match the simple pattern. Of course,
                // we add in only those commands that aren't hidden by a command in
                // the effective namespace.

                if ((ns != globalNs) && !specificNsInPattern)
                {
                    search = globalNs.cmdTable.GetEnumerator();
                    while (search.MoveNext())
                    {
                        cmdName = ((string)search.Key);
                        if (((System.Object)simplePattern == null) || Util.stringMatch(cmdName, simplePattern))
                        {
                            if (ns.cmdTable[cmdName] == null)
                            {
                                TclList.append(interp, list, TclString.newInstance(cmdName));
                            }
                        }
                    }
                }
            }

            interp.setResult(list);
            return;
        }