diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/file.c osl/unx/file.c
--- osl/unx/file.c	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/file.c	2005-07-10 17:45:54.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: file.c,v $
  *
- *  $Revision: 1.72.28.1 $
+ *  $Revision: 1.72.28.1.22.2 $
  *
- *  last change: $Author: hr $ $Date: 2004/01/09 18:31:46 $
+ *  last change: $Author: pluby $ $Date: 2005/05/07 20:13:15 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -173,6 +173,13 @@
 #include <sys/mount.h>
 #define HAVE_STATFS_H
 
+#define osl_getThreadTextEncoding() RTL_TEXTENCODING_UTF8
+
+// add MACOSX Time Value
+
+#define TimeValue CFTimeValue
+#include <CoreFoundation/CoreFoundation.h>
+#undef TimeValue
 #endif
 
 #if OSL_DEBUG_LEVEL > 1
@@ -266,6 +273,9 @@
 static int           oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, size_t nSourceSize, mode_t mode);
 static oslFileError  oslDoMoveFile(const sal_Char* pszPath, const sal_Char* pszDestPath);
 static rtl_uString*  oslMakeUStrFromPsz(const sal_Char* pszStr,rtl_uString** uStr);
+#if defined MACOSX && defined PRODUCT_FILETYPE
+static void          oslSetFileTypeFromPsz(const sal_Char* pszStr);
+#endif	/* MACOSX && PRODUCT_FILETYPE */
 
 /******************************************************************************
  *
@@ -336,7 +346,11 @@
 	osl_systemPathRemoveSeparator(ustrSystemPath);
 
     /* convert unicode path to text */
+#ifdef MACOSX
+    if ( UnicodeToText( path, PATH_MAX, ustrSystemPath->buffer, ustrSystemPath->length ) && macxp_resolveAlias( path, PATH_MAX ) == 0 )
+#else	/* MACOSX */
     if ( UnicodeToText( path, PATH_MAX, ustrSystemPath->buffer, ustrSystemPath->length ) )
+#endif	/* MACOSX */
     {
         /* open directory */
         DIR *pdir = opendir( path );
@@ -443,9 +457,22 @@
     if (NULL == pEntry)
         return osl_File_E_NOENT;
 
+#if defined(MACOSX) && (BUILD_OS_MAJOR==10) && (BUILD_OS_MINOR>=2)
+    /* convert decomposed file name to precomposed unicode */
+    char composed_name[BUFSIZ];
+    CFMutableStringRef strRef = CFStringCreateMutable( NULL, 0 );
+    CFStringAppendCString( strRef, pEntry->d_name, kCFStringEncodingUTF8 );
+    CFStringNormalize( strRef, kCFStringNormalizationFormC );
+    CFStringGetCString( strRef, composed_name, BUFSIZ, kCFStringEncodingUTF8 );
+    CFRelease( strRef );
+
+    rtl_string2UString( &ustrFileName, composed_name, strlen( composed_name ),
+        osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
+#else
     /* convert file name to unicode */
     rtl_string2UString( &ustrFileName, pEntry->d_name, strlen( pEntry->d_name ),
         osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
+#endif
 
 	osl_systemPathMakeAbsolutePath(pDirImpl->ustrPath, ustrFileName, &ustrFilePath);
 
@@ -586,8 +613,13 @@
 	osl_systemPathRemoveSeparator(ustrFilePath);
 
     /* convert unicode path to text */
+#ifdef MACOSX
+    if( UnicodeToText( buffer, PATH_MAX, ustrFilePath->buffer, ustrFilePath->length ) && macxp_resolveAlias( buffer, PATH_MAX ) == 0 )
+#else	/* MACOSX */
     if( UnicodeToText( buffer, PATH_MAX, ustrFilePath->buffer, ustrFilePath->length ) )
+#endif	/* MACOSX */
     {
+
         /* we do not open devices or such here */
         if( !( uFlags & osl_File_OpenFlag_Create ) )
         {
@@ -653,6 +685,11 @@
 
                         *pHandle = (oslFileHandle) pHandleImpl;
 
+#if defined MACOSX && defined PRODUCT_FILETYPE
+                        if ( uFlags & osl_File_OpenFlag_Create )
+                            oslSetFileTypeFromPsz( buffer );
+#endif	/* MACOSX && PRODUCT_FILETYPE */
+
                         return osl_File_E_None;
                     }
                     else
@@ -664,10 +701,39 @@
                 close( fd );
             }
 
+#ifdef MACOSX
+            /*
+             * Handle case where we cannot open a file for writing because it
+             * is locked in the Finder's GetInfo panel
+             */
+            if ( errno == EPERM )
+            {
+                struct stat aFileStat;
+
+                if( stat( buffer, &aFileStat ) >= 0 && ( aFileStat.st_flags & ( UF_IMMUTABLE | SF_IMMUTABLE ) ) )
+                    errno = EACCES;
+            }
+            /*
+             * Mac OS X will return ENOTSUP for mounted file systems so ignore
+             * the error for write locks
+             */
+            else if ( errno == ENOTSUP )
+            {
+                struct stat aFileStat;
+
+                if( stat( buffer, &aFileStat ) >= 0 )
+                    errno = EACCES;
+            }
+#endif	/* MACOSX */
+
             PERROR( "osl_openFile", buffer );
             eRet = oslTranslateFileError(OSL_FET_ERROR, errno );
         }
     }
+#ifdef MACOSX
+    else if( errno )
+        eRet = oslTranslateFileError(OSL_FET_ERROR, errno );
+#endif	/* MACOSX */
     else
         eRet = osl_File_E_INVAL;
 
@@ -781,6 +847,11 @@
     if( eRet != osl_File_E_None )
         return eRet;
 
+#ifdef MACOSX
+    if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 )
+        return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif	/* MACOSX */
+
     return oslDoMoveFile( srcPath, destPath );
 }
 
