MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / StdinProc

Function StdinProc

SRC/tcl/tclMain85.cpp:819–911  ·  view source on GitHub ↗

ARGSUSED */

Source from the content-addressed store, hash-verified

817 * it's complete.
818 *
819 * Results:
820 * None.
821 *
822 * Side effects:
823 * Could be almost arbitrary, depending on the command that's typed.
824 *
825 *----------------------------------------------------------------------
826 */
827
828 /* ARGSUSED */
829static void
830StdinProc(
831 ClientData clientData, /* The state of interactive cmd line */
832 int mask) /* Not used. */
833{
834 InteractiveState *isPtr = (InteractiveState *) clientData;
835 Tcl_Channel chan = isPtr->input;
836 Tcl_Obj *commandPtr = isPtr->commandPtr;
837 Tcl_Interp *interp = isPtr->interp;
838 int code, length;
839
840 if (Tcl_IsShared(commandPtr)) {
841 Tcl_DecrRefCount(commandPtr);
842 commandPtr = Tcl_DuplicateObj(commandPtr);
843 Tcl_IncrRefCount(commandPtr);
844 }
845 length = Tcl_GetsObj(chan, commandPtr);
846 if (length < 0) {
847 if (Tcl_InputBlocked(chan)) {
848 return;
849 }
850 if (isPtr->tty) {
851 /*
852 * Would be better to find a way to exit the mainLoop? Or perhaps
853 * evaluate [exit]? Leaving as is for now due to compatibility
854 * concerns.
855 */
856
857 Tcl_Exit(0);
858 }
859 Tcl_DeleteChannelHandler(chan, StdinProc, (ClientData) isPtr);
860 return;
861 }
862
863 if (Tcl_IsShared(commandPtr)) {
864 Tcl_DecrRefCount(commandPtr);
865 commandPtr = Tcl_DuplicateObj(commandPtr);
866 Tcl_IncrRefCount(commandPtr);
867 }
868 Tcl_AppendToObj(commandPtr, "\n", 1);
869 if (!TclObjCommandComplete(commandPtr)) {
870 isPtr->prompt = PROMPT_CONTINUE;
871 goto prompt;
872 }
873 isPtr->prompt = PROMPT_START;
874 Tcl_GetStringFromObj(commandPtr, &length);
875 Tcl_SetObjLength(commandPtr, --length);
876

Callers

nothing calls this directly

Calls 1

PromptFunction · 0.70

Tested by

no test coverage detected