Remove classic Mac OS code from libreg. b=486906 r/sr=bsmedberg
authorJosh Aas <joshmoz@gmail.com>
Thu, 09 Apr 2009 20:49:24 -0400
changeset 27147 ba5eda04971c91b5c48be241a0126dff75226bb8
parent 27146 71f2a7fd20980dd8de730c08d0079f21643f78ca
child 27148 adf251480d63fa9124fee2a9724270c3eff600af
push id6406
push userjosh@mozilla.com
push dateFri, 10 Apr 2009 00:55:01 +0000
treeherdermozilla-central@adf251480d63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs486906
milestone1.9.2a1pre
Remove classic Mac OS code from libreg. b=486906 r/sr=bsmedberg
modules/libreg/src/vr_stubs.c
--- a/modules/libreg/src/vr_stubs.c
+++ b/modules/libreg/src/vr_stubs.c
@@ -224,35 +224,32 @@ int FAR PASCAL _export WEP(int nParam)
 
 #if defined(XP_MACOSX)
 
 #ifdef STANDALONE_REGISTRY
 extern XP_File vr_fileOpen(const char *name, const char * mode)
 {
     XP_File fh = NULL;
     struct stat st;
-    
-#ifdef STANDALONE_REGISTRY
+
     errno = 0; /* reset errno (only if we're using stdio) */
-#endif
 
     if ( name != NULL ) {
         if ( stat( name, &st ) == 0 )
             fh = fopen( name, XP_FILE_UPDATE_BIN );
         else 
         {
             /* should never get here! */
             fh = fopen( name, XP_FILE_TRUNCATE_BIN );
         }
     }
     return fh;
 }
 #endif /*STANDALONE_REGISTRY*/
 
-#if defined (XP_MACOSX)
 extern void vr_findGlobalRegName()
 {
     OSErr   err;
     FSRef   foundRef;
     
     err = FSFindFolder(kLocalDomain, kDomainLibraryFolderType, kDontCreateFolder, &foundRef);
     if (err == noErr)
     {
@@ -282,74 +279,17 @@ extern void vr_findGlobalRegName()
                 UInt8 pathBuf[PATH_MAX];
                 err = FSRefMakePath(&regRef, pathBuf, sizeof(pathBuf));
                 if (err == noErr)
                     globalRegName = XP_STRDUP(pathBuf);
             }
         }
     }
 }
-#else
-extern void vr_findGlobalRegName()
-{
-    FSSpec  regSpec;
-    OSErr   err;
-    short   foundVRefNum;
-    long    foundDirID;
-    int     bCreate = 0;
-    
-    err = FindFolder(kOnSystemDisk,'pref', false, &foundVRefNum, &foundDirID);
 
-    if (err == noErr)
-    {
-        err = FSMakeFSSpec(foundVRefNum, foundDirID, MAC_REG, &regSpec);
-
-        if (err == -43) /* if file doesn't exist */
-        {
-            err = FSpCreate(&regSpec, 'MOSS', 'REGS', smSystemScript);
-            bCreate = 1;
-        }
-
-        if (err == noErr)
-        {
-            Handle thePath;
-            short pathLen;
-            err = FSpGetFullPath(&regSpec, &pathLen, &thePath);
-            if (err == noErr && thePath)
-            {
-                /* we have no idea if this moves memory, so better lock the handle */
-            #if defined(STANDALONE_REGISTRY) || defined(USE_STDIO_MODES)
-                HLock(thePath);
-                globalRegName = (char *)XP_ALLOC(pathLen + 1);
-                XP_STRNCPY(globalRegName, *thePath, pathLen);
-                globalRegName[pathLen] = '\0';
-            #else
-                /* Since we're now using NSPR, this HAS to be a unix path! */
-                const char* src;
-                char* dst;
-                HLock(thePath);
-                globalRegName = (char*)XP_ALLOC(pathLen + 2);
-                src = *(char**)thePath;
-                dst = globalRegName;
-                *dst++ = '/';
-                while (pathLen--)
-                {
-                    char c = *src++;
-                    *dst++ = (c == ':') ? '/' : c;
-                }
-                *dst = '\0';
-            #endif
-            }
-            DisposeHandle(thePath);
-        }
-    }
-}
-#endif /* XP_MACOSX */
-
-#ifdef XP_MACOSX
 extern char* vr_findVerRegName()
 {
     OSErr   err;
     FSRef   foundRef;
     
     err = FSFindFolder(kLocalDomain, kDomainLibraryFolderType, kDontCreateFolder, &foundRef);
     if (err == noErr)
     {
@@ -380,215 +320,26 @@ extern char* vr_findVerRegName()
                 err = FSRefMakePath(&regRef, pathBuf, sizeof(pathBuf));
                 if (err == noErr)
                     verRegName = XP_STRDUP(pathBuf);
             }
         }
     }
     return verRegName;
 }