@@ -807,6 +878,11 @@
     if( eRet != osl_File_E_None )
         return eRet;
 
+#ifdef MACOSX
+    if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 )
+        return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif	/* MACOSX */
+
     return osl_psz_copyFile( srcPath, destPath );
 }
 
@@ -826,6 +902,11 @@
     if( eRet != osl_File_E_None )
         return eRet;
 
+#ifdef MACOSX
+    if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+        return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif	/* MACOSX */
+
     return osl_psz_removeFile( path );
 }
 
@@ -846,6 +927,11 @@
     if( eRet != osl_File_E_None )
         return eRet;
 
+#ifdef MACOSX
+    if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+        return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif	/* MACOSX */
+
     return osl_psz_getVolumeInformation( path, pInfo, uFieldMask);
 }
 
@@ -865,6 +951,11 @@
     if( eRet != osl_File_E_None )
         return eRet;
 
+#ifdef MACOSX
+    if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+        return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif	/* MACOSX */
+
     return osl_psz_createDirectory( path );
 }
 
@@ -884,6 +975,11 @@
     if( eRet != osl_File_E_None )
         return eRet;
 
+#ifdef MACOSX
+    if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+        return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif	/* MACOSX */
+
     return osl_psz_removeDirectory( path );
 }
 
@@ -916,6 +1012,11 @@
     if( eRet != osl_File_E_None )
         return eRet;
 
+#ifdef MACOSX
+    if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+        return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif	/* MACOSX */
+
     return osl_psz_setFileAttributes( path, uAttributes );
 }
 
@@ -936,6 +1037,11 @@
     if( eRet != osl_File_E_None )
         return eRet;
 
+#ifdef MACOSX
+    if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+        return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif	/* MACOSX */
+
     return osl_psz_setFileTime( path, pCreationTime, pLastAccessTime, pLastWriteTime );
 }
 
@@ -1955,6 +2061,10 @@
     close(SourceFileFD);
     close(DestFileFD);
 
+#if defined MACOSX && defined PRODUCT_FILETYPE
+    oslSetFileTypeFromPsz( pszDestFileName );
+#endif	/* MACOSX && PRODUCT_FILETYPE */
+
     return 0;
 }
 
@@ -1974,6 +2084,26 @@
     return *ustrValid;
 }
 
