Skip to content

Commit

Permalink
A couple of fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed May 18, 2005
1 parent 9f0e61f commit f590edf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
20 changes: 16 additions & 4 deletions mojopatch.c
Expand Up @@ -617,7 +617,7 @@ IsPatchable version_ok(const char *ver, const char *allowed_ver, const char *new
if (*allowed_ver == '\0') /* No specified version? Anything is okay. */
return ISPATCHABLE_YES;

if (strcmp(allowed_ver, newver) == 0) /* all patched up? */
if (strcmp(ver, newver) == 0) /* all patched up? */
return ISPATCHABLE_MATCHES;

buf = (char *) alloca(strlen(allowed_ver) + 1);
Expand Down Expand Up @@ -2164,18 +2164,30 @@ static int run_script(const char *name)
char cwd[MAX_PATH];

if (getcwd(cwd, sizeof (cwd)) == NULL)
{
_fatal("Couldn't determine current working directory!");
return(0);
} /* if */

if (patchfiledir != NULL)
{
if (chdir(patchfiledir) == -1)
{
_fatal("Failed to change directory to \"%s\".", patchfiledir);
return(0);
} /* if */
} /* if */

rc = spawn_script(name, cwd);

if (chdir(cwd) == -1)
return(0);
if (patchfiledir != NULL)
{
if (chdir(cwd) == -1)
{
_fatal("Failed to change directory to \"%s\".", cwd);
return(0);
} /* if */
} /* if */

if (rc == SPAWN_FILENOTFOUND)
return(1); /* "success" */
Expand Down Expand Up @@ -2351,7 +2363,7 @@ static int do_patching(void)
if (!info_only())
{
if (installed_patches == 0)
_fatal("Your installation has not been modified.");
_fatal("No patches were applied to your installation.");
else if (!quietonsuccess)
ui_success("Patching successful!");
} /* if */
Expand Down
18 changes: 13 additions & 5 deletions platform_unix.c
Expand Up @@ -366,18 +366,19 @@ int locate_product_by_identifier(const char *str, char *buf, size_t bufsize)
CFRelease(id);
if (rc == noErr)
{
Boolean b = CFURLGetFileSystemRepresentation(url, TRUE, buf, bufsize);
int b = (int) CFURLGetFileSystemRepresentation(url, TRUE, buf, bufsize);
if (b) b = 1;
CFRelease(url);
if (1) //((b) && (strstr(buf, "/.Trash/")))
if ((b) && (strstr(buf, "/.Trash/")))
{
_fatal("It looks like your installation is in the Trash can."
" Please take it out of the trash first."
" If this is an old installation, please empty your"
" trash so we find the right one.");
b = 0;
b = -1;
} /* if */

return(b != 0);
return(b);
} /* if */

return(0);
Expand Down Expand Up @@ -520,13 +521,20 @@ static SpawnResult spawn_binary(const char *cmd)

SpawnResult spawn_xdelta(const char *cmdline)
{
SpawnResult retval;
const char *binname = "xdelta";
char *cmd = alloca(strlen(cmdline) + strlen(basedir) + strlen(binname) + 5);
if (!cmd)
return(SPAWN_FAILED);

sprintf(cmd, "\"%s/%s\" %s", basedir, binname, cmdline);
return(spawn_binary(cmd));
retval = spawn_binary(cmd);

/* !!! FIXME: xdelta returns an unexpected value when making a delta. */
/* !!! FIXME: (we check the md5sums from all output anyhow. */
if (retval == SPAWN_RETURNBAD) retval = SPAWN_RETURNGOOD;

return(retval);
} /* spawn_xdelta */


Expand Down

0 comments on commit f590edf

Please sign in to comment.