summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--generic/tcl.h129
-rw-r--r--generic/tclTest.c14
-rw-r--r--unix/tclUnixNotfy.c14
-rw-r--r--unix/tclUnixPipe.c33
5 files changed, 119 insertions, 79 deletions
diff --git a/ChangeLog b/ChangeLog
index 9ce8e09..f98b1ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-01-29 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * generic/tcl.h Use correct TCL_LL_MODIFIER for CYGWIN.
+ Formatting (all backported from HEAD)
+ * generic/tclTest.c: Fix gcc 4.4 warning: ignoring return value of ‘write’,
+ * unix/tclUnixPipe.c
+ * unix/tclUnixNotify.c
+
2010-01-19 Donal K. Fellows <dkf@users.sf.net>
* doc/dict.n: [Bug 2929546]: Clarify just what [dict with] and [dict
diff --git a/generic/tcl.h b/generic/tcl.h
index 311c1fc..98f90c9 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tcl.h,v 1.254.2.13 2009/11/03 19:21:37 dgp Exp $
+ * RCS: @(#) $Id: tcl.h,v 1.254.2.14 2010/01/29 09:38:48 nijtmans Exp $
*/
#ifndef _TCL
@@ -145,7 +145,7 @@ extern "C" {
*
* The following TCL_VARARGS* macros are to support old extensions
* written for older versions of Tcl where the macros permitted
- * support for the varargs.h system as well as stdarg.h .
+ * support for the varargs.h system as well as stdarg.h .
*
* New code should just directly be written to use stdarg.h conventions.
*/
@@ -167,7 +167,7 @@ extern "C" {
* Note: when building static but linking dynamically to MSVCRT we must still
* correctly decorate the C library imported function. Use CRTIMPORT
* for this purpose. _DLL is defined by the compiler when linking to
- * MSVCRT.
+ * MSVCRT.
*/
#if (defined(__WIN32__) && (defined(_MSC_VER) || (__BORLANDC__ >= 0x0550) || defined(__LCC__) || defined(__WATCOMC__) || (defined(__GNUC__) && defined(__declspec))))
@@ -262,7 +262,7 @@ extern "C" {
#endif
/*
- * Make sure EXTERN isn't defined elsewhere
+ * Make sure EXTERN isn't defined elsewhere.
*/
#ifdef EXTERN
@@ -315,7 +315,7 @@ typedef long LONG;
#endif
/*
- * Darwin specifc configure overrides (to support fat compiles, where
+ * Darwin specific configure overrides (to support fat compiles, where
* configure runs only once for multiple architectures):
*/
@@ -359,7 +359,7 @@ typedef long LONG;
# if defined(__WIN32__) && !defined(__CYGWIN__)
# define TCL_LL_MODIFIER "I64"
# else
-# define TCL_LL_MODIFIER "L"
+# define TCL_LL_MODIFIER "ll"
# endif
typedef struct stat Tcl_StatBuf;
# elif defined(__WIN32__)
@@ -514,9 +514,10 @@ typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
* given to Tcl_CreateThread.
*/
-#define TCL_THREAD_STACK_DEFAULT (0) /* Use default size for stack */
-#define TCL_THREAD_NOFLAGS (0000) /* Standard flags, default behaviour */
-#define TCL_THREAD_JOINABLE (0001) /* Mark the thread as joinable */
+#define TCL_THREAD_STACK_DEFAULT (0) /* Use default size for stack. */
+#define TCL_THREAD_NOFLAGS (0000) /* Standard flags, default
+ * behaviour. */
+#define TCL_THREAD_JOINABLE (0001) /* Mark the thread as joinable. */
/*
* Flag values passed to Tcl_StringCaseMatch.
@@ -528,20 +529,20 @@ typedef void (Tcl_ThreadCreateProc) _ANSI_ARGS_((ClientData clientData));
* Flag values passed to Tcl_GetRegExpFromObj.
*/
-#define TCL_REG_BASIC 000000 /* BREs (convenience) */
-#define TCL_REG_EXTENDED 000001 /* EREs */
-#define TCL_REG_ADVF 000002 /* advanced features in EREs */
-#define TCL_REG_ADVANCED 000003 /* AREs (which are also EREs) */
-#define TCL_REG_QUOTE 000004 /* no special characters, none */
-#define TCL_REG_NOCASE 000010 /* ignore case */
-#define TCL_REG_NOSUB 000020 /* don't care about subexpressions */
-#define TCL_REG_EXPANDED 000040 /* expanded format, white space &
- * comments */
+#define TCL_REG_BASIC 000000 /* BREs (convenience). */
+#define TCL_REG_EXTENDED 000001 /* EREs. */
+#define TCL_REG_ADVF 000002 /* Advanced features in EREs. */
+#define TCL_REG_ADVANCED 000003 /* AREs (which are also EREs). */
+#define TCL_REG_QUOTE 000004 /* No special characters, none. */
+#define TCL_REG_NOCASE 000010 /* Ignore case. */
+#define TCL_REG_NOSUB 000020 /* Don't care about subexpressions. */
+#define TCL_REG_EXPANDED 000040 /* Expanded format, white space &
+ * comments. */
#define TCL_REG_NLSTOP 000100 /* \n doesn't match . or [^ ] */
-#define TCL_REG_NLANCH 000200 /* ^ matches after \n, $ before */
-#define TCL_REG_NEWLINE 000300 /* newlines are line terminators */
-#define TCL_REG_CANMATCH 001000 /* report details on partial/limited
- * matches */
+#define TCL_REG_NLANCH 000200 /* ^ matches after \n, $ before. */
+#define TCL_REG_NEWLINE 000300 /* Newlines are line terminators. */
+#define TCL_REG_CANMATCH 001000 /* Report details on partial/limited
+ * matches. */
/*
* Flags values passed to Tcl_RegExpExecObj.
@@ -600,13 +601,13 @@ typedef struct stat *Tcl_OldStat_;
* interpreter's result is meaningless.
*/
-#define TCL_OK 0
-#define TCL_ERROR 1
-#define TCL_RETURN 2
-#define TCL_BREAK 3
-#define TCL_CONTINUE 4
+#define TCL_OK 0
+#define TCL_ERROR 1
+#define TCL_RETURN 2
+#define TCL_BREAK 3
+#define TCL_CONTINUE 4
-#define TCL_RESULT_SIZE 200
+#define TCL_RESULT_SIZE 200
/*
* Flags to control what substitutions are performed by Tcl_SubstObj():
@@ -761,19 +762,19 @@ typedef struct Tcl_Obj {
* internal rep. NULL indicates the object has
* no internal rep (has no type). */
union { /* The internal representation: */
- long longValue; /* - an long integer value */
- double doubleValue; /* - a double-precision floating value */
- VOID *otherValuePtr; /* - another, type-specific value */
- Tcl_WideInt wideValue; /* - a long long value */
- struct { /* - internal rep as two pointers */
+ long longValue; /* - an long integer value. */
+ double doubleValue; /* - a double-precision floating value. */
+ VOID *otherValuePtr; /* - another, type-specific value. */
+ Tcl_WideInt wideValue; /* - a long long value. */
+ struct { /* - internal rep as two pointers. */
VOID *ptr1;
VOID *ptr2;
} twoPtrValue;
struct { /* - internal rep as a wide int, tightly
- * packed fields */
- VOID *ptr; /* Pointer to digits */
+ * packed fields. */
+ VOID *ptr; /* Pointer to digits. */
unsigned long value;/* Alloc, used, and signum packed into a
- * single word */
+ * single word. */
} ptrAndLongRep;
} internalRep;
} Tcl_Obj;
@@ -935,8 +936,8 @@ typedef struct Tcl_DString {
* buffer space required by Tcl_PrintDouble.
*/
-#define TCL_MAX_PREC 17
-#define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10)
+#define TCL_MAX_PREC 17
+#define TCL_DOUBLE_SPACE (TCL_MAX_PREC+10)
/*
* Definition for a number of bytes of buffer space sufficient to hold the
@@ -993,9 +994,9 @@ typedef struct Tcl_DString {
* page for details):
*/
-#define TCL_VOLATILE ((Tcl_FreeProc *) 1)
-#define TCL_STATIC ((Tcl_FreeProc *) 0)
-#define TCL_DYNAMIC ((Tcl_FreeProc *) 3)
+#define TCL_VOLATILE ((Tcl_FreeProc *) 1)
+#define TCL_STATIC ((Tcl_FreeProc *) 0)
+#define TCL_DYNAMIC ((Tcl_FreeProc *) 3)
/*
* Flag values passed to variable-related functions.
@@ -1348,9 +1349,9 @@ typedef void (Tcl_ScaleTimeProc) _ANSI_ARGS_((Tcl_Time *timebuf,
* indicate what sorts of events are of interest:
*/
-#define TCL_READABLE (1<<1)
-#define TCL_WRITABLE (1<<2)
-#define TCL_EXCEPTION (1<<3)
+#define TCL_READABLE (1<<1)
+#define TCL_WRITABLE (1<<2)
+#define TCL_EXCEPTION (1<<3)
/*
* Flag values to pass to Tcl_OpenCommandChannel to indicate the disposition
@@ -1368,15 +1369,15 @@ typedef void (Tcl_ScaleTimeProc) _ANSI_ARGS_((Tcl_Time *timebuf,
* should be closed.
*/
-#define TCL_CLOSE_READ (1<<1)
-#define TCL_CLOSE_WRITE (1<<2)
+#define TCL_CLOSE_READ (1<<1)
+#define TCL_CLOSE_WRITE (1<<2)
/*
* Value to use as the closeProc for a channel that supports the close2Proc
* interface.
*/
-#define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *)1)
+#define TCL_CLOSE2PROC ((Tcl_DriverCloseProc *) 1)
/*
* Channel version tag. This was introduced in 8.3.2/8.4.
@@ -1389,7 +1390,7 @@ typedef void (Tcl_ScaleTimeProc) _ANSI_ARGS_((Tcl_Time *timebuf,
#define TCL_CHANNEL_VERSION_5 ((Tcl_ChannelTypeVersion) 0x5)
/*
- * TIP #218: Channel Actions, Ids for Tcl_DriverThreadActionProc
+ * TIP #218: Channel Actions, Ids for Tcl_DriverThreadActionProc.
*/
#define TCL_CHANNEL_THREAD_INSERT (0)
@@ -1485,7 +1486,7 @@ typedef struct Tcl_ChannelType {
/* Set blocking mode for the raw channel. May
* be NULL. */
/*
- * Only valid in TCL_CHANNEL_VERSION_2 channels or later
+ * Only valid in TCL_CHANNEL_VERSION_2 channels or later.
*/
Tcl_DriverFlushProc *flushProc;
/* Function to call to flush a channel. May be
@@ -1495,7 +1496,7 @@ typedef struct Tcl_ChannelType {
* This will be passed up the stacked channel
* chain. */
/*
- * Only valid in TCL_CHANNEL_VERSION_3 channels or later
+ * Only valid in TCL_CHANNEL_VERSION_3 channels or later.
*/
Tcl_DriverWideSeekProc *wideSeekProc;
/* Function to call to seek on the channel
@@ -1503,8 +1504,8 @@ typedef struct Tcl_ChannelType {
* NULL, and must be NULL if seekProc is
* NULL. */
/*
- * Only valid in TCL_CHANNEL_VERSION_4 channels or later
- * TIP #218, Channel Thread Actions
+ * Only valid in TCL_CHANNEL_VERSION_4 channels or later.
+ * TIP #218, Channel Thread Actions.
*/
Tcl_DriverThreadActionProc *threadActionProc;
/* Function to call to notify the driver of
@@ -1512,8 +1513,8 @@ typedef struct Tcl_ChannelType {
* be NULL. */
/*
- * Only valid in TCL_CHANNEL_VERSION_5 channels or later
- * TIP #208, File Truncation
+ * Only valid in TCL_CHANNEL_VERSION_5 channels or later.
+ * TIP #208, File Truncation.
*/
Tcl_DriverTruncateProc *truncateProc;
/* Function to call to truncate the underlying
@@ -1547,14 +1548,14 @@ typedef enum Tcl_PathType {
*/
typedef struct Tcl_GlobTypeData {
- int type; /* Corresponds to bcdpfls as in 'find -t' */
- int perm; /* Corresponds to file permissions */
- Tcl_Obj *macType; /* Acceptable mac type */
- Tcl_Obj *macCreator; /* Acceptable mac creator */
+ int type; /* Corresponds to bcdpfls as in 'find -t'. */
+ int perm; /* Corresponds to file permissions. */
+ Tcl_Obj *macType; /* Acceptable Mac type. */
+ Tcl_Obj *macCreator; /* Acceptable Mac creator. */
} Tcl_GlobTypeData;
/*
- * Type and permission definitions for glob command
+ * Type and permission definitions for glob command.
*/
#define TCL_GLOB_TYPE_BLOCK (1<<0)
@@ -1573,7 +1574,7 @@ typedef struct Tcl_GlobTypeData {
#define TCL_GLOB_PERM_X (1<<4)
/*
- * Flags for the unload callback function
+ * Flags for the unload callback function.
*/
#define TCL_UNLOAD_DETACH_FROM_INTERPRETER (1<<0)
@@ -2157,9 +2158,9 @@ typedef unsigned short Tcl_UniChar;
typedef struct Tcl_Config {
CONST char *key; /* Configuration key to register. ASCII
- * encoded, thus UTF-8 */
+ * encoded, thus UTF-8. */
CONST char *value; /* The value associated with the key. System
- * encoding */
+ * encoding. */
} Tcl_Config;
/*
@@ -2192,7 +2193,7 @@ typedef unsigned int mp_digit;
* value since the stubs tables don't match.
*/
-#define TCL_STUB_MAGIC ((int)0xFCA3BACF)
+#define TCL_STUB_MAGIC ((int) 0xFCA3BACF)
/*
* The following function is required to be defined in all stubs aware
@@ -2297,7 +2298,7 @@ EXTERN void Tcl_GetMemoryInfo _ANSI_ARGS_((Tcl_DString *dsPtr));
# define Tcl_IncrRefCount(objPtr) \
++(objPtr)->refCount
/*
- * Use do/while0 idiom for optimum correctness without compiler warnings
+ * Use do/while0 idiom for optimum correctness without compiler warnings.
* http://c2.com/cgi/wiki?TrivialDoWhileLoop
*/
# define Tcl_DecrRefCount(objPtr) \
diff --git a/generic/tclTest.c b/generic/tclTest.c
index f92c0cd..7320f51 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclTest.c,v 1.114.2.4 2009/12/28 13:53:40 dkf Exp $
+ * RCS: @(#) $Id: tclTest.c,v 1.114.2.5 2010/01/29 09:38:48 nijtmans Exp $
*/
#define TCL_TEST
@@ -2212,9 +2212,13 @@ ExitProcOdd(
ClientData clientData) /* Integer value to print. */
{
char buf[16 + TCL_INTEGER_SPACE];
+ size_t len;
sprintf(buf, "odd %d\n", PTR2INT(clientData));
- (void)write(1, buf, strlen(buf));
+ len = strlen(buf);
+ if (write(1, buf, len) != len) {
+ Tcl_Panic("Tcl_FinalizeNotifier: unable to write q to triggerPipe");
+ }
}
static void
@@ -2222,9 +2226,13 @@ ExitProcEven(
ClientData clientData) /* Integer value to print. */
{
char buf[16 + TCL_INTEGER_SPACE];
+ size_t len;
sprintf(buf, "even %d\n", PTR2INT(clientData));
- (void)write(1, buf, strlen(buf));
+ len = strlen(buf);
+ if (write(1, buf, len) != len) {
+ Tcl_Panic("Tcl_FinalizeNotifier: unable to write q to triggerPipe");
+ }
}
/*
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 916951f..c1b5fd8 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixNotfy.c,v 1.34.2.1 2009/04/10 18:02:42 das Exp $
+ * RCS: @(#) $Id: tclUnixNotfy.c,v 1.34.2.2 2010/01/29 09:38:47 nijtmans Exp $
*/
#include "tclInt.h"
@@ -292,7 +292,9 @@ Tcl_FinalizeNotifier(
* 4139] [Bug: 1222872]
*/
- write(triggerPipe, "q", 1);
+ if (write(triggerPipe, "q", 1) != 1) {
+ Tcl_Panic("Tcl_FinalizeNotifier: unable to write q to triggerPipe");
+ }
close(triggerPipe);
while(triggerPipe >= 0) {
Tcl_ConditionWait(&notifierCV, &notifierMutex, NULL);
@@ -771,7 +773,9 @@ Tcl_WaitForEvent(
waitingListPtr = tsdPtr;
tsdPtr->onList = 1;
- write(triggerPipe, "", 1);
+ if (write(triggerPipe, "", 1) != 1) {
+ Tcl_Panic("Tcl_WaitForEvent: unable to write to triggerPipe");
+ }
}
FD_ZERO(&(tsdPtr->readyMasks.readable));
@@ -801,7 +805,9 @@ Tcl_WaitForEvent(
}
tsdPtr->nextPtr = tsdPtr->prevPtr = NULL;
tsdPtr->onList = 0;
- write(triggerPipe, "", 1);
+ if (write(triggerPipe, "", 1) != 1) {
+ Tcl_Panic("Tcl_WaitForEvent: unable to write to triggerPipe");
+ }
}
#else
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index 64b58a1..714979e 100644
--- a/unix/tclUnixPipe.c
+++ b/unix/tclUnixPipe.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixPipe.c,v 1.42 2008/03/14 16:32:52 rmax Exp $
+ * RCS: @(#) $Id: tclUnixPipe.c,v 1.42.2.1 2010/01/29 09:38:47 nijtmans Exp $
*/
#include "tclInt.h"
@@ -25,8 +25,8 @@
* the same as NULL.
*/
-#define MakeFile(fd) ((TclFile)INT2PTR(((int)(fd))+1))
-#define GetFd(file) (PTR2INT(file)-1)
+#define MakeFile(fd) ((TclFile) INT2PTR(((int) (fd)) + 1))
+#define GetFd(file) (PTR2INT(file) - 1)
/*
* This structure describes per-instance state of a pipe based channel.
@@ -85,7 +85,7 @@ static Tcl_ChannelType pipeChannelType = {
NULL, /* handler proc. */
NULL, /* wide seek proc */
NULL, /* thread action proc */
- NULL, /* truncation */
+ NULL /* truncation */
};
/*
@@ -436,6 +436,7 @@ TclpCreateProcess(
* might corrupt the parent: so ensure standard channels are initialized in
* the parent, otherwise SetupStdFile() might initialize them in the child.
*/
+
if (!inputFile) {
Tcl_GetStdChannel(TCL_STDIN);
}
@@ -446,8 +447,10 @@ TclpCreateProcess(
Tcl_GetStdChannel(TCL_STDERR);
}
#endif
+
pid = fork();
if (pid == 0) {
+ size_t len;
int joinThisError = errorFile && (errorFile == outputFile);
fd = GetFd(errPipeOut);
@@ -463,7 +466,10 @@ TclpCreateProcess(
((dup2(1,2) == -1) || (fcntl(2, F_SETFD, 0) != 0)))) {
sprintf(errSpace,
"%dforked process couldn't set up input/output: ", errno);
- (void)write(fd, errSpace, (size_t) strlen(errSpace));
+ len = strlen(errSpace);
+ if (len != (size_t) write(fd, errSpace, len)) {
+ Tcl_Panic("TclpCreateProcess: unable to write to errPipeOut");
+ }
_exit(1);
}
@@ -474,7 +480,10 @@ TclpCreateProcess(
RestoreSignals();
execvp(newArgv[0], newArgv); /* INTL: Native. */
sprintf(errSpace, "%dcouldn't execute \"%.150s\": ", errno, argv[0]);
- (void)write(fd, errSpace, (size_t) strlen(errSpace));
+ len = strlen(errSpace);
+ if (len != (size_t) write(fd, errSpace, len)) {
+ Tcl_Panic("TclpCreateProcess: unable to write to errPipeOut");
+ }
_exit(1);
}
@@ -1148,9 +1157,8 @@ Tcl_WaitPid(
int options)
{
int result;
- pid_t real_pid;
+ pid_t real_pid = (pid_t) PTR2INT(pid);
- real_pid = (pid_t) PTR2INT(pid);
while (1) {
result = (int) waitpid(real_pid, statPtr, options);
if ((result != -1) || (errno != EINTR)) {
@@ -1188,9 +1196,13 @@ Tcl_PidObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "?channelId?");
return TCL_ERROR;
}
+
if (objc == 1) {
Tcl_SetObjResult(interp, Tcl_NewLongObj((long) getpid()));
} else {
+ /*
+ * Get the channel and make sure that it refers to a pipe.
+ */
Tcl_Channel chan;
const Tcl_ChannelType *chanTypePtr;
PipeState *pipePtr;
@@ -1205,6 +1217,11 @@ Tcl_PidObjCmd(
if (chanTypePtr != &pipeChannelType) {
return TCL_OK;
}
+
+ /*
+ * Extract the process IDs from the pipe structure.
+ */
+
pipePtr = (PipeState *) Tcl_GetChannelInstanceData(chan);
resultPtr = Tcl_NewObj();
for (i = 0; i < pipePtr->numPids; i++) {