+/*****************************************
+ * oslSetFileTypeFromPsz 
+ ****************************************/
+
+#if defined MACOSX && defined PRODUCT_FILETYPE
+static void oslSetFileTypeFromPsz(const sal_Char* pszStr)
+{
+    FSRef aFSRef;
+    FSCatalogInfo aCatInfo;
+    if ( FSPathMakeRef( (const UInt8 *)pszStr, &aFSRef, 0 ) == noErr && FSGetCatalogInfo( &aFSRef, kFSCatInfoFinderInfo, &aCatInfo, NULL, NULL, NULL) == noErr )
+    {
+        if ( ( (FileInfo *)&aCatInfo.finderInfo )->fileType == 0x00000000 )
+        {
+            ( (FileInfo *)&aCatInfo.finderInfo )->fileType = (OSType)PRODUCT_FILETYPE;
+            FSSetCatalogInfo( &aFSRef, kFSCatInfoFinderInfo, &aCatInfo );
+        }
+    }
+}
+#endif	/* MACOSX && PRODUCT_FILETYPE */
+
 /*****************************************************************************
  * UnicodeToText
  * converting unicode to text manually saves us the penalty of a temporary
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/makefile.mk osl/unx/makefile.mk
--- osl/unx/makefile.mk	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/makefile.mk	2005-07-10 17:45:55.000000000 -0700
@@ -2,9 +2,9 @@
 #
 #   $RCSfile: makefile.mk,v $
 #
-#   $Revision: 1.23.10.2 $
+#   $Revision: 1.23.10.2.6.1 $
 #
-#   last change: $Author: kz $ $Date: 2004/07/06 10:36:15 $
+#   last change: $Author: pluby $ $Date: 2005/04/18 02:56:45 $
 #
 #   The Contents of this file are made available subject to the terms of
 #   either of the following licenses
@@ -76,6 +76,11 @@
 
 TARGETTYPE=CUI
 
+.IF "$(OS)"=="MACOSX"
+.IF "$(PRODUCT_FILETYPE)"!=""
+ENVCDEFS += -DPRODUCT_FILETYPE=\'$(PRODUCT_FILETYPE)\'
+.ENDIF		# "$(PRODUCT_FILETYPE)"!=""
+.ENDIF		# "$(OS)"=="MACOSX"
 
 # --- Settings -----------------------------------------------------
 
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/module.c osl/unx/module.c
--- osl/unx/module.c	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/module.c	2005-07-10 17:45:55.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: module.c,v $
  *
- *  $Revision: 1.28 $
+ *  $Revision: 1.28.142.2 $
  *
- *  last change: $Author: rt $ $Date: 2003/04/29 08:32:35 $
+ *  last change: $Author: pluby $ $Date: 2005/05/07 20:13:15 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -115,6 +115,9 @@
 #ifndef _OSL_PROCESS_H_
 #include <osl/process.h>
 #endif
+#ifndef _OSL_MUTEX_H_
+#include <osl/mutex.h>
+#endif
 #include <mach-o/dyld.h>
 extern oslProcessError SAL_CALL osl_searchPath(const sal_Char* pszName, const sal_Char* pszPath, sal_Char Separator, sal_Char *pszBuffer, sal_uInt32 Max);
 #else /* MACOSX */
@@ -169,6 +172,7 @@
         const struct mach_header      *pLib = NULL;
         oslModule               pModule;
         sal_Char		buf[PATH_MAX + 1];
+        oslMutex				*pMutex;
 
 	OSL_ASSERT(pszModuleName);
 
@@ -176,6 +180,10 @@
 		return NULL;
 
 #ifndef NO_DL_FUNCTIONS
+        // Synchronize calls to NSAddImage to prevent crashing on multiple CPUs
+        pMutex = osl_getGlobalMutex();
+        if ( pMutex )
+            osl_acquireMutex( *pMutex );
 
         // Check if module is already loaded
         strncpy(buf, pszModuleName, sizeof(buf));
@@ -203,6 +211,9 @@
                                   NSADDIMAGE_OPTION_RETURN_ON_ERROR);
         }
 
