summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-03 12:09:19 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-05-03 12:09:19 (GMT)
commitba878ec5c0d48422b9412451c6b9a84c0d7a5e8d (patch)
treebcbe5e1bf1448cafa3f6d7080e2d9163d497d286 /unix
parenta1e8705fe3b7e08e889e989c77c0881cce63db8c (diff)
parent126d43773ca468803c238c2deb4c947f80f4f68d (diff)
downloadtcl-ba878ec5c0d48422b9412451c6b9a84c0d7a5e8d.zip
tcl-ba878ec5c0d48422b9412451c6b9a84c0d7a5e8d.tar.gz
tcl-ba878ec5c0d48422b9412451c6b9a84c0d7a5e8d.tar.bz2
merge trunk
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixChan.c17
-rw-r--r--unix/tclUnixInit.c58
-rw-r--r--unix/tclUnixSock.c34
-rw-r--r--unix/tclUnixTest.c45
4 files changed, 97 insertions, 57 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 6418f48..3bf64d6 100644
--- a/unix/tclUnixChan.c
+++ b/unix/tclUnixChan.c
@@ -605,7 +605,6 @@ TtySetOptionProc(
return TCL_OK;
}
-
/*
* Option -handshake none|xonxoff|rtscts|dtrdsr
*/
@@ -706,6 +705,7 @@ TtySetOptionProc(
/*
* Option -ttycontrol {DTR 1 RTS 0 BREAK 0}
*/
+
if ((len > 4) && (strncmp(optionName, "-ttycontrol", len) == 0)) {
#if defined(TIOCMGET) && defined(TIOCMSET)
int i, control, flag;
@@ -882,6 +882,7 @@ TtyGetOptionProc(
* Option is readonly and returned by [fconfigure chan -ttystatus] but not
* returned by unnamed [fconfigure chan].
*/
+
if ((len > 4) && (strncmp(optionName, "-ttystatus", len) == 0)) {
int status;
@@ -894,12 +895,10 @@ TtyGetOptionProc(
if (valid) {
return TCL_OK;
}
- return Tcl_BadChannelOption(interp, optionName, "mode"
- " queue ttystatus xchar"
- );
+ return Tcl_BadChannelOption(interp, optionName,
+ "mode queue ttystatus xchar");
}
-
static const struct {int baud; speed_t speed;} speeds[] = {
#ifdef B0
{0, B0},
@@ -1023,7 +1022,7 @@ static const struct {int baud; speed_t speed;} speeds[] = {
#endif
{-1, 0}
};
-
+
/*
*---------------------------------------------------------------------------
*
@@ -1315,7 +1314,8 @@ TtyParseMode(
static void
TtyInit(
- int fd) /* Open file descriptor for serial port to be initialized. */
+ int fd) /* Open file descriptor for serial port to be
+ * initialized. */
{
struct termios iostate;
tcgetattr(fd, &iostate);
@@ -1325,8 +1325,7 @@ TtyInit(
|| iostate.c_lflag != 0
|| iostate.c_cflag & CREAD
|| iostate.c_cc[VMIN] != 1
- || iostate.c_cc[VTIME] != 0)
- {
+ || iostate.c_cc[VTIME] != 0) {
iostate.c_iflag = IGNBRK;
iostate.c_oflag = 0;
iostate.c_lflag = 0;
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index dcf4975..5b0453a 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -737,6 +737,43 @@ Tcl_GetEncodingNameFromEnvironment(
*----------------------------------------------------------------------
*/
+#if defined(HAVE_COREFOUNDATION) && MAC_OS_X_VERSION_MAX_ALLOWED > 1020
+/*
+ * Helper because whether CFLocaleCopyCurrent and CFLocaleGetIdentifier are
+ * strongly or weakly bound varies by version of OSX, triggering warnings.
+ */
+
+static inline void
+InitMacLocaleInfoVar(
+ CFLocaleRef (*localeCopyCurrent)(void),
+ CFStringRef (*localeGetIdentifier)(CFLocaleRef),
+ Tcl_Interp *interp)
+{
+ CFLocaleRef localeRef;
+ CFStringRef locale;
+ char loc[256];
+
+ if (localeCopyCurrent == NULL || localeGetIdentifier == NULL) {
+ return;
+ }
+
+ localeRef = localeCopyCurrent();
+ if (!localeRef) {
+ return;
+ }
+
+ locale = localeGetIdentifier(localeRef);
+ if (locale && CFStringGetCString(locale, loc, 256,
+ kCFStringEncodingUTF8)) {
+ if (!Tcl_CreateNamespace(interp, "::tcl::mac", NULL, NULL)) {
+ Tcl_ResetResult(interp);
+ }
+ Tcl_SetVar2(interp, "::tcl::mac::locale", NULL, loc, TCL_GLOBAL_ONLY);
+ }
+ CFRelease(localeRef);
+}
+#endif /*defined(HAVE_COREFOUNDATION) && MAC_OS_X_VERSION_MAX_ALLOWED > 1020*/
+
void
TclpSetVariables(
Tcl_Interp *interp)
@@ -755,29 +792,12 @@ TclpSetVariables(
#ifdef HAVE_COREFOUNDATION
char tclLibPath[MAXPATHLEN + 1];
-#if MAC_OS_X_VERSION_MAX_ALLOWED > 1020
/*
* Set msgcat fallback locale to current CFLocale identifier.
*/
- CFLocaleRef localeRef;
-
- if (&CFLocaleCopyCurrent != NULL && &CFLocaleGetIdentifier != NULL &&
- (localeRef = CFLocaleCopyCurrent())) {
- CFStringRef locale = CFLocaleGetIdentifier(localeRef);
-
- if (locale) {
- char loc[256];
-
- if (CFStringGetCString(locale, loc, 256, kCFStringEncodingUTF8)) {
- if (!Tcl_CreateNamespace(interp, "::tcl::mac", NULL, NULL)) {
- Tcl_ResetResult(interp);
- }
- Tcl_SetVar2(interp, "::tcl::mac::locale", NULL, loc, TCL_GLOBAL_ONLY);
- }
- }
- CFRelease(localeRef);
- }
+#if MAC_OS_X_VERSION_MAX_ALLOWED > 1020
+ InitMacLocaleInfoVar(CFLocaleCopyCurrent, CFLocaleGetIdentifier, interp);
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED > 1020 */
if (MacOSXGetLibraryPath(interp, MAXPATHLEN, tclLibPath) == TCL_OK) {
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index b404080..2353f94 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -728,6 +728,33 @@ TcpClose2Proc(
*
*----------------------------------------------------------------------
*/
+
+#ifndef NEED_FAKE_RFC2553
+static inline int
+IPv6AddressNeedsNumericRendering(
+ struct in6_addr addr)
+{
+ if (IN6_ARE_ADDR_EQUAL(&addr, &in6addr_any)) {
+ return 1;
+ }
+
+ /*
+ * The IN6_IS_ADDR_V4MAPPED macro has a problem with aliasing warnings on
+ * at least some versions of OSX.
+ */
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+ if (!IN6_IS_ADDR_V4MAPPED(&addr)) {
+#pragma GCC diagnostic pop
+ return 0;
+ }
+
+ return (addr.s6_addr[12] == 0 && addr.s6_addr[13] == 0
+ && addr.s6_addr[14] == 0 && addr.s6_addr[15] == 0);
+}
+#endif /* NEED_FAKE_RFC2553 */
+
static void
TcpHostPortList(
Tcl_Interp *interp,
@@ -754,12 +781,7 @@ TcpHostPortList(
}
#ifndef NEED_FAKE_RFC2553
} else if (addr.sa.sa_family == AF_INET6) {
- if ((IN6_ARE_ADDR_EQUAL(&addr.sa6.sin6_addr, &in6addr_any))
- || (IN6_IS_ADDR_V4MAPPED(&addr.sa6.sin6_addr) &&
- addr.sa6.sin6_addr.s6_addr[12] == 0 &&
- addr.sa6.sin6_addr.s6_addr[13] == 0 &&
- addr.sa6.sin6_addr.s6_addr[14] == 0 &&
- addr.sa6.sin6_addr.s6_addr[15] == 0)) {
+ if (IPv6AddressNeedsNumericRendering(addr.sa6.sin6_addr)) {
flags |= NI_NUMERICHOST;
}
#endif /* NEED_FAKE_RFC2553 */
diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c
index 86e0925..ceb64d9 100644
--- a/unix/tclUnixTest.c
+++ b/unix/tclUnixTest.c
@@ -68,10 +68,10 @@ static Tcl_CmdProc TestfilehandlerCmd;
static Tcl_CmdProc TestfilewaitCmd;
static Tcl_CmdProc TestfindexecutableCmd;
static Tcl_ObjCmdProc TestforkObjCmd;
-static Tcl_CmdProc TestgetdefencdirCmd;
+static Tcl_ObjCmdProc TestgetencpathObjCmd;
static Tcl_CmdProc TestgetopenfileCmd;
static Tcl_CmdProc TestgotsigCmd;
-static Tcl_CmdProc TestsetdefencdirCmd;
+static Tcl_ObjCmdProc TestsetencpathObjCmd;
static Tcl_FileProc TestFileHandlerProc;
static void AlarmHandler(int signum);
@@ -108,9 +108,9 @@ TclplatformtestInit(
NULL, NULL);
Tcl_CreateCommand(interp, "testgetopenfile", TestgetopenfileCmd,
NULL, NULL);
- Tcl_CreateCommand(interp, "testgetdefenc", TestgetdefencdirCmd,
+ Tcl_CreateObjCommand(interp, "testgetencpath", TestgetencpathObjCmd,
NULL, NULL);
- Tcl_CreateCommand(interp, "testsetdefenc", TestsetdefencdirCmd,
+ Tcl_CreateObjCommand(interp, "testsetencpath", TestsetencpathObjCmd,
NULL, NULL);
Tcl_CreateCommand(interp, "testalarm", TestalarmCmd,
NULL, NULL);
@@ -499,9 +499,9 @@ TestgetopenfileCmd(
/*
*----------------------------------------------------------------------
*
- * TestsetdefencdirCmd --
+ * TestsetencpathCmd --
*
- * This function implements the "testsetdefenc" command. It is used to
+ * This function implements the "testsetencpath" command. It is used to
* test Tcl_SetDefaultEncodingDir().
*
* Results:
@@ -514,19 +514,18 @@ TestgetopenfileCmd(
*/
static int
-TestsetdefencdirCmd(
+TestsetencpathObjCmd(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const *objv) /* Argument strings. */
{
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " defaultDir\"", NULL);
+ if (objc != 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "defaultDir");
return TCL_ERROR;
}
- Tcl_SetDefaultEncodingDir(argv[1]);
+ Tcl_SetEncodingSearchPath(objv[1]);
return TCL_OK;
}
@@ -552,7 +551,7 @@ TestforkObjCmd(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *const *objv) /* Argument strings. */
+ Tcl_Obj *const *objv) /* Argument strings. */
{
pid_t pid;
@@ -578,10 +577,10 @@ TestforkObjCmd(
/*
*----------------------------------------------------------------------
*
- * TestgetdefencdirCmd --
+ * TestgetencpathObjCmd --
*
- * This function implements the "testgetdefenc" command. It is used to
- * test Tcl_GetDefaultEncodingDir().
+ * This function implements the "testgetencpath" command. It is used to
+ * test Tcl_GetEncodingSearchPath().
*
* Results:
* A standard Tcl result.
@@ -593,18 +592,18 @@ TestforkObjCmd(
*/
static int
-TestgetdefencdirCmd(
+TestgetencpathObjCmd(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const *objv) /* Argument strings. */
{
- if (argc != 1) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], NULL);
+ if (objc != 1) {
+ Tcl_WrongNumArgs(interp, 1, objv, "");
return TCL_ERROR;
}
- Tcl_AppendResult(interp, Tcl_GetDefaultEncodingDir(), NULL);
+ Tcl_SetObjResult(interp, Tcl_GetEncodingSearchPath());
return TCL_OK;
}