From 566669d7c908a11d8f760457041a22e5422447d3 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 27 May 2004 15:36:02 +0000 Subject: [PATCH] Print a friendlier message if product appears to be patched to patchfile's version already. --- TODO | 1 + mojopatch.c | 5 ++++- platform.h | 3 ++- platform_unix.c | 18 +++++++++++++----- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index ed4adc3..653bd24 100644 --- a/TODO +++ b/TODO @@ -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 ... */ diff --git a/mojopatch.c b/mojopatch.c index 0d51caf..7e5cb48 100644 --- a/mojopatch.c +++ b/mojopatch.c @@ -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) diff --git a/platform.h b/platform.h index 9473b0a..6a7982b 100644 --- a/platform.h +++ b/platform.h @@ -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 } diff --git a/platform_unix.c b/platform_unix.c index f515a90..04f162e 100644 --- a/platform_unix.c +++ b/platform_unix.c @@ -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; @@ -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 */ @@ -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; @@ -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 */