Diff
Not logged in

Differences From Artifact [606bf3bef1]:

To Artifact [24bbcfa528]:


1650
1651
1652
1653
1654
1655
1656
1657

1658
1659
1660
1661
1662
1663
1664
1650
1651
1652
1653
1654
1655
1656

1657
1658
1659
1660
1661
1662
1663
1664







-
+







/*
 *----------------------------------------------------------------------
 *
 * Tcl_FSEvalFile, Tcl_FSEvalFileEx, TclNREvalFile --
 *
 *	Reads a file and evaluates it as a script.
 *
 *	Tcl_FSEvalFile is Tcl_FSEvalFileEx without the encoding argument.
 *	Tcl_FSEvalFile is Tcl_FSEvalFileEx without the encodingName argument.
 *
 *	TclNREvalFile is an NRE-enabled version of Tcl_FSEvalFileEx.
 *
 * Results:
 *	A standard Tcl result, which is either the result of executing the
 *	file or an error indicating why the file couldn't be read.
 *
1683
1684
1685
1686
1687
1688
1689
1690
1691


1692
1693
1694
1695
1696
1697
1698
1683
1684
1685
1686
1687
1688
1689


1690
1691
1692
1693
1694
1695
1696
1697
1698







-
-
+
+







int
Tcl_FSEvalFileEx(
    Tcl_Interp *interp,		/* Interpreter that evaluates the script. */
    Tcl_Obj *pathPtr,		/* Pathname of the file to process.
				 * Tilde-substitution is performed on this
				 * pathname. */
    const char *encoding)	/* Either the name of an encoding or NULL to
				   use the utf-8 encoding. May also be TCL_SHELL_PROFILE_STRICT,
				   TCL_SHELL_PROFILE_REPLACE, or TCL_SHELL_PROFILE_TCL8,
				   use the utf-8 encoding. May also be TCL_ENCODING_UTF8_STRICT,
				   TCL_ENCODING_UTF8_REPLACE, or TCL_ENCODING_UTF8_TCL8,
				   for specifying the profile. */
{
    Tcl_Size length;
    int result = TCL_ERROR;
    Tcl_StatBuf statBuf;
    Tcl_Obj *oldScriptFile;
    Interp *iPtr;
1728
1729
1730
1731
1732
1733
1734
1735

1736
1737

1738
1739
1740

1741
1742
1743
1744
1745
1746
1747
1728
1729
1730
1731
1732
1733
1734

1735
1736

1737
1738
1739

1740
1741
1742
1743
1744
1745
1746
1747







-
+

-
+


-
+








    /*
     * If the encoding is specified, set the channel to that encoding.
     * Otherwise use utf-8.  If the encoding is unknown report an error.
     * "tcl8", "replace" or "strict" are permitted values too.
     */

    if (encoding == NULL || encoding == TCL_SHELL_PROFILE_STRICT) {
    if (encoding == NULL || encoding == TCL_ENCODING_UTF8_STRICT) {
	goto utf8;
    } else if (encoding == TCL_SHELL_PROFILE_REPLACE) {
    } else if (encoding == TCL_ENCODING_UTF8_REPLACE) {
	Tcl_SetChannelOption(interp, chan, "-profile", "replace");
	goto utf8;
    } else if (encoding == TCL_SHELL_PROFILE_TCL8) {
    } else if (encoding == TCL_ENCODING_UTF8_TCL8) {
	Tcl_SetChannelOption(interp, chan, "-profile", "tcl8");
    utf8:
	encoding = "utf-8";
    }
    if (Tcl_SetChannelOption(interp, chan, "-encoding", encoding)
	    != TCL_OK) {
	Tcl_CloseEx(interp,chan,0);
1872
1873
1874
1875
1876
1877
1878
1879

1880
1881

1882
1883
1884

1885
1886
1887
1888
1889
1890
1891
1872
1873
1874
1875
1876
1877
1878

1879
1880

1881
1882
1883

1884
1885
1886
1887
1888
1889
1890
1891







-
+

-
+


-
+








    /*
     * If the encoding is specified, set the channel to that encoding.
     * Otherwise use utf-8.  If the encoding is unknown report an error.
     * "tcl8", "replace" or "strict" are permitted values too.
     */

    if (encoding == NULL || encoding == TCL_SHELL_PROFILE_STRICT) {
    if (encoding == NULL || encoding == TCL_ENCODING_UTF8_STRICT) {
	goto utf8;
    } else if (encoding == TCL_SHELL_PROFILE_REPLACE) {
    } else if (encoding == TCL_ENCODING_UTF8_REPLACE) {
	Tcl_SetChannelOption(interp, chan, "-profile", "replace");
	goto utf8;
    } else if (encoding == TCL_SHELL_PROFILE_TCL8) {
    } else if (encoding == TCL_ENCODING_UTF8_TCL8) {
	Tcl_SetChannelOption(interp, chan, "-profile", "tcl8");
    utf8:
	encoding = "utf-8";
    }
    if (Tcl_SetChannelOption(interp, chan, "-encoding", encoding)
	    != TCL_OK) {
	Tcl_CloseEx(interp, chan, 0);