-#else
-extern char* vr_findVerRegName()
-{
-    FSSpec  regSpec;
-    OSErr   err;
-    short   foundVRefNum;
-    long    foundDirID;
-    int     bCreate = 0;
-    
-    /* quick exit if we have the info */
-    if ( verRegName != NULL )
-        return verRegName;
 
-    err = FindFolder(kOnSystemDisk,'pref', false, &foundVRefNum, &foundDirID);
-
-    if (err == noErr)
-    {
-        err = FSMakeFSSpec(foundVRefNum, foundDirID, MAC_VERREG, &regSpec);
-
-        if (err == -43) /* if file doesn't exist */
-        {
-            err = FSpCreate(&regSpec, 'MOSS', 'REGS', smSystemScript);
-            bCreate = 1;
-        }
-
-        if (err == noErr)
-        {
-            Handle thePath;
-            short pathLen;
-            err = FSpGetFullPath(&regSpec, &pathLen, &thePath);
-            if (err == noErr && thePath)
-            {
-                /* we have no idea if this moves memory, so better lock the handle */
-             #if defined(STANDALONE_REGISTRY) || defined(USE_STDIO_MODES)
-                HLock(thePath);
-                verRegName = (char *)XP_ALLOC(pathLen + 1);
-                XP_STRNCPY(verRegName, *thePath, pathLen);
-                verRegName[pathLen] = '\0';
-            #else
-                /* Since we're now using NSPR, this HAS to be a unix path! */
-                const char* src;
-                char* dst;
-                HLock(thePath);
-                verRegName = (char*)XP_ALLOC(pathLen + 2);
-                src = *(char**)thePath;
-                dst = verRegName;
-                *dst++ = '/';
-                while (pathLen--)
-                {
-                    char c = *src++;
-                    *dst++ = (c == ':') ? '/' : c;
-                }
-                *dst = '\0';
-            #endif
-            }
-            DisposeHandle(thePath);
-        }
-    }
-
-    return verRegName;
-}
-#endif /* OS_MACOSX */
-
-/* Moves and renames a file or directory.
-   Returns 0 on success, -1 on failure (errno contains mac error code).
- */
-#ifndef XP_MACOSX 
-extern int nr_RenameFile(char *from, char *to)
-{
-    OSErr           err = -1;
-    FSSpec          fromSpec;
-    FSSpec          toSpec;
-    FSSpec          destDirSpec;
-    FSSpec          beforeRenameSpec;
-    
-#ifdef STANDALONE_REGISTRY
-    errno = 0; /* reset errno (only if we're using stdio) */
-#endif
-
-    if (from && to) {
-        err = FSpLocationFromFullPath(XP_STRLEN(from), from, &fromSpec);
-        if (err != noErr) goto exit;
-        
-        err = FSpLocationFromFullPath(XP_STRLEN(to), to, &toSpec);
-        if (err != noErr && err != fnfErr) goto exit;
-        
-        /* make an FSSpec for the destination directory */
-        err = FSMakeFSSpec(toSpec.vRefNum, toSpec.parID, nil, &destDirSpec);
-        if (err != noErr) goto exit; /* parent directory must exist */
-
-        /* move it to the directory specified */
-        err = FSpCatMove(&fromSpec, &destDirSpec);
-        if (err != noErr) goto exit;
-        
-        /* make a new FSSpec for the file or directory in its new location  */
-        err = FSMakeFSSpec(toSpec.vRefNum, toSpec.parID, fromSpec.name, &beforeRenameSpec);
-        if (err != noErr) goto exit;
-        
-        /* rename the file or directory */
-        err = FSpRename(&beforeRenameSpec, toSpec.name);
-    }
-        
-    exit:
-#ifdef STANDALONE_REGISTRY
-    if (err != noErr)
-        errno = err;
-#endif
-    return (err == noErr ? 0 : -1);
-}
-#endif
-
-
-#ifdef STANDALONE_REGISTRY
-#ifndef XP_MACOSX
-char *strdup(const char *source)
-{
-        char    *newAllocation;
-        size_t  stringLength;
-
-        stringLength = strlen(source) + 1;
-
-        newAllocation = (char *)XP_ALLOC(stringLength);
-        if (newAllocation == NULL)
-                return NULL;
-        BlockMoveData(source, newAllocation, stringLength);
-        return newAllocation;
-}
-
-int strcasecmp(const char *str1, const char *str2)
-{
-    char    currentChar1, currentChar2;
-
-    while (1) {
-    
-        currentChar1 = *str1;
-        currentChar2 = *str2;
-        
-        if ((currentChar1 >= 'a') && (currentChar1 <= 'z'))
-            currentChar1 += ('A' - 'a');
-        
-        if ((currentChar2 >= 'a') && (currentChar2 <= 'z'))
-            currentChar2 += ('A' - 'a');
-                
-        if (currentChar1 == '\0')
-            break;
-    
-        if (currentChar1 != currentChar2)
-            return currentChar1 - currentChar2;
-            
-        str1++;
-        str2++;
-    
-    }
-    
-    return currentChar1 - currentChar2;
-}
-
-int strncasecmp(const char *str1, const char *str2, int length)
-{
-    char    currentChar1, currentChar2;
-
-    while (length > 0) {
-
-        currentChar1 = *str1;
-        currentChar2 = *str2;
-
-        if ((currentChar1 >= 'a') && (currentChar1 <= 'z'))
-            currentChar1 += ('A' - 'a');
-
-        if ((currentChar2 >= 'a') && (currentChar2 <= 'z'))
-            currentChar2 += ('A' - 'a');
-
-        if (currentChar1 == '\0')
-            break;
-
-        if (currentChar1 != currentChar2)
-            return currentChar1 - currentChar2;
-
-        str1++;
-        str2++;
-
-        length--;
-    }
-
-    return currentChar1 - currentChar2;
-}
 #endif /* XP_MACOSX */
-#endif /* STANDALONE_REGISTRY */
-
-#endif /* XP_MAC */
 
 
 /* ------------------------------------------------------------------
  *  UNIX STUBS
  * ------------------------------------------------------------------
  */
 
-/*allow OS/2 and Macintosh to use this main to test...*/
-#if (defined(STANDALONE_REGISTRY) && defined(XP_MAC)) || defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
+#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
 
 #include <stdlib.h>
 
 #ifdef XP_OS2
 #include <io.h>
 #define W_OK 0x02 /*evil hack from the docs...*/
 #else
 #include <unistd.h>