summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/ProcessUNIX.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-10-04 21:27:17 (GMT)
committerBrad King <brad.king@kitware.com>2006-10-04 21:27:17 (GMT)
commit40adb2ce0330020600424430fa52d743e4d504db (patch)
tree97121b6f5b2de801c8e1125cb67e67460dc180b8 /Source/kwsys/ProcessUNIX.c
parent6c19d3a86239882545ddc4dad11fe0c8d32f37ae (diff)
downloadCMake-40adb2ce0330020600424430fa52d743e4d504db.zip
CMake-40adb2ce0330020600424430fa52d743e4d504db.tar.gz
CMake-40adb2ce0330020600424430fa52d743e4d504db.tar.bz2
ENH: Adding tests KWSYS_C_HAS_PTRDIFF_T and KWSYS_C_HAS_SSIZE_T to help ProcessUNIX.c build everywhere without warnings.
Diffstat (limited to 'Source/kwsys/ProcessUNIX.c')
-rw-r--r--Source/kwsys/ProcessUNIX.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index afd9cd8..d0d29a7 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -47,6 +47,7 @@ do.
*/
+#include <stddef.h> /* ptrdiff_t */
#include <stdio.h> /* snprintf */
#include <stdlib.h> /* malloc, free */
#include <string.h> /* strdup, strerror, memset */
@@ -62,6 +63,18 @@ do.
#include <dirent.h> /* DIR, dirent */
#include <ctype.h> /* isspace */
+#if defined(KWSYS_C_HAS_PTRDIFF_T) && KWSYS_C_HAS_PTRDIFF_T
+typedef ptrdiff_t kwsysProcess_ptrdiff_t;
+#else
+typedef int kwsysProcess_ptrdiff_t;
+#endif
+
+#if defined(KWSYS_C_HAS_SSIZE_T) && KWSYS_C_HAS_SSIZE_T
+typedef ssize_t kwsysProcess_ssize_t;
+#else
+typedef int kwsysProcess_ssize_t;
+#endif
+
/* The number of pipes for the child's output. The standard stdout
and stderr pipes are the first two. One more pipe is used to
detect when the child process has terminated. The third pipe is
@@ -368,8 +381,8 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
{
/* Copy each argument string individually. */
char const* const* c = command;
- int n = 0;
- int i = 0;
+ kwsysProcess_ptrdiff_t n = 0;
+ kwsysProcess_ptrdiff_t i = 0;
while(*c++);
n = c - command - 1;
newCommands[cp->NumberOfCommands] = (char**)malloc((n+1)*sizeof(char*));
@@ -904,7 +917,7 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
if(cp->PipeReadEnds[i] >= 0 &&
FD_ISSET(cp->PipeReadEnds[i], &cp->PipeSet))
{
- int n;
+ kwsysProcess_ssize_t n;
/* We are handling this pipe now. Remove it from the set. */
FD_CLR(cp->PipeReadEnds[i], &cp->PipeSet);
@@ -1501,8 +1514,8 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
/* Block until the child's exec call succeeds and closes the error
pipe or writes data to the pipe to report an error. */
{
- int total = 0;
- int n = 1;
+ kwsysProcess_ssize_t total = 0;
+ kwsysProcess_ssize_t n = 1;
/* Read the entire error message up to the length of our buffer. */
while(total < KWSYSPE_PIPE_BUFFER_SIZE && n > 0)
{
@@ -2404,7 +2417,7 @@ static int kwsysProcessAppendByte(char* local,
/* Allocate space for the character. */
if((*end - *begin) >= *size)
{
- int length = *end - *begin;
+ kwsysProcess_ptrdiff_t length = *end - *begin;
char* newBuffer = (char*)malloc(*size*2);
if(!newBuffer)
{
@@ -2442,7 +2455,7 @@ static int kwsysProcessAppendArgument(char** local,
/* Allocate space for the argument pointer. */
if((*end - *begin) >= *size)
{
- int length = *end - *begin;
+ kwsysProcess_ptrdiff_t length = *end - *begin;
char** newPointers = (char**)malloc(*size*2*sizeof(char*));
if(!newPointers)
{
@@ -2615,14 +2628,14 @@ static char** kwsysProcessParseVerbatimCommand(const char* command)
buffer. */
if(!failed)
{
- int n = pointer_end - pointer_begin;
+ kwsysProcess_ptrdiff_t n = pointer_end - pointer_begin;
newCommand = (char**)malloc((n+1)*sizeof(char*));
}
if(newCommand)
{
/* Copy the arguments into the new command buffer. */
- int n = pointer_end - pointer_begin;
+ kwsysProcess_ptrdiff_t n = pointer_end - pointer_begin;
memcpy(newCommand, pointer_begin, sizeof(char*)*n);
newCommand[n] = 0;
}