10.6 compatibility: Fix some new compiler warnings, and work around apparent regressions in NSTask and -stringByStandardizingPath.
     4 //  Copyright 2008 Google Inc.
 
     6 //  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 
     7 //  use this file except in compliance with the License.  You may obtain a copy
 
    10 //  http://www.apache.org/licenses/LICENSE-2.0
 
    12 //  Unless required by applicable law or agreed to in writing, software
 
    13 //  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
    14 //  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 
    15 //  License for the specific language governing permissions and limitations under
 
    19 // ============================================================================
 
    21 // ----------------------------------------------------------------------------
 
    22 // CPP symbols that can be overridden in a prefix to control how the toolbox
 
    24 // ----------------------------------------------------------------------------
 
    27 // GTMHTTPFetcher will support logging by default but only hook its input
 
    28 // stream support for logging when requested.  You can control the inclusion of
 
    29 // the code by providing your own definitions for these w/in a prefix header.
 
    31 #ifndef GTM_HTTPFETCHER_ENABLE_LOGGING
 
    32 # define GTM_HTTPFETCHER_ENABLE_LOGGING 1
 
    33 #endif // GTM_HTTPFETCHER_ENABLE_LOGGING
 
    34 #ifndef GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING
 
    35 # define GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING 0
 
    36 #endif // GTM_HTTPFETCHER_ENABLE_INPUTSTREAM_LOGGING
 
    39 // _GTMDevLog & _GTMDevAssert
 
    41 // _GTMDevLog & _GTMDevAssert are meant to be a very lightweight shell for
 
    42 // developer level errors.  This implementation simply macros to NSLog/NSAssert.
 
    43 // It is not intended to be a general logging/reporting system.
 
    45 // Please see http://code.google.com/p/google-toolbox-for-mac/wiki/DevLogNAssert
 
    46 // for a little more background on the usage of these macros.
 
    48 //    _GTMDevLog           log some error/problem in debug builds
 
    49 //    _GTMDevAssert        assert if conditon isn't met w/in a method/function
 
    52 // To replace this system, just provide different macro definitions in your
 
    53 // prefix header.  Remember, any implementation you provide *must* be thread
 
    54 // safe since this could be called by anything in what ever situtation it has
 
    58 // We only define the simple macros if nothing else has defined this.
 
    62  #define _GTMDevLog(...) NSLog(__VA_ARGS__)
 
    64  #define _GTMDevLog(...) do { } while (0)
 
    67 // we directly invoke the NSAssert handler so we can pass on the varargs
 
    68 // (NSAssert doesn't have a macro we can use that takes varargs)
 
    69 #if !defined(NS_BLOCK_ASSERTIONS)
 
    70 #define _GTMDevAssert(condition, ...)                                    \
 
    73       [[NSAssertionHandler currentHandler]                               \
 
    74           handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__] \
 
    75                              file:[NSString stringWithCString:__FILE__]  \
 
    77                       description:__VA_ARGS__];                          \
 
    80 #else // !defined(NS_BLOCK_ASSERTIONS)
 
    81 #define _GTMDevAssert(condition, ...) do { } while (0)
 
    82 #endif // !defined(NS_BLOCK_ASSERTIONS)
 
    86 // ============================================================================
 
    88 // ----------------------------------------------------------------------------
 
    89 // CPP symbols defined based on the project settings so the GTM code has
 
    90 // simple things to test against w/o scattering the knowledge of project
 
    91 // setting through all the code.
 
    92 // ----------------------------------------------------------------------------
 
    94 // Provide a single constant CPP symbol that all of GTM uses for ifdefing
 
    96 #include <TargetConditionals.h>
 
    97 #if TARGET_OS_IPHONE // iPhone SDK
 
    98   // For iPhone specific stuff
 
    99   #define GTM_IPHONE_SDK 1
 
   101   // For MacOS specific stuff
 
   102   #define GTM_MACOS_SDK 1
 
   105 // To simplify support for 64bit (and Leopard in general), we provide the type
 
   106 // defines for non Leopard SDKs
 
   107 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
 
   108  // NSInteger/NSUInteger and Max/Mins
 
   109  #ifndef NSINTEGER_DEFINED
 
   110   #if __LP64__ || NS_BUILD_32_LIKE_64
 
   111    typedef long NSInteger;
 
   112    typedef unsigned long NSUInteger;
 
   114    typedef int NSInteger;
 
   115    typedef unsigned int NSUInteger;
 
   117   #define NSIntegerMax    LONG_MAX
 
   118   #define NSIntegerMin    LONG_MIN
 
   119   #define NSUIntegerMax   ULONG_MAX
 
   120   #define NSINTEGER_DEFINED 1
 
   121  #endif  // NSINTEGER_DEFINED
 
   123  #ifndef CGFLOAT_DEFINED
 
   124   #if defined(__LP64__) && __LP64__
 
   125    // This really is an untested path (64bit on Tiger?)
 
   126    typedef double CGFloat;
 
   127    #define CGFLOAT_MIN DBL_MIN
 
   128    #define CGFLOAT_MAX DBL_MAX
 
   129    #define CGFLOAT_IS_DOUBLE 1
 
   130   #else /* !defined(__LP64__) || !__LP64__ */
 
   131    typedef float CGFloat;
 
   132    #define CGFLOAT_MIN FLT_MIN
 
   133    #define CGFLOAT_MAX FLT_MAX
 
   134    #define CGFLOAT_IS_DOUBLE 0
 
   135   #endif /* !defined(__LP64__) || !__LP64__ */
 
   136   #define CGFLOAT_DEFINED 1
 
   137  #endif // CGFLOAT_DEFINED
 
   138 #endif  // MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4