+        if ( pMutex )
+            osl_releaseMutex( *pMutex );
+
         if (!pLib) {
                 // Still couldn't find it - give up
 #if OSL_DEBUG_LEVEL > 1
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/nlsupport.c osl/unx/nlsupport.c
--- osl/unx/nlsupport.c	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/nlsupport.c	2005-07-10 17:45:56.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: nlsupport.c,v $
  *
- *  $Revision: 1.21.10.2 $
+ *  $Revision: 1.21.10.1.18.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/06/03 10:32:24 $
+ *  last change: $Author: pluby $ $Date: 2005/05/07 20:13:15 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -58,6 +58,7 @@
  *
  *
  ************************************************************************/
+
 #include <osl/nlsupport.h>
 #include <osl/diagnose.h>
 #include <osl/process.h>
@@ -328,7 +329,7 @@
    { "sjis",		RTL_TEXTENCODING_SHIFT_JIS	} /* Japan */
 };
 
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(NETBSD)
 
 const _pair _nl_language_list[] = {
     { "ANSI_X3.110-1983",           RTL_TEXTENCODING_DONTKNOW   },  /* ISO-IR-99 NAPLPS */
@@ -795,6 +796,16 @@
 
 rtl_TextEncoding osl_getTextEncodingFromLocale( rtl_Locale * pLocale )
 {
+#ifdef MACOSX
+    /*
+     * Mac OS X uses UTF-8 for all path names and, unfortunately, there are
+     * still places throughout the OOo code that will use
+     * osl_getThreadTextEncoding() to encode a Unicode path before passing it
+     * to one of the libsal functions. So, we need to force all OOo code to
+     * use UTF-8.
+     */
+    return RTL_TEXTENCODING_UTF8;
+#else	/* MACOSX */
     const _pair *language = 0;
     char locale_buf[64] = "";
     char *cp;
@@ -844,6 +855,7 @@
         return language->value;
    
     return RTL_TEXTENCODING_DONTKNOW;
+#endif	/* MACOSX */
 }
 
 #ifdef MACOSX
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/pipe.c osl/unx/pipe.c
--- osl/unx/pipe.c	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/pipe.c	2005-07-10 17:45:57.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: pipe.c,v $
  *
- *  $Revision: 1.17 $
+ *  $Revision: 1.17.256.2 $
  *
- *  last change: $Author: vg $ $Date: 2003/07/01 14:53:28 $
+ *  last change: $Author: pluby $ $Date: 2005/05/07 20:13:15 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/process.c osl/unx/process.c
--- osl/unx/process.c	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/process.c	2005-07-10 17:45:57.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: process.c,v $
  *
- *  $Revision: 1.31 $
+ *  $Revision: 1.31.108.2 $
  *
- *  last change: $Author: vg $ $Date: 2003/07/02 13:34:17 $
+ *  last change: $Author: pluby $ $Date: 2005/05/07 20:13:16 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -18,7 +18,7 @@
  *  =============================================
  *  Copyright 2000 by Sun Microsystems, Inc.
  *  901 San Antonio Road, Palo Alto, CA 94303, USA
- *osl_getExecut
+ *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
  *  License version 2.1, as published by the Free Software Foundation.
@@ -113,7 +113,6 @@
 #include "sockimpl.h"
 #include "secimpl.h"
 
-
 #define MAX_ARGS        255
 #define MAX_ENVS        255
 
@@ -1364,6 +1363,16 @@
 		(osl_searchPath_impl(pszImageName, NULL, '\0', path, sizeof(path)) == osl_Process_E_None))
 		pszImageName = path;
 
+#ifdef MACOSX
+	// The fork() function will eventually hang the process if too many
+	// non-existant executables are called so don't bother forking if we know
+	// exec() will fail
+	if (access(pszImageName, R_OK | X_OK))
+	{
+		return osl_Process_E_NotFound;
+	}
+#endif	/* MACOSX */
+
 	Data.m_pszArgs[0] = strdup(pszImageName);
 	Data.m_pszArgs[1] = 0;
 
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/signal.c osl/unx/signal.c
--- osl/unx/signal.c	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/signal.c	2005-07-10 17:45:58.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: signal.c,v $
  *
- *  $Revision: 1.17.10.3 $
+ *  $Revision: 1.17.10.3.22.1 $
  *
- *  last change: $Author: hr $ $Date: 2004/01/09 18:31:47 $
+ *  last change: $Author: pluby $ $Date: 2005/04/18 02:56:46 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -360,6 +360,7 @@
 
 static int ReportCrash( int Signal )
 {
+#ifndef MACOSX
 	static sal_Bool bCrashReporterExecuted = sal_False;
 
 	sal_uInt32	argi;
@@ -596,28 +597,25 @@
 		
 		return 0;
 	}
+#endif	/* !MACOSX */
 	
 	return 1;
 }
 
 static void PrintStack( int sig )
 {
-	void *buffer[MAX_STACK_FRAMES];
 #ifndef MACOSX
+	void *buffer[MAX_STACK_FRAMES];
 	int size = backtrace( buffer, sizeof(buffer) / sizeof(buffer[0]) );
-#endif
 
 	fprintf( stderr, "\n\nFatal exception: Signal %d\n", sig );
 
-#ifdef MACOSX
-	fprintf( stderr, "Please turn on Enable Crash Reporting and\nAutomatic Display of Crashlogs in the Console application\n" );
-#else
 	if ( size > 0 )
 	{
 		fputs( "Stack:\n", stderr );
 		backtrace_symbols_fd( buffer, size, fileno(stderr) );
 	}
-#endif
+#endif	/* !MACOSX */
 }
 
 static oslSignalAction CallSignalHandler(oslSignalInfo *pInfo)
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/system.c osl/unx/system.c
--- osl/unx/system.c	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/system.c	2005-07-10 17:45:59.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: system.c,v $
  *
