Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C1876100E1 for ; Fri, 28 Feb 2014 22:11:35 +0000 (UTC) Received: (qmail 96041 invoked by uid 500); 28 Feb 2014 22:11:31 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 95889 invoked by uid 500); 28 Feb 2014 22:11:28 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 95669 invoked by uid 99); 28 Feb 2014 22:11:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Feb 2014 22:11:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Feb 2014 22:11:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7EF5D238883D; Fri, 28 Feb 2014 22:11:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1573096 - /subversion/trunk/subversion/libsvn_subr/sysinfo.c Date: Fri, 28 Feb 2014 22:11:00 -0000 To: commits@subversion.apache.org From: breser@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140228221100.7EF5D238883D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: breser Date: Fri Feb 28 22:11:00 2014 New Revision: 1573096 URL: http://svn.apache.org/r1573096 Log: Stop using a deprecated (as of OS X 10.9) function to get OS X version. CFURLCreateDataAndPropertiesFromResource() is not listed as being deprecated. It still works but this code goes to a lot of effor to use OS X's CoreFoundation framework to read the plist when we have our own functions for reading files. I think it's much better for our maintenance purposes to use our functions for as much as we can. * subversion/libsvn_subr/sysinfo.c (write_to_cfmutabledata): svn_write_fn_t implementation that feeds data into a CFMutableDataRef (Core Foundation's version of streams). (system_version_plist): Use our stream interface to read the plist files and wire it up to a stream that feeds the data to a CFMutableDataRef so we can still let OS X's property list code do the parsing for us. Also fix a small comment typo. Modified: subversion/trunk/subversion/libsvn_subr/sysinfo.c Modified: subversion/trunk/subversion/libsvn_subr/sysinfo.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sysinfo.c?rev=1573096&r1=1573095&r2=1573096&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/sysinfo.c (original) +++ subversion/trunk/subversion/libsvn_subr/sysinfo.c Fri Feb 28 22:11:00 2014 @@ -901,64 +901,72 @@ win32_shared_libs(apr_pool_t *pool) #ifdef SVN_HAVE_MACOS_PLIST +static svn_error_t * +write_to_cfmutabledata(void *baton, const char *data, apr_size_t *len) +{ + CFMutableDataRef *resource = (CFMutableDataRef *) baton; + + CFDataAppendBytes(*resource, (UInt8 *)data, *len); + + return SVN_NO_ERROR; +} + /* Load the SystemVersion.plist or ServerVersion.plist file into a property list. Set SERVER to TRUE if the file read was ServerVersion.plist. */ static CFDictionaryRef system_version_plist(svn_boolean_t *server, apr_pool_t *pool) { - static const UInt8 server_version[] = + static const char server_version[] = "/System/Library/CoreServices/ServerVersion.plist"; - static const UInt8 system_version[] = + static const char system_version[] = "/System/Library/CoreServices/SystemVersion.plist"; - + svn_stream_t *read_stream, *write_stream; + svn_error_t *err; CFPropertyListRef plist = NULL; - CFDataRef resource = NULL; + CFMutableDataRef resource = CFDataCreateMutable(kCFAllocatorDefault, 0); CFStringRef errstr = NULL; - CFURLRef url = NULL; - SInt32 errcode; - - url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, - server_version, - sizeof(server_version) - 1, - FALSE); - if (!url) - return NULL; - if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, - url, &resource, - NULL, NULL, &errcode)) + /* Try to open the plist files to get the data */ + err = svn_stream_open_readonly(&read_stream, server_version, pool, pool); + if (err) { - CFRelease(url); - url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, - system_version, - sizeof(system_version) - 1, - FALSE); - if (!url) - return NULL; - - if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, - url, &resource, - NULL, NULL, &errcode)) + if (!APR_STATUS_IS_ENOENT(err->apr_err)) { - CFRelease(url); + svn_error_clear(err); return NULL; } else { - CFRelease(url); + svn_error_clear(err); + err = svn_stream_open_readonly(&read_stream, system_version, + pool, pool); + if (err) + { + svn_error_clear(err); + return NULL; + } + *server = FALSE; } } else { - CFRelease(url); *server = TRUE; } + write_stream = svn_stream_create(&resource, pool); + svn_stream_set_write(write_stream, write_to_cfmutabledata); + err = svn_stream_copy3(read_stream, write_stream, NULL, NULL, pool); + if (err) + { + svn_error_clear(err); + return NULL; + } + /* ### CFPropertyListCreateFromXMLData is obsolete, but its replacement CFPropertyListCreateWithData is only available - from Mac OS 1.6 onward. */ + from Mac OS 10.6 onward. */ plist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resource, kCFPropertyListImmutable, &errstr);