Skip to content

Commit

Permalink
Skip ahead in the patchfile if a given product is already patched.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed May 28, 2004
1 parent f786516 commit ba56106
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
29 changes: 19 additions & 10 deletions mojopatch.c
Expand Up @@ -157,6 +157,7 @@ static int replace = 0;
static int appending = 0;
static int alwaysadd = 0;
static int quietonsuccess = 0;
static int skip_patch = 0;
static PatchCommands command = COMMAND_NONE;

static const char *patchfile = NULL;
Expand Down Expand Up @@ -539,11 +540,16 @@ void _dlog(const char *fmt, ...)
static void _current_operation(const char *fmt, ...)
{
char buf[512];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof (buf), fmt, ap);
va_end(ap);
buf[sizeof(buf)-1] = '\0';
if (skip_patch)
strcpy(buf, "Skipping ahead...");
else
{
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof (buf), fmt, ap);
va_end(ap);
buf[sizeof(buf)-1] = '\0';
} /* else */
ui_status(buf);
ui_pump();
} /* _current_operation */
Expand Down Expand Up @@ -605,7 +611,7 @@ static int in_ignore_list(const char *fname)

static inline int info_only(void)
{
return(command == COMMAND_INFO);
return((command == COMMAND_INFO) || (skip_patch));
} /* info_only */


Expand Down Expand Up @@ -1860,11 +1866,12 @@ static int process_patch_header(SerialArchive *ar, PatchHeader *h)

if (!info_only())
{
if (!chdir_by_identifier(h->product, h->identifier,
h->version, h->newversion))
{
int rc = chdir_by_identifier(h->product, h->identifier,
h->version, h->newversion);
if (rc == 0)
return(PATCHERROR);
} /* if */
else if (rc == -1)
skip_patch = 1;
} /* if */

if (*h->readmefname)
Expand Down Expand Up @@ -1932,6 +1939,8 @@ static int do_patching(void)
} /* if */
} /* if */

skip_patch = 0; /* reset for next patch... */

/* !!! FIXME: This loses command line overrides! */
memset(&header, '\0', sizeof (header));

Expand Down
10 changes: 6 additions & 4 deletions platform_unix.c
Expand Up @@ -318,15 +318,17 @@ static int parse_info_dot_plist(const char *ident,
retval = 1;
else
{
if (strcmp(version, newversion) == 0)
if (strcmp(ptr, newversion) == 0)
{
_fatal("You seem to be all patched up already!");
retval = -1;
} /* if */
else
{
_fatal("This patch applies to version '%s', but you have '%s'.",
version, ptr);
retval = 0;
} /* else */
free(mem);
return(0);
} /* else */
} /* if */

Expand All @@ -335,7 +337,7 @@ static int parse_info_dot_plist(const char *ident,
if (io != NULL)
fclose(io);

if (!retval) _fatal("Can't determine product's installed version.");
if (retval == 0) _fatal("Can't determine product's installed version.");
return(retval);
} /* parse_info_dot_plist */

Expand Down

0 comments on commit ba56106

Please sign in to comment.