- *  $Revision: 1.8 $
+ *  $Revision: 1.8.252.2 $
  *
- *  last change: $Author: hr $ $Date: 2003/07/16 17:21:47 $
+ *  last change: $Author: pluby $ $Date: 2005/04/19 21:14:55 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -563,16 +563,23 @@
 	 * 3) P_tmpdir (defined in stdio.h)
 	 * 4) /tmp
 	 */
+#ifdef MACOSX
+	/* But because /tmp gets automatically cleaned up with each reboot, we
+	 * won't use P_tmpdir.
+	 */
+#endif	/* MACOSX */
 	
 	/* Get the length of whatever temp dir we are going to use. */
 	if ( (envTempDir=getenv("TMPDIR")) != NULL )
 		tempDirLen = strlen( envTempDir );
 	else if ( tmpdir != NULL )
 		tempDirLen = strlen( tmpdir );
+#ifdef MACOSX
 	#ifdef P_tmpdir
 		else if ( P_tmpdir != NULL )
 			tempDirLen = strlen( P_tmpdir );
 	#endif
+#endif	/* MACOSX */
 	else
 		tempDirLen = strlen( kLastResortTempDir );
 	tempDirLen++;
@@ -595,10 +602,12 @@
 				strncpy( tempFilePathAndPrefix, envTempDir, tempDirLen );
 			else if ( tmpdir != NULL )
 				strncpy( tempFilePathAndPrefix, tmpdir, tempDirLen );
+#ifdef MACOSX
 			#ifdef P_tmpdir
 				else if ( P_tmpdir != NULL )
 					strncpy( tempFilePathAndPrefix, P_tmpdir, tempDirLen );
 			#endif
+#endif	/* MACOSX */
 			else
 				strncpy( tempFilePathAndPrefix, kLastResortTempDir, tempDirLen );
 
@@ -670,6 +679,72 @@
 	*minorMinorVersion = 0;
 }
 
+int macxp_resolveAlias(char *path, int buflen)
+{
+    FSRef aFSRef;
+    OSStatus nErr;
+    MacOSBoolean bFolder;
+    MacOSBoolean bAliased;
+    char *unprocessedPath = path;
+
+    if ( *unprocessedPath == '/' )
+        unprocessedPath++;
+
+    int nRet = 0;
+    while ( !nRet && unprocessedPath && *unprocessedPath )
+    {
+        unprocessedPath = strchr( unprocessedPath, '/' );
+        if ( unprocessedPath )
+            *unprocessedPath = '\0';
+
+        nErr = noErr;
+        bFolder = FALSE;
+        bAliased = FALSE;
+        if ( FSPathMakeRef( (const UInt8 *)path, &aFSRef, 0 ) == noErr )
+        {
+            nErr = FSResolveAliasFileWithMountFlags( &aFSRef, TRUE, &bFolder, &bAliased, kResolveAliasFileNoUI );
+            if ( nErr == nsvErr )
+            {
+                errno = ENOENT;
+                nRet = -1;
+            }
+            else if ( nErr == noErr && bAliased )
+            {
+                char tmpPath[ PATH_MAX ];
+                if ( FSRefMakePath( &aFSRef, (UInt8 *)tmpPath, PATH_MAX ) == noErr )
+                {
+                    int nLen = strlen( tmpPath ) + ( unprocessedPath ? strlen( unprocessedPath + 1 ) + 1 : 0 );
+                    if ( nLen < buflen && nLen < PATH_MAX )
+                    {
+                        if ( unprocessedPath )
+                        {
+                            int nTmpPathLen = strlen( tmpPath );
+                            strcat( tmpPath, "/" );
+                            strcat( tmpPath, unprocessedPath + 1 );
+                            strcpy( path, tmpPath);
+                            unprocessedPath = path + nTmpPathLen;
+                        }
+                        else if ( !unprocessedPath )
+                        {
+                            strcpy( path, tmpPath);
+                        }
+                    }
+                    else
+                    {
+                        errno = ENAMETOOLONG;
+                        nRet = -1;
+                    }
+                }
+            }
+        }
+
+        if ( unprocessedPath )
+            *unprocessedPath++ = '/';
+    }
+
+    return nRet;
+}
+
 #endif  /* defined MACOSX */
 
 #endif /* NO_PTHREAD_RTL */
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/system.h osl/unx/system.h
--- osl/unx/system.h	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/system.h	2005-07-10 17:45:59.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: system.h,v $
  *
