Skip to content

Commit

Permalink
Print a friendlier message if product appears to be patched to patchf…
Browse files Browse the repository at this point in the history
…ile's

 version already.
  • Loading branch information
icculus committed May 27, 2004
1 parent 0995cc2 commit 566669d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions TODO
Expand Up @@ -10,6 +10,7 @@
- Get other platforms besides Mac updated and building again.
- Look for FIXMEs...
- "_fatal" isn't really appropriate anymore, since it might not be fatal.
- chdir_by_identifier() has way too many unwritten responsibilities.

/* end of TODO ... */

5 changes: 4 additions & 1 deletion mojopatch.c
Expand Up @@ -1819,8 +1819,11 @@ static int process_patch_header(SerialArchive *ar, PatchHeader *h)

if (!info_only())
{
if (!chdir_by_identifier(h->product, h->identifier, h->version))
if (!chdir_by_identifier(h->product, h->identifier,
h->version, h->newversion))
{
return(PATCHERROR);
} /* if */
} /* if */

if (h->readmedata)
Expand Down
3 changes: 2 additions & 1 deletion platform.h
Expand Up @@ -57,10 +57,11 @@ int get_file_size(const char *fname, long *fsize);
char *get_current_dir(void);
char *get_realpath(const char *path);
int spawn_xdelta(const char *cmdline);
int chdir_by_identifier(const char *name, const char *str, const char *ver);
int update_version(const char *ver);
int calc_tmp_filenames(char **tmp1, char **tmp2);
int show_and_install_readme(const char *fname, const char *text);
int chdir_by_identifier(const char *name, const char *str,
const char *ver, const char *newver);

#ifdef __cplusplus
}
Expand Down
18 changes: 13 additions & 5 deletions platform_unix.c
Expand Up @@ -274,7 +274,9 @@ static char *find_info_plist_bundle_id(char *ptr)
} /* find_info_plist_version */


static int parse_info_dot_plist(const char *ident, const char *version)
static int parse_info_dot_plist(const char *ident,
const char *version,
const char *newversion)
{
const char *fname = "Contents/Info.plist"; // already chdir'd for this.
char *mem = NULL;
Expand Down Expand Up @@ -316,8 +318,13 @@ static int parse_info_dot_plist(const char *ident, const char *version)
retval = 1;
else
{
_fatal("This patch applies to version '%s', but you have '%s'.",
version, ptr);
if (strcmp(version, newversion) == 0)
_fatal("You seem to be all patched up already!");
else
{
_fatal("This patch applies to version '%s', but you have '%s'.",
version, ptr);
} /* else */
free(mem);
return(0);
} /* else */
Expand Down Expand Up @@ -377,7 +384,8 @@ int update_version(const char *ver)

int manually_locate_product(const char *name, char *buf, size_t bufsize);

int chdir_by_identifier(const char *name, const char *str, const char *version)
int chdir_by_identifier(const char *name, const char *str,
const char *version, const char *newversion)
{
char buf[MAXPATHLEN];
Boolean b;
Expand Down Expand Up @@ -428,7 +436,7 @@ int chdir_by_identifier(const char *name, const char *str, const char *version)
return(0);
} /* if */

return(hasident ? parse_info_dot_plist(str, version) : 1);
return(hasident ? parse_info_dot_plist(str, version, newversion) : 1);
} /* chdir_by_identifier */


Expand Down

0 comments on commit 566669d

Please sign in to comment.