diff --git a/GCC/libcpp/files.c b/GCC/libcpp/files.c index a109b67..6680c29 100644 --- a/GCC/libcpp/files.c +++ b/GCC/libcpp/files.c @@ -80,9 +80,9 @@ struct _cpp_file header. */ cpp_dir *dir; -/* BEGIN GCC-XML MODIFICATIONS (2008/02/07 15:15:10) */ +/* BEGIN GCC-XML MODIFICATIONS (2009/09/01 13:48:58) */ struct cpp_dir wrapper_dir; /* hack for supporting -iwrapper */ -/* END GCC-XML MODIFICATIONS (2008/02/07 15:15:10) */ +/* END GCC-XML MODIFICATIONS (2009/09/01 13:48:58) */ /* As filled in by stat(2) for the file. */ struct stat st; @@ -380,6 +380,12 @@ _cpp_find_failed (_cpp_file *file) return file->err_no != 0; } +/* The gccxml include wrapper path changes with each input file + because it wraps around double-quote locations too (so that system + headers including each other by double-quotes can be wrapped). + This does not interact well with search result caching. */ +#define GCCXML_DISABLE_INCLUDE_CACHE + /* Given a filename FNAME search for such a file in the include path starting from START_DIR. If FNAME is the empty string it is interpreted as STDIN if START_DIR is PFILE->no_search_path. @@ -397,7 +403,9 @@ _cpp_find_failed (_cpp_file *file) _cpp_file * _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool fake, int angle_brackets) { +#ifndef GCCXML_DISABLE_INCLUDE_CACHE struct file_hash_entry *entry, **hash_slot; +#endif _cpp_file *file; bool invalid_pch = false; @@ -405,6 +413,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f if (start_dir == NULL) cpp_error (pfile, CPP_DL_ICE, "NULL directory in find_file"); +#ifndef GCCXML_DISABLE_INCLUDE_CACHE hash_slot = (struct file_hash_entry **) htab_find_slot_with_hash (pfile->file_hash, fname, htab_hash_string (fname), @@ -414,6 +423,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f entry = search_cache (*hash_slot, start_dir); if (entry) return entry->u.file; +#endif file = make_cpp_file (pfile, start_dir, fname); @@ -449,6 +459,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f break; } +#ifndef GCCXML_DISABLE_INCLUDE_CACHE /* Only check the cache for the starting location (done above) and the quote and bracket chain heads because there are no other possible starting points for searches. */ @@ -459,8 +470,10 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f entry = search_cache (*hash_slot, file->dir); if (entry) break; +#endif } +#ifndef GCCXML_DISABLE_INCLUDE_CACHE if (entry) { /* Cache for START_DIR too, sharing the _cpp_file structure. */ @@ -469,18 +482,21 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f file = entry->u.file; } else +#endif { /* This is a new file; put it in the list. */ file->next_file = pfile->all_files; pfile->all_files = file; } +#ifndef GCCXML_DISABLE_INCLUDE_CACHE /* Store this new result in the hash table. */ entry = new_file_hash_entry (pfile); entry->next = *hash_slot; entry->start_dir = start_dir; entry->u.file = file; *hash_slot = entry; +#endif return file; } @@ -821,7 +837,7 @@ _cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets, if (!dir) return false; -/* BEGIN GCC-XML MODIFICATIONS (2008/02/07 15:15:10) */ +/* BEGIN GCC-XML MODIFICATIONS (2009/09/01 13:48:58) */ /* pfile->buffer is NULL when processing an -include command-line flag. */ file = pfile->buffer == NULL ? pfile->main_file : pfile->buffer->file; @@ -854,7 +870,7 @@ _cpp_stack_include (cpp_reader *pfile, const char *fname, int angle_brackets, { file = _cpp_find_file (pfile, fname, dir, false, angle_brackets); } -/* END GCC-XML MODIFICATIONS (2008/02/07 15:15:10) */ +/* END GCC-XML MODIFICATIONS (2009/09/01 13:48:58) */ /* Compensate for the increment in linemap_add. In the case of a normal #include, we're currently at the start of the line @@ -1198,14 +1214,14 @@ _cpp_get_file_stat (_cpp_file *file) If BRACKET does not lie in the QUOTE chain, it is set to QUOTE. */ void cpp_set_include_chains (cpp_reader *pfile, cpp_dir *quote, cpp_dir *bracket, -/* BEGIN GCC-XML MODIFICATIONS (2008/02/07 15:15:10) */ +/* BEGIN GCC-XML MODIFICATIONS (2009/09/01 13:48:58) */ cpp_dir *wrapper, -/* END GCC-XML MODIFICATIONS (2008/02/07 15:15:10) */ +/* END GCC-XML MODIFICATIONS (2009/09/01 13:48:58) */ int quote_ignores_source_dir) { pfile->quote_include = quote; pfile->bracket_include = quote; -/* BEGIN GCC-XML MODIFICATIONS (2008/02/07 15:15:10) */ +/* BEGIN GCC-XML MODIFICATIONS (2009/09/01 13:48:58) */ pfile->wrapper_include = wrapper; pfile->wrapper_include_last = 0; for (; wrapper; wrapper = wrapper->next) @@ -1214,7 +1230,7 @@ cpp_set_include_chains (cpp_reader *pfile, cpp_dir *quote, cpp_dir *bracket, wrapper->len = strlen (wrapper->name); pfile->wrapper_include_last = wrapper; } -/* END GCC-XML MODIFICATIONS (2008/02/07 15:15:10) */ +/* END GCC-XML MODIFICATIONS (2009/09/01 13:48:58) */ pfile->quote_ignores_source_dir = quote_ignores_source_dir; for (; quote; quote = quote->next) diff --git a/GCC_XML/GXFront/gxConfiguration.cxx b/GCC_XML/GXFront/gxConfiguration.cxx index 456b1b7..b80b182 100644 --- a/GCC_XML/GXFront/gxConfiguration.cxx +++ b/GCC_XML/GXFront/gxConfiguration.cxx @@ -1466,6 +1466,12 @@ bool gxConfiguration::FindFlagsGCC() { if(reDefine.find(it->c_str())) { + // __BLOCKS__ is an Apple extension to gcc unknown to gccxml. + if(reDefine.match(1) == "__BLOCKS__") + { + continue; + } + if (MACROS == "") { MACROS = "-D"; diff --git a/GCC_XML/KWSys/CMakeLists.txt b/GCC_XML/KWSys/CMakeLists.txt index 145e43a..f1f95f7 100644 --- a/GCC_XML/KWSys/CMakeLists.txt +++ b/GCC_XML/KWSys/CMakeLists.txt @@ -337,14 +337,19 @@ ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) #----------------------------------------------------------------------------- # Configure Large File Support. +KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDIO + "Checking whether header cstdio is available" DIRECT) SET(KWSYS_LFS_AVAILABLE 0) IF(KWSYS_LFS_REQUESTED) # Large File Support is requested. SET(KWSYS_LFS_REQUESTED 1) # Check for large file support. + SET(KWSYS_PLATFORM_CXX_TEST_DEFINES + -DKWSYS_CXX_HAS_CSTDIO=${KWSYS_CXX_HAS_CSTDIO}) KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_LFS_WORKS "Checking for Large File Support" DIRECT) + SET(KWSYS_PLATFORM_CXX_TEST_DEFINES) IF(KWSYS_LFS_WORKS) SET(KWSYS_LFS_AVAILABLE 1) @@ -442,6 +447,11 @@ ELSE(KWSYS_IOS_USE_ANSI AND NOT WATCOM) KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_ISTREAM "Checking whether stl string has istream operator>>" DIRECT) ENDIF(KWSYS_IOS_USE_ANSI AND NOT WATCOM) +SET(KWSYS_PLATFORM_CXX_TEST_DEFINES + -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} + -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}) +KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAVE_BINARY + "Checking whether ios has binary openmode" DIRECT) SET(KWSYS_PLATFORM_CXX_TEST_DEFINES) KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS diff --git a/GCC_XML/KWSys/Configure.hxx.in b/GCC_XML/KWSys/Configure.hxx.in index 4916c12..444f46f 100644 --- a/GCC_XML/KWSys/Configure.hxx.in +++ b/GCC_XML/KWSys/Configure.hxx.in @@ -32,6 +32,9 @@ /* Whether old C++ header is to be used. */ #define @KWSYS_NAMESPACE@_IOS_USE_STRSTREA_H @KWSYS_IOS_USE_STRSTREA_H@ +/* Whether C++ streams support the ios::binary openmode. */ +#define @KWSYS_NAMESPACE@_IOS_HAVE_BINARY @KWSYS_IOS_HAVE_BINARY@ + /* Whether STL is in std namespace. */ #define @KWSYS_NAMESPACE@_STL_HAVE_STD @KWSYS_STL_HAVE_STD@ @@ -63,6 +66,13 @@ # define @KWSYS_NAMESPACE@_ios @KWSYS_NAMESPACE@_ios #endif +/* Define the ios::binary openmode macro. */ +#if @KWSYS_NAMESPACE@_IOS_HAVE_BINARY +# define @KWSYS_NAMESPACE@_ios_binary @KWSYS_NAMESPACE@_ios::ios::binary +#else +# define @KWSYS_NAMESPACE@_ios_binary 0 +#endif + /* Whether the cstddef header is available. */ #define @KWSYS_NAMESPACE@_CXX_HAS_CSTDDEF @KWSYS_CXX_HAS_CSTDDEF@ @@ -133,6 +143,7 @@ # define kwsys_stl @KWSYS_NAMESPACE@_stl # define kwsys_ios @KWSYS_NAMESPACE@_ios # define kwsys @KWSYS_NAMESPACE@ +# define kwsys_ios_binary @KWSYS_NAMESPACE@_ios_binary # endif # define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS # define KWSYS_STL_HAVE_STD @KWSYS_NAMESPACE@_STL_HAVE_STD @@ -141,6 +152,7 @@ # define KWSYS_IOS_USE_SSTREAM @KWSYS_NAMESPACE@_IOS_USE_SSTREAM # define KWSYS_IOS_USE_STRSTREAM_H @KWSYS_NAMESPACE@_IOS_USE_STRSTREAM_H # define KWSYS_IOS_USE_STRSTREA_H @KWSYS_NAMESPACE@_IOS_USE_STRSTREA_H +# define KWSYS_IOS_HAVE_BINARY @KWSYS_NAMESPACE@_IOS_HAVE_BINARY # define KWSYS_STAT_HAS_ST_MTIM @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM # define KWSYS_CXX_HAS_CSTDDEF @KWSYS_NAMESPACE@_CXX_HAS_CSTDDEF # define KWSYS_STL_STRING_HAVE_OSTREAM @KWSYS_NAMESPACE@_STL_STRING_HAVE_OSTREAM diff --git a/GCC_XML/KWSys/Glob.cxx b/GCC_XML/KWSys/Glob.cxx index f3a952d..edf98db 100644 --- a/GCC_XML/KWSys/Glob.cxx +++ b/GCC_XML/KWSys/Glob.cxx @@ -84,7 +84,8 @@ kwsys_stl::vector& Glob::GetFiles() //---------------------------------------------------------------------------- kwsys_stl::string Glob::PatternToRegex(const kwsys_stl::string& pattern, - bool require_whole_string) + bool require_whole_string, + bool preserve_case) { // Incrementally build the regular expression from the pattern. kwsys_stl::string regex = require_whole_string? "^" : ""; @@ -195,10 +196,13 @@ kwsys_stl::string Glob::PatternToRegex(const kwsys_stl::string& pattern, { // On case-insensitive systems file names are converted to lower // case before matching. - ch = tolower(ch); + if(!preserve_case) + { + ch = tolower(ch); + } } #endif - + (void)preserve_case; // Store the character. regex.append(1, static_cast(ch)); } diff --git a/GCC_XML/KWSys/Glob.hxx.in b/GCC_XML/KWSys/Glob.hxx.in index 690dad9..1620dfe 100644 --- a/GCC_XML/KWSys/Glob.hxx.in +++ b/GCC_XML/KWSys/Glob.hxx.in @@ -79,7 +79,8 @@ public: whole strings, but may be disabled to support concatenating expressions more easily (regex1|regex2|etc). */ static kwsys_stl::string PatternToRegex(const kwsys_stl::string& pattern, - bool require_whole_string = true); + bool require_whole_string = true, + bool preserve_case = false); protected: //! Process directory diff --git a/GCC_XML/KWSys/MD5.c b/GCC_XML/KWSys/MD5.c index 14db0b9..b7ec4a2 100644 --- a/GCC_XML/KWSys/MD5.c +++ b/GCC_XML/KWSys/MD5.c @@ -20,6 +20,7 @@ # include "MD5.h.in" #endif +#include /* size_t */ #include /* malloc, free */ #include /* memcpy, strlen */ @@ -238,7 +239,8 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) # define xbuf X /* (static only) */ # endif for (i = 0; i < 16; ++i, xp += 4) - xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); + xbuf[i] = (md5_word_t)(xp[0] + (xp[1] << 8) + + (xp[2] << 16) + (xp[3] << 24)); } #endif } @@ -369,25 +371,25 @@ static void md5_init(md5_state_t *pms) } /* Append a string to the message. */ -static void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) +static void md5_append(md5_state_t *pms, const md5_byte_t *data, size_t nbytes) { const md5_byte_t *p = data; - int left = nbytes; - int offset = (pms->count[0] >> 3) & 63; + size_t left = nbytes; + size_t offset = (pms->count[0] >> 3) & 63; md5_word_t nbits = (md5_word_t)(nbytes << 3); if (nbytes <= 0) return; /* Update the message length. */ - pms->count[1] += nbytes >> 29; + pms->count[1] += (md5_word_t)(nbytes >> 29); pms->count[0] += nbits; if (pms->count[0] < nbits) pms->count[1]++; /* Process an initial partial block. */ if (offset) { - int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); + size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes); memcpy(pms->buf + offset, p, copy); if (offset + copy < 64) @@ -474,7 +476,7 @@ void kwsysMD5_Append(kwsysMD5* md5, unsigned char const* data, int length) { length = (int)strlen((char const*)data); } - md5_append(&md5->md5_state, (md5_byte_t const*)data, length); + md5_append(&md5->md5_state, (md5_byte_t const*)data, (size_t)length); } /*--------------------------------------------------------------------------*/ diff --git a/GCC_XML/KWSys/ProcessUNIX.c b/GCC_XML/KWSys/ProcessUNIX.c index 101af1e..df74658 100644 --- a/GCC_XML/KWSys/ProcessUNIX.c +++ b/GCC_XML/KWSys/ProcessUNIX.c @@ -13,11 +13,13 @@ =========================================================================*/ #include "kwsysPrivate.h" #include KWSYS_HEADER(Process.h) +#include KWSYS_HEADER(System.h) /* Work-around CMake dependency scanning limitation. This must duplicate the above list of headers. */ #if 0 # include "Process.h.in" +# include "System.h.in" #endif /* @@ -187,7 +189,6 @@ static void kwsysProcessesSignalHandler(int signum, siginfo_t* info, #else static void kwsysProcessesSignalHandler(int signum); #endif -static char** kwsysProcessParseVerbatimCommand(const char* command); /*--------------------------------------------------------------------------*/ /* Structure containing data used to implement the child's execution. */ @@ -422,7 +423,7 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) /* In order to run the given command line verbatim we need to parse it. */ newCommands[cp->NumberOfCommands] = - kwsysProcessParseVerbatimCommand(*command); + kwsysSystem_Parse_CommandForUnix(*command, 0); if(!newCommands[cp->NumberOfCommands]) { /* Out of memory. */ @@ -2729,257 +2730,3 @@ static void kwsysProcessesSignalHandler(int signum } #endif } - -/*--------------------------------------------------------------------------*/ -static int kwsysProcessAppendByte(char* local, - char** begin, char** end, - int* size, char c) -{ - /* Allocate space for the character. */ - if((*end - *begin) >= *size) - { - kwsysProcess_ptrdiff_t length = *end - *begin; - char* newBuffer = (char*)malloc((size_t)(*size*2)); - if(!newBuffer) - { - return 0; - } - memcpy(newBuffer, *begin, (size_t)(length)*sizeof(char)); - if(*begin != local) - { - free(*begin); - } - *begin = newBuffer; - *end = *begin + length; - *size *= 2; - } - - /* Store the character. */ - *(*end)++ = c; - return 1; -} - -/*--------------------------------------------------------------------------*/ -static int kwsysProcessAppendArgument(char** local, - char*** begin, char*** end, - int* size, - char* arg_local, - char** arg_begin, char** arg_end, - int* arg_size) -{ - /* Append a null-terminator to the argument string. */ - if(!kwsysProcessAppendByte(arg_local, arg_begin, arg_end, arg_size, '\0')) - { - return 0; - } - - /* Allocate space for the argument pointer. */ - if((*end - *begin) >= *size) - { - kwsysProcess_ptrdiff_t length = *end - *begin; - char** newPointers = (char**)malloc((size_t)(*size)*2*sizeof(char*)); - if(!newPointers) - { - return 0; - } - memcpy(newPointers, *begin, (size_t)(length)*sizeof(char*)); - if(*begin != local) - { - free(*begin); - } - *begin = newPointers; - *end = *begin + length; - *size *= 2; - } - - /* Allocate space for the argument string. */ - **end = (char*)malloc((size_t)(*arg_end - *arg_begin)); - if(!**end) - { - return 0; - } - - /* Store the argument in the command array. */ - memcpy(**end, *arg_begin,(size_t)(*arg_end - *arg_begin)); - ++(*end); - - /* Reset the argument to be empty. */ - *arg_end = *arg_begin; - - return 1; -} - -/*--------------------------------------------------------------------------*/ -#define KWSYSPE_LOCAL_BYTE_COUNT 1024 -#define KWSYSPE_LOCAL_ARGS_COUNT 32 -static char** kwsysProcessParseVerbatimCommand(const char* command) -{ - /* Create a buffer for argument pointers during parsing. */ - char* local_pointers[KWSYSPE_LOCAL_ARGS_COUNT]; - int pointers_size = KWSYSPE_LOCAL_ARGS_COUNT; - char** pointer_begin = local_pointers; - char** pointer_end = pointer_begin; - - /* Create a buffer for argument strings during parsing. */ - char local_buffer[KWSYSPE_LOCAL_BYTE_COUNT]; - int buffer_size = KWSYSPE_LOCAL_BYTE_COUNT; - char* buffer_begin = local_buffer; - char* buffer_end = buffer_begin; - - /* Parse the command string. Try to behave like a UNIX shell. */ - char** newCommand = 0; - const char* c = command; - int in_argument = 0; - int in_escape = 0; - int in_single = 0; - int in_double = 0; - int failed = 0; - for(;*c; ++c) - { - if(in_escape) - { - /* This character is escaped so do no special handling. */ - if(!in_argument) - { - in_argument = 1; - } - if(!kwsysProcessAppendByte(local_buffer, &buffer_begin, - &buffer_end, &buffer_size, *c)) - { - failed = 1; - break; - } - in_escape = 0; - } - else if(*c == '\\' && !in_single) - { - /* The next character should be escaped. */ - in_escape = 1; - } - else if(*c == '\'' && !in_double) - { - /* Enter or exit single-quote state. */ - if(in_single) - { - in_single = 0; - } - else - { - in_single = 1; - if(!in_argument) - { - in_argument = 1; - } - } - } - else if(*c == '"' && !in_single) - { - /* Enter or exit double-quote state. */ - if(in_double) - { - in_double = 0; - } - else - { - in_double = 1; - if(!in_argument) - { - in_argument = 1; - } - } - } - else if(isspace((unsigned char) *c)) - { - if(in_argument) - { - if(in_single || in_double) - { - /* This space belongs to a quoted argument. */ - if(!kwsysProcessAppendByte(local_buffer, &buffer_begin, - &buffer_end, &buffer_size, *c)) - { - failed = 1; - break; - } - } - else - { - /* This argument has been terminated by whitespace. */ - if(!kwsysProcessAppendArgument(local_pointers, &pointer_begin, - &pointer_end, &pointers_size, - local_buffer, &buffer_begin, - &buffer_end, &buffer_size)) - { - failed = 1; - break; - } - in_argument = 0; - } - } - } - else - { - /* This character belong to an argument. */ - if(!in_argument) - { - in_argument = 1; - } - if(!kwsysProcessAppendByte(local_buffer, &buffer_begin, - &buffer_end, &buffer_size, *c)) - { - failed = 1; - break; - } - } - } - - /* Finish the last argument. */ - if(in_argument) - { - if(!kwsysProcessAppendArgument(local_pointers, &pointer_begin, - &pointer_end, &pointers_size, - local_buffer, &buffer_begin, - &buffer_end, &buffer_size)) - { - failed = 1; - } - } - - /* If we still have memory allocate space for the new command - buffer. */ - if(!failed) - { - kwsysProcess_ptrdiff_t n = pointer_end - pointer_begin; - newCommand = (char**)malloc((size_t)(n+1)*sizeof(char*)); - } - - if(newCommand) - { - /* Copy the arguments into the new command buffer. */ - kwsysProcess_ptrdiff_t n = pointer_end - pointer_begin; - memcpy(newCommand, pointer_begin, sizeof(char*)*(size_t)(n)); - newCommand[n] = 0; - } - else - { - /* Free arguments already allocated. */ - while(pointer_end != pointer_begin) - { - free(*(--pointer_end)); - } - } - - /* Free temporary buffers. */ - if(pointer_begin != local_pointers) - { - free(pointer_begin); - } - if(buffer_begin != local_buffer) - { - free(buffer_begin); - } - - /* Return the final command buffer. */ - return newCommand; -} - diff --git a/GCC_XML/KWSys/RegularExpression.hxx.in b/GCC_XML/KWSys/RegularExpression.hxx.in index 827452a..98c93a3 100644 --- a/GCC_XML/KWSys/RegularExpression.hxx.in +++ b/GCC_XML/KWSys/RegularExpression.hxx.in @@ -42,6 +42,12 @@ # define kwsys_stl @KWSYS_NAMESPACE@_stl #endif +/* Disable useless Borland warnings. KWSys tries not to force things + on its includers, but there is no choice here. */ +#if defined(__BORLANDC__) +# pragma warn -8027 /* function not inlined. */ +#endif + namespace @KWSYS_NAMESPACE@ { diff --git a/GCC_XML/KWSys/SharedForward.h.in b/GCC_XML/KWSys/SharedForward.h.in index 5b0b2ee..a7c34c0 100644 --- a/GCC_XML/KWSys/SharedForward.h.in +++ b/GCC_XML/KWSys/SharedForward.h.in @@ -147,6 +147,7 @@ /*--------------------------------------------------------------------------*/ /* Include needed system headers. */ +#include /* size_t */ #include #include #include @@ -219,7 +220,7 @@ static const char kwsys_shared_forward_path_slash[2] = {KWSYS_SHARED_FORWARD_PAT #endif /* SUN */ -#if defined(__sparc) +#if defined(__sparc) && !defined(__linux) # define KWSYS_SHARED_FORWARD_LDD "ldd" # define KWSYS_SHARED_FORWARD_LDD_N 1 # include @@ -482,13 +483,14 @@ static void kwsys_shared_forward_strerror(char* message) /*--------------------------------------------------------------------------*/ /* Functions to execute a child process. */ -static void kwsys_shared_forward_execvp(const char* cmd, char* const* argv) +static void kwsys_shared_forward_execvp(const char* cmd, + char const* const* argv) { #ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV /* Count the number of arguments. */ int argc = 0; { - char* const* argvc; + char const* const* argvc; for(argvc = argv; *argvc; ++argvc,++argc) {} } @@ -505,7 +507,7 @@ static void kwsys_shared_forward_execvp(const char* cmd, char* const* argv) nargv[argc] = 0; /* Replace the command line to be used. */ - argv = nargv; + argv = (char const* const*)nargv; } #endif @@ -513,10 +515,9 @@ static void kwsys_shared_forward_execvp(const char* cmd, char* const* argv) #if defined(_MSC_VER) _execvp(cmd, argv); #elif defined(__MINGW32__) - /* Avoid incompatible pointer warning with a cast. */ - execvp(cmd, (char const* const*)argv); -#else execvp(cmd, argv); +#else + execvp(cmd, (char* const*)argv); #endif } @@ -550,7 +551,7 @@ static void kwsys_shared_forward_dirname(const char* begin, char* result) else if(last_slash_index == 2 && begin[1] == ':') { /* Only one leading drive letter and slash. */ - strncpy(result, begin, last_slash_index); + strncpy(result, begin, (size_t)last_slash_index); result[last_slash_index] = KWSYS_SHARED_FORWARD_PATH_SLASH; result[last_slash_index+1] = 0; } @@ -558,7 +559,7 @@ static void kwsys_shared_forward_dirname(const char* begin, char* result) else { /* A non-leading slash. */ - strncpy(result, begin, last_slash_index); + strncpy(result, begin, (size_t)last_slash_index); result[last_slash_index] = 0; } } @@ -630,7 +631,7 @@ static int kwsys_shared_forward_self_path(const char* argv0, char* result) if(first < last) { /* Determine the length without trailing slash. */ - int length = (int)(last-first); + size_t length = (size_t)(last-first); if(*(last-1) == '/' || *(last-1) == '\\') { --length; @@ -800,10 +801,10 @@ static int kwsys_shared_forward_get_settings(const char* self_path, /*--------------------------------------------------------------------------*/ /* Function to print why execution of a command line failed. */ -static void kwsys_shared_forward_print_failure(char** argv) +static void kwsys_shared_forward_print_failure(char const* const* argv) { char msg[KWSYS_SHARED_FORWARD_MAXPATH]; - char** arg = argv; + char const* const* arg = argv; kwsys_shared_forward_strerror(msg); fprintf(stderr, "Error running"); for(; *arg; ++arg) @@ -818,8 +819,9 @@ static char kwsys_shared_forward_ldpath[KWSYS_SHARED_FORWARD_MAXPATH*16] = KWSYS /*--------------------------------------------------------------------------*/ /* Main driver function to be called from main. */ -static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv) +static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in) { + char const** argv = (char const**)argv_in; /* Get the directory containing this executable. */ char self_path[KWSYS_SHARED_FORWARD_MAXPATH]; if(kwsys_shared_forward_self_path(argv[0], self_path)) @@ -877,7 +879,7 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv) { # if defined(KWSYS_SHARED_FORWARD_LDD) /* Use the named ldd-like executable and arguments. */ - char* ldd_argv[] = {KWSYS_SHARED_FORWARD_LDD, 0, 0}; + char const* ldd_argv[] = {KWSYS_SHARED_FORWARD_LDD, 0, 0}; ldd_argv[KWSYS_SHARED_FORWARD_LDD_N] = exe; kwsys_shared_forward_execvp(ldd_argv[0], ldd_argv); diff --git a/GCC_XML/KWSys/System.c b/GCC_XML/KWSys/System.c index 2208361..6c9f542 100644 --- a/GCC_XML/KWSys/System.c +++ b/GCC_XML/KWSys/System.c @@ -20,11 +20,19 @@ # include "System.h.in" #endif +#include /* ptrdiff_t */ +#include /* malloc, free */ #include /* strlen */ #include /* isalpha */ #include +#if defined(KWSYS_C_HAS_PTRDIFF_T) && KWSYS_C_HAS_PTRDIFF_T +typedef ptrdiff_t kwsysSystem_ptrdiff_t; +#else +typedef int kwsysSystem_ptrdiff_t; +#endif + /* Notes: @@ -579,3 +587,272 @@ int kwsysSystem_Shell_GetArgumentSizeForUnix(const char* in, int flags) { return kwsysSystem_Shell__GetArgumentSize(in, 1, flags); } + +/*--------------------------------------------------------------------------*/ +static int kwsysSystem__AppendByte(char* local, + char** begin, char** end, + int* size, char c) +{ + /* Allocate space for the character. */ + if((*end - *begin) >= *size) + { + kwsysSystem_ptrdiff_t length = *end - *begin; + char* newBuffer = (char*)malloc((size_t)(*size*2)); + if(!newBuffer) + { + return 0; + } + memcpy(newBuffer, *begin, (size_t)(length)*sizeof(char)); + if(*begin != local) + { + free(*begin); + } + *begin = newBuffer; + *end = *begin + length; + *size *= 2; + } + + /* Store the character. */ + *(*end)++ = c; + return 1; +} + +/*--------------------------------------------------------------------------*/ +static int kwsysSystem__AppendArgument(char** local, + char*** begin, char*** end, + int* size, + char* arg_local, + char** arg_begin, char** arg_end, + int* arg_size) +{ + /* Append a null-terminator to the argument string. */ + if(!kwsysSystem__AppendByte(arg_local, arg_begin, arg_end, arg_size, '\0')) + { + return 0; + } + + /* Allocate space for the argument pointer. */ + if((*end - *begin) >= *size) + { + kwsysSystem_ptrdiff_t length = *end - *begin; + char** newPointers = (char**)malloc((size_t)(*size)*2*sizeof(char*)); + if(!newPointers) + { + return 0; + } + memcpy(newPointers, *begin, (size_t)(length)*sizeof(char*)); + if(*begin != local) + { + free(*begin); + } + *begin = newPointers; + *end = *begin + length; + *size *= 2; + } + + /* Allocate space for the argument string. */ + **end = (char*)malloc((size_t)(*arg_end - *arg_begin)); + if(!**end) + { + return 0; + } + + /* Store the argument in the command array. */ + memcpy(**end, *arg_begin,(size_t)(*arg_end - *arg_begin)); + ++(*end); + + /* Reset the argument to be empty. */ + *arg_end = *arg_begin; + + return 1; +} + +/*--------------------------------------------------------------------------*/ +#define KWSYSPE_LOCAL_BYTE_COUNT 1024 +#define KWSYSPE_LOCAL_ARGS_COUNT 32 +static char** kwsysSystem__ParseUnixCommand(const char* command, int flags) +{ + /* Create a buffer for argument pointers during parsing. */ + char* local_pointers[KWSYSPE_LOCAL_ARGS_COUNT]; + int pointers_size = KWSYSPE_LOCAL_ARGS_COUNT; + char** pointer_begin = local_pointers; + char** pointer_end = pointer_begin; + + /* Create a buffer for argument strings during parsing. */ + char local_buffer[KWSYSPE_LOCAL_BYTE_COUNT]; + int buffer_size = KWSYSPE_LOCAL_BYTE_COUNT; + char* buffer_begin = local_buffer; + char* buffer_end = buffer_begin; + + /* Parse the command string. Try to behave like a UNIX shell. */ + char** newCommand = 0; + const char* c = command; + int in_argument = 0; + int in_escape = 0; + int in_single = 0; + int in_double = 0; + int failed = 0; + for(;*c; ++c) + { + if(in_escape) + { + /* This character is escaped so do no special handling. */ + if(!in_argument) + { + in_argument = 1; + } + if(!kwsysSystem__AppendByte(local_buffer, &buffer_begin, + &buffer_end, &buffer_size, *c)) + { + failed = 1; + break; + } + in_escape = 0; + } + else if(*c == '\\') + { + /* The next character should be escaped. */ + in_escape = 1; + } + else if(*c == '\'' && !in_double) + { + /* Enter or exit single-quote state. */ + if(in_single) + { + in_single = 0; + } + else + { + in_single = 1; + if(!in_argument) + { + in_argument = 1; + } + } + } + else if(*c == '"' && !in_single) + { + /* Enter or exit double-quote state. */ + if(in_double) + { + in_double = 0; + } + else + { + in_double = 1; + if(!in_argument) + { + in_argument = 1; + } + } + } + else if(isspace((unsigned char) *c)) + { + if(in_argument) + { + if(in_single || in_double) + { + /* This space belongs to a quoted argument. */ + if(!kwsysSystem__AppendByte(local_buffer, &buffer_begin, + &buffer_end, &buffer_size, *c)) + { + failed = 1; + break; + } + } + else + { + /* This argument has been terminated by whitespace. */ + if(!kwsysSystem__AppendArgument(local_pointers, &pointer_begin, + &pointer_end, &pointers_size, + local_buffer, &buffer_begin, + &buffer_end, &buffer_size)) + { + failed = 1; + break; + } + in_argument = 0; + } + } + } + else + { + /* This character belong to an argument. */ + if(!in_argument) + { + in_argument = 1; + } + if(!kwsysSystem__AppendByte(local_buffer, &buffer_begin, + &buffer_end, &buffer_size, *c)) + { + failed = 1; + break; + } + } + } + + /* Finish the last argument. */ + if(in_argument) + { + if(!kwsysSystem__AppendArgument(local_pointers, &pointer_begin, + &pointer_end, &pointers_size, + local_buffer, &buffer_begin, + &buffer_end, &buffer_size)) + { + failed = 1; + } + } + + /* If we still have memory allocate space for the new command + buffer. */ + if(!failed) + { + kwsysSystem_ptrdiff_t n = pointer_end - pointer_begin; + newCommand = (char**)malloc((size_t)(n+1)*sizeof(char*)); + } + + if(newCommand) + { + /* Copy the arguments into the new command buffer. */ + kwsysSystem_ptrdiff_t n = pointer_end - pointer_begin; + memcpy(newCommand, pointer_begin, sizeof(char*)*(size_t)(n)); + newCommand[n] = 0; + } + else + { + /* Free arguments already allocated. */ + while(pointer_end != pointer_begin) + { + free(*(--pointer_end)); + } + } + + /* Free temporary buffers. */ + if(pointer_begin != local_pointers) + { + free(pointer_begin); + } + if(buffer_begin != local_buffer) + { + free(buffer_begin); + } + + /* The flags argument is currently unused. */ + (void)flags; + + /* Return the final command buffer. */ + return newCommand; +} + +/*--------------------------------------------------------------------------*/ +char** kwsysSystem_Parse_CommandForUnix(const char* command, int flags) +{ + /* Validate the flags. */ + if(flags != 0) + { + return 0; + } + + /* Forward to our internal implementation. */ + return kwsysSystem__ParseUnixCommand(command, flags); +} diff --git a/GCC_XML/KWSys/System.h.in b/GCC_XML/KWSys/System.h.in index f6b531a..e75330c 100644 --- a/GCC_XML/KWSys/System.h.in +++ b/GCC_XML/KWSys/System.h.in @@ -25,6 +25,7 @@ # define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT #endif #if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# define kwsysSystem_Parse_CommandForUnix kwsys_ns(System_Parse_CommandForUnix) # define kwsysSystem_Shell_GetArgumentForWindows kwsys_ns(System_Shell_GetArgumentForWindows) # define kwsysSystem_Shell_GetArgumentForUnix kwsys_ns(System_Shell_GetArgumentForUnix) # define kwsysSystem_Shell_GetArgumentSizeForWindows kwsys_ns(System_Shell_GetArgumentSizeForWindows) @@ -113,6 +114,27 @@ enum kwsysSystem_Shell_Flag_e kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<5) }; +/** + * Parse a unix-style command line string into separate arguments. + * + * On success, returns a pointer to an array of pointers to individual + * argument strings. Each string is null-terminated and the last + * entry in the array is a NULL pointer (just like argv). It is the + * caller's responsibility to free() the strings and the array of + * pointers to them. + * + * On failure, returns NULL. Failure occurs only on invalid flags or + * when memory cannot be allocated; never due to content of the input + * string. Missing close-quotes are treated as if the necessary + * closing quote appears. + * + * By default single- and double-quoted arguments are supported, and + * any character may be escaped by a backslash. The flags argument is + * reserved for future use, and must be zero (or the call will fail). + */ +kwsysEXPORT char** kwsysSystem_Parse_CommandForUnix(const char* command, + int flags); + #if defined(__cplusplus) } /* extern "C" */ #endif @@ -123,6 +145,7 @@ enum kwsysSystem_Shell_Flag_e # undef kwsys_ns # undef kwsysEXPORT # if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# undef kwsysSystem_Parse_CommandForUnix # undef kwsysSystem_Shell_GetArgumentForWindows # undef kwsysSystem_Shell_GetArgumentForUnix # undef kwsysSystem_Shell_GetArgumentSizeForWindows diff --git a/GCC_XML/KWSys/SystemTools.cxx b/GCC_XML/KWSys/SystemTools.cxx index 21cd59f..ac15898 100644 --- a/GCC_XML/KWSys/SystemTools.cxx +++ b/GCC_XML/KWSys/SystemTools.cxx @@ -3325,18 +3325,18 @@ ::JoinPath(kwsys_stl::vector::const_iterator first, // The first two components do not add a slash. if(first != last) { - result += *first++; + result.append(*first++); } if(first != last) { - result += *first++; + result.append(*first++); } // All remaining components are always separated with a slash. while(first != last) { - result += "/"; - result += *first++; + result.append("/"); + result.append((*first++)); } // Return the concatenated result. diff --git a/GCC_XML/KWSys/kwsysDateStamp.cmake b/GCC_XML/KWSys/kwsysDateStamp.cmake index 9ae14f8..8e64e4a 100644 --- a/GCC_XML/KWSys/kwsysDateStamp.cmake +++ b/GCC_XML/KWSys/kwsysDateStamp.cmake @@ -4,7 +4,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2009) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 06) +SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 25) +SET(KWSYS_DATE_STAMP_DAY 14) diff --git a/GCC_XML/KWSys/kwsysPlatformTestsCXX.cxx b/GCC_XML/KWSys/kwsysPlatformTestsCXX.cxx index f0a2dfc..502e2d8 100644 --- a/GCC_XML/KWSys/kwsysPlatformTestsCXX.cxx +++ b/GCC_XML/KWSys/kwsysPlatformTestsCXX.cxx @@ -91,6 +91,11 @@ bool f(const kwsys_stl::string& s) { return s != ""; } int main() { return 0; } #endif +#ifdef TEST_KWSYS_CXX_HAS_CSTDIO +#include +int main() { return 0; } +#endif + #ifdef TEST_KWSYS_CXX_HAS_CSTDDEF #include void f(size_t) {} @@ -289,6 +294,17 @@ int main() } #endif +#ifdef TEST_KWSYS_IOS_HAVE_BINARY +int test_binary(int, ...) +{ + return 0; +} +int main() +{ + return test_binary(1, kwsys_ios::ios::binary); +} +#endif + #ifdef TEST_KWSYS_IOS_HAS_ISTREAM_LONG_LONG int test_istream(kwsys_ios::istream& is, long long& x) { @@ -331,6 +347,9 @@ int main() #include #include #include +#if KWSYS_CXX_HAS_CSTDIO +# include +#endif #include int main(int, char **argv) diff --git a/GCC_XML/KWSys/testIOS.cxx b/GCC_XML/KWSys/testIOS.cxx index 5b65d20..2839109 100644 --- a/GCC_XML/KWSys/testIOS.cxx +++ b/GCC_XML/KWSys/testIOS.cxx @@ -1,6 +1,7 @@ #include "kwsysPrivate.h" #include KWSYS_HEADER(stl/vector) #include KWSYS_HEADER(ios/sstream) +#include KWSYS_HEADER(ios/fstream) #include KWSYS_HEADER(ios/iostream) // Work-around CMake dependency scanning limitation. This must @@ -9,6 +10,7 @@ # include "kwsys_stl_string.hxx.in" # include "kwsys_stl_vector.h.in" # include "kwsys_ios_sstream.h.in" +# include "kwsys_ios_fstream.h.in" # include "kwsys_ios_iostream.h.in" #endif @@ -142,6 +144,13 @@ int testIOS(int, char*[]) return 1; } + // Just try to compile this. + if(x == 12345) + { + kwsys_ios::ifstream fin("/does_not_exist", + kwsys_ios::ios::in | kwsys_ios_binary); + } + kwsys_ios::cout << "IOS tests passed" << kwsys_ios::endl; return 0; }