- *  $Revision: 1.19.10.1 $
+ *  $Revision: 1.19.10.1.46.1 $
  *
- *  last change: $Author: hr $ $Date: 2003/08/15 11:38:50 $
+ *  last change: $Author: pluby $ $Date: 2005/04/18 02:56:47 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -397,6 +397,8 @@
 /* fixme are premac and postmac still needed here? */
 #	include <premac.h>
 #	include <mach-o/dyld.h> 
+#	define __OPENTRANSPORTPROVIDERS__
+#	include <Carbon/Carbon.h>
 #	include <postmac.h>
 #	if BYTE_ORDER == LITTLE_ENDIAN
 #		define _LITTLE_ENDIAN
@@ -413,6 +415,13 @@
 char *asctime_r( const struct tm *tm, char *buffer );
 char *macxp_tempnam( const char *tmpdir, const char *prefix );
 void macxp_getSystemVersion( unsigned int *isDarwin, unsigned int *majorVersion, unsigned int *minorVersion, unsigned int *minorMinorVersion );
+#ifdef __cplusplus
+extern "C" {
+#endif
+int macxp_resolveAlias(char *path, int buflen);
+#ifdef __cplusplus
+}
+#endif
 #endif
 
 #if !defined(_WIN32)  && !defined(_WIN16) && !defined(OS2)  && \
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/tempfile.c osl/unx/tempfile.c
--- osl/unx/tempfile.c	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/tempfile.c	2005-07-10 17:46:00.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: tempfile.c,v $
  *
- *  $Revision: 1.5.28.1 $
+ *  $Revision: 1.5.28.1.18.2 $
  *
- *  last change: $Author: vg $ $Date: 2004/01/28 10:18:07 $
+ *  last change: $Author: pluby $ $Date: 2005/05/07 20:13:17 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -92,13 +92,28 @@
 #ifndef _FILE_URL_H_
 #include "file_url.h"
 #endif
- 
+
 /*****************************************************************/
 /* osl_getTempFirURL                                             */
 /*****************************************************************/
 
 oslFileError SAL_CALL osl_getTempDirURL( rtl_uString** pustrTempDir )
 {
+#ifdef MACOSX
+    /* There are a number of temp paths to choose from...  The order
+     * from the MacOS X man page is:
+     * 1) the environment variable TMPDIR
+     * 2) tmpdir argument
+     * 3) P_tmpdir (defined in stdio.h)
+     * 4) /tmp
+     * But because /tmp gets automatically cleaned up with each reboot, we
+     * won't use P_tmpdir.
+     */
+    const char *pValue = getenv( "TMPDIR" );
+
+    if ( !pValue )
+        pValue = "/tmp";
+#else	/* MACOSX */
     const char *pValue = getenv( "TEMP" );
 
     if ( !pValue )
@@ -109,6 +124,7 @@
 			pValue = P_tmpdir;
 #endif
 	}
