Print a friendlier message if product appears to be patched to patchfile's
authorRyan C. Gordon <icculus@icculus.org>
Thu, 27 May 2004 15:36:02 +0000
changeset 27 569fe0e4038e
parent 26 d459ca2ce76e
child 28 decb523dfb0d
Print a friendlier message if product appears to be patched to patchfile's version already.
TODO
mojopatch.c
platform.h
platform_unix.c
--- a/TODO	Thu May 27 12:43:58 2004 +0000
+++ b/TODO	Thu May 27 15:36:02 2004 +0000
@@ -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 ... */
 
--- a/mojopatch.c	Thu May 27 12:43:58 2004 +0000
+++ b/mojopatch.c	Thu May 27 15:36:02 2004 +0000
@@ -1819,8 +1819,11 @@
 
     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)
--- a/platform.h	Thu May 27 12:43:58 2004 +0000
+++ b/platform.h	Thu May 27 15:36:02 2004 +0000
@@ -57,10 +57,11 @@
 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
 }
--- a/platform_unix.c	Thu May 27 12:43:58 2004 +0000
+++ b/platform_unix.c	Thu May 27 15:36:02 2004 +0000
@@ -274,7 +274,9 @@
 } /* 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 @@
             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 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 @@
         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 */