summaryrefslogtreecommitdiffstats
path: root/generic/tclMain.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclMain.c')
-rw-r--r--generic/tclMain.c51
1 files changed, 15 insertions, 36 deletions
diff --git a/generic/tclMain.c b/generic/tclMain.c
index bc75c8e..4f4ad62 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.c
@@ -17,21 +17,11 @@
*/
/*
- * On Windows, this file needs to be compiled twice, once with TCL_ASCII_MAIN
- * defined. This way both Tcl_Main and Tcl_MainExW can be implemented, sharing
- * the same source code.
+ * On Windows, this file needs to be compiled twice, once with UNICODE and
+ * _UNICODE defined. This way both Tcl_Main and Tcl_MainExW can be
+ * implemented, sharing the same source code.
*/
-#if defined(TCL_ASCII_MAIN)
-# ifdef UNICODE
-# undef UNICODE
-# undef _UNICODE
-# else
-# define UNICODE
-# define _UNICODE
-# endif
-#endif
-
#include "tclInt.h"
/*
@@ -53,31 +43,20 @@
# define _tcscmp strcmp
#endif
-/*
- * Further on, in UNICODE mode we just use Tcl_NewUnicodeObj, otherwise
- * NewNativeObj is needed (which provides proper conversion from native
- * encoding to UTF-8).
- */
-
-#if defined(UNICODE) && (TCL_UTF_MAX <= 4)
-# define NewNativeObj(a,b) Tcl_NewUnicodeObj((const Tcl_UniChar *)a,b)
-#else /* !UNICODE || (TCL_UTF_MAX > 4) */
static inline Tcl_Obj *
NewNativeObj(
- TCHAR *string,
- int length)
+ TCHAR *string)
{
Tcl_DString ds;
#ifdef UNICODE
Tcl_DStringInit(&ds);
- Tcl_WCharToUtfDString(string, length, &ds);
+ Tcl_WCharToUtfDString(string, -1, &ds);
#else
- Tcl_ExternalToUtfDString(NULL, (char *) string, length, &ds);
+ Tcl_ExternalToUtfDString(NULL, (char *) string, -1, &ds);
#endif
return TclDStringToObj(&ds);
}
-#endif /* !UNICODE || (TCL_UTF_MAX > 4) */
/*
* Declarations for various library functions and variables (don't want to
@@ -139,7 +118,7 @@ static void Prompt(Tcl_Interp *interp, InteractiveState *isPtr);
static void StdinProc(ClientData clientData, int mask);
static void FreeMainInterp(ClientData clientData);
-#ifndef TCL_ASCII_MAIN
+#if !defined(_WIN32) || defined(UNICODE)
static Tcl_ThreadDataKey dataKey;
/*
@@ -284,7 +263,7 @@ Tcl_SourceRCFile(
Tcl_DStringFree(&temp);
}
}
-#endif /* !TCL_ASCII_MAIN */
+#endif /* !UNICODE */
/*----------------------------------------------------------------------
*
@@ -346,14 +325,14 @@ Tcl_MainEx(
if ((argc > 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1]))
&& ('-' != argv[3][0])) {
- Tcl_Obj *value = NewNativeObj(argv[2], -1);
- Tcl_SetStartupScript(NewNativeObj(argv[3], -1),
+ Tcl_Obj *value = NewNativeObj(argv[2]);
+ Tcl_SetStartupScript(NewNativeObj(argv[3]),
Tcl_GetString(value));
Tcl_DecrRefCount(value);
argc -= 3;
argv += 3;
} else if ((argc > 1) && ('-' != argv[1][0])) {
- Tcl_SetStartupScript(NewNativeObj(argv[1], -1), NULL);
+ Tcl_SetStartupScript(NewNativeObj(argv[1]), NULL);
argc--;
argv++;
}
@@ -361,7 +340,7 @@ Tcl_MainEx(
path = Tcl_GetStartupScript(&encodingName);
if (path == NULL) {
- appName = NewNativeObj(argv[0], -1);
+ appName = NewNativeObj(argv[0]);
} else {
appName = path;
}
@@ -373,7 +352,7 @@ Tcl_MainEx(
argvPtr = Tcl_NewListObj(0, NULL);
while (argc--) {
- Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++, -1));
+ Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++));
}
Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
@@ -640,7 +619,7 @@ Tcl_MainEx(
Tcl_Exit(exitCode);
}
-#ifndef TCL_ASCII_MAIN
+#if !defined(_WIN32) || defined(UNICODE)
/*
*---------------------------------------------------------------
@@ -731,7 +710,7 @@ TclFullFinalizationRequested(void)
return finalize;
#endif /* PURIFY */
}
-#endif /* !TCL_ASCII_MAIN */
+#endif /* UNICODE */
/*
*----------------------------------------------------------------------