+#endif	/* MACOSX */
 
 	if ( pValue )
 	{
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/osl/unx/uunxapi.cxx osl/unx/uunxapi.cxx
--- osl/unx/uunxapi.cxx	2005-07-04 16:35:22.000000000 -0700
+++ osl/unx/uunxapi.cxx	2005-07-10 17:46:00.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: uunxapi.cxx,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.160.2 $
  *
- *  last change: $Author: hr $ $Date: 2003/03/26 16:46:06 $
+ *  last change: $Author: pluby $ $Date: 2005/05/07 20:13:17 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -74,7 +74,10 @@
  #ifndef _OSL_THREAD_H_
  #include <osl/thread.h>
  #endif
- 
+
+ #ifdef MACOSX
+ #include "system.h"
+ #endif 
  
  /***********************************
   access_u 
@@ -85,6 +88,16 @@
  	rtl::OString p = rtl::OUStringToOString(
 		rtl::OUString(const_cast<rtl_uString*>(pustrPath)),
 		osl_getThreadTextEncoding());
+
+ #ifdef MACOSX
+    sal_Char path[ PATH_MAX ];
+    if ( p.getLength() < PATH_MAX )
+    {
+	    strcpy( path, p.getStr() );
+        macxp_resolveAlias( path, PATH_MAX );
+        p = rtl::OString( path );
+    }
+ #endif
 		
 	return access(p.getStr(), mode);
  }
@@ -99,6 +112,16 @@
 		rtl::OUString(const_cast<rtl_uString*>(pustrFileName)),
 		osl_getThreadTextEncoding());
 		
+ #ifdef MACOSX
+    sal_Char path[ PATH_MAX ];
+    if ( fn.getLength() < PATH_MAX )
+    {
+	    strcpy( path, fn.getStr() );
+        macxp_resolveAlias( path, PATH_MAX );
+        fn = rtl::OString( path );
+    }
+ #endif
+
 	char  rp[PATH_MAX];
 	bool  bRet = realpath(fn.getStr(), rp); 
 	
@@ -122,6 +145,16 @@
  	rtl::OString p = rtl::OUStringToOString(
 		rtl::OUString(const_cast<rtl_uString*>(pustrPath)),
 		osl_getThreadTextEncoding());
+
+ #ifdef MACOSX
+    sal_Char path[ PATH_MAX ];
+    if ( p.getLength() < PATH_MAX )
+    {
+	    strcpy( path, p.getStr() );
+        macxp_resolveAlias( path, PATH_MAX );
+        p = rtl::OString( path );
+    }
+ #endif
 	
 	return lstat(p.getStr(), buf);
  } 
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/rtl/source/alloc.c rtl/source/alloc.c
--- rtl/source/alloc.c	2005-07-04 16:35:25.000000000 -0700
+++ rtl/source/alloc.c	2005-07-10 17:46:01.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: alloc.c,v $
  *
- *  $Revision: 1.11.10.1 $
+ *  $Revision: 1.11.10.1.22.2 $
  *
- *  last change: $Author: hr $ $Date: 2004/01/09 18:31:51 $
+ *  last change: $Author: pluby $ $Date: 2005/06/09 15:12:55 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/systools/macxp_extras/x11osx/osxlocale.c systools/macxp_extras/x11osx/osxlocale.c
--- systools/macxp_extras/x11osx/osxlocale.c	2005-07-04 16:35:26.000000000 -0700
+++ systools/macxp_extras/x11osx/osxlocale.c	2005-07-10 17:46:02.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: osxlocale.c,v $
  *
- *  $Revision: 1.2.10.3 $
+ *  $Revision: 1.2.10.3.2.1 $
  *
- *  last change: $Author: vg $ $Date: 2004/08/27 10:23:08 $
+ *  last change: $Author: pluby $ $Date: 2005/04/18 02:56:48 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -73,70 +73,35 @@
  */
 int macxp_getOSXLocale( char *locale, sal_uInt32 bufferLen )
 {
+	CFBundleRef rBundle;
 
-#if (BUILD_OS_MAJOR == 10) && (BUILD_OS_MINOR == 2)
-// Jaguar code
-	LocaleRef	lref;
-	CFArrayRef	aref;
-	CFStringRef	sref;
-	CFStringRef    locNameRef;
-
-	aref = (CFArrayRef)CFPreferencesCopyAppValue( CFSTR( "AppleLanguages" ), kCFPreferencesCurrentApplication );
-	if ( aref != NULL )
+	locale[0] = '\0'; 
+	rBundle = CFBundleGetMainBundle();
+	if ( rBundle )
 	{
-		if ( (CFGetTypeID(aref) == CFArrayGetTypeID()) && (CFArrayGetCount(aref) > 0) )
+		CFArrayRef rAvailableLocales = CFBundleCopyBundleLocalizations( rBundle );
+		if ( rAvailableLocales )
 		{
-			sref = (CFStringRef)CFArrayGetValueAtIndex( aref, 0 );
-			if ( (sref != NULL) && (CFGetTypeID(sref) == CFStringGetTypeID()) )
+			CFArrayRef rPreferredLocales = CFBundleCopyPreferredLocalizationsFromArray( rAvailableLocales );
+			if ( rPreferredLocales )
 			{
-				if ( CFStringGetCString( sref, locale, bufferLen, CFStringGetSystemEncoding() ) )
+				CFStringRef rString = (CFStringRef)CFArrayGetValueAtIndex( rPreferredLocales, 0 );
+				if ( rString )
 				{
-					LocaleRefFromLocaleString( locale, &lref );
-					LocaleRefGetPartString( lref, kLocaleAllPartsMask, bufferLen, locale );
-
-					/* Hack for US english locales.  OS X returns only "en", but we want
-					* "en_US".  So add it.
-					*/
-					if ( (strlen(locale) == 2) && (strncmp(locale, "en", 2) == 0) )
-						strncat( locale, "_US", bufferLen - strlen(locale) - 1 );
-        				// For Japanese locale, just "ja" is not sufficient.
-					// Use "ja_JP.UTF-8" instead.
-					if ( (strlen(locale) == 2) && (strncmp(locale, "ja", 2) == 0) )
-						strlcpy( locale, "ja_JP.UTF-8", bufferLen );
+					if ( !CFStringGetCString( rString, locale, bufferLen, kCFStringEncodingUTF8 ) )
+						locale[0] = '\0';
+					
 				}
+				CFRelease( rPreferredLocales );
 			}
-			else
-				fprintf( stderr, "Could not get array index 0 value of CFPref AppleLanguages!\n" );
+			CFRelease( rAvailableLocales );
 		}
+	}
 
-		CFRelease( aref );
-     }
-     else
-          fprintf( stderr, "Could not get value of CFPref AppleLanguages!  Please reset your locale in the International control panel.\n" );
+	if ( !strlen( locale ) )
+		strcpy( locale, "en" );
 
 	return( noErr );
-
-#else 
-// Panther and later code
-
-        CFStringRef lstr;
-        CFLocaleRef lref;
-
-        lref = CFLocaleCopyCurrent();
-        lstr = CFLocaleGetIdentifier(lref);
-        CFStringGetCString(lstr, locale, bufferLen, kCFStringEncodingASCII);
-        CFRelease(lref);
-        CFRelease(lstr);
-
-        if ( strchr(locale, '.') == NULL )
-	  strlcat( locale, ".UTF-8", bufferLen );
-
-        // fprintf(stderr,"returned locale string is %s\n",locale);
-
-        return ( noErr );
-
-#endif
-
 }
 
 
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/textenc/tencinfo.c textenc/tencinfo.c
--- textenc/tencinfo.c	2005-07-04 16:35:34.000000000 -0700
+++ textenc/tencinfo.c	2005-07-10 17:46:03.000000000 -0700
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: tencinfo.c,v $
  *
- *  $Revision: 1.22 $
+ *  $Revision: 1.22.62.1 $
  *
- *  last change: $Author: vg $ $Date: 2003/06/20 10:11:52 $
+ *  last change: $Author: pluby $ $Date: 2005/04/18 02:56:48 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -169,6 +169,10 @@
     const ImplStrCharsetDef*    mpSecondPartTab;
 } ImplStrFirstPartCharsetDef;
 
+#if MACOSX
+rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMacTextEncoding( sal_uInt32 nMacTextEncoding );
+#endif	/* MACOSX */
+
 /* ======================================================================= */
 
 sal_Bool SAL_CALL rtl_getTextEncodingInfo( rtl_TextEncoding eTextEncoding, rtl_TextEncodingInfo* pEncInfo )
@@ -247,12 +251,18 @@
         default:    eTextEncoding = RTL_TEXTENCODING_DONTKNOW; break;
     };
 
+#ifdef MACOSX
+    /* Mac OS X sets the encoding in RTF files to 77 + nWinCharset */
+    if ( eTextEncoding == RTL_TEXTENCODING_DONTKNOW && nWinCharset >= 77 )
+        eTextEncoding = rtl_getTextEncodingFromMacTextEncoding( nWinCharset - 77 );
+#endif	/* MACOSX */
+
     return eTextEncoding;
 }
 
 /* ----------------------------------------------------------------------- */
 
-#if 0
+#if MACOSX
 
 rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMacTextEncoding( sal_uInt32 nMacTextEncoding )
 {
@@ -408,7 +418,7 @@
     return eTextEncoding;
 }
 
-#endif
+#endif	/* MACOSX */
 
 /* ----------------------------------------------------------------------- */
 
diff -ur -x CVS -X .DS_Store ../SRX645_m57_without_patches/util/makefile.mk util/makefile.mk
--- util/makefile.mk	2005-07-04 16:35:34.000000000 -0700
+++ util/makefile.mk	2005-07-10 17:46:04.000000000 -0700
@@ -2,9 +2,9 @@
 #
 #   $RCSfile: makefile.mk,v $
 #
-#   $Revision: 1.31 $
+#   $Revision: 1.31.118.1 $
 #
-#   last change: $Author: hr $ $Date: 2003/07/16 17:23:32 $
+#   last change: $Author: pluby $ $Date: 2005/04/18 02:56:49 $
 #
 #   The Contents of this file are made available subject to the terms of
 #   either of the following licenses
@@ -160,7 +160,7 @@
 .ENDIF # UNX
 
 .IF "$(OS)"=="MACOSX"
-SHL1STDLIBS+=-lstlport_gcc -framework CoreFoundation
+SHL1STDLIBS+=-lstlport_gcc -framework CoreFoundation -framework Carbon
 .ENDIF
 
 SHL1LIBS+=$(SLB)$/$(TARGET).lib
