The following commit has been merged in the master branch:
commit b571373cd2e62782c3bb2b8e0bef585c4215b967
Author: Guillem Jover <[email protected]>
Date: Sat Oct 16 20:47:20 2010 +0200
libdpkg: Refactor error display setter into a static function
Create a new function that takes an error context argument and sets
the error printer function. This allows using the new setter for
other error_context than econtext.
diff --git a/lib/dpkg/ehandle.c b/lib/dpkg/ehandle.c
index 79b19eb..09b1a77 100644
--- a/lib/dpkg/ehandle.c
+++ b/lib/dpkg/ehandle.c
@@ -74,11 +74,14 @@ static struct {
void *args[20];
} emergency;
+static void set_error_printer(struct error_context *ec,
+ error_printer *printerror,
+ const char *contextstring);
+
void set_error_display(error_printer *printerror,
const char *contextstring) {
assert(econtext);
- econtext->printerror= printerror;
- econtext->contextstring= contextstring;
+ set_error_printer(econtext, printerror, contextstring);
}
static void DPKG_ATTR_NORET
@@ -121,6 +124,14 @@ error_context_new(void)
return necp;
}
+static void
+set_error_printer(struct error_context *ec, error_printer *printerror,
+ const char *contextstring)
+{
+ ec->printerror = printerror;
+ ec->contextstring = contextstring;
+}
+
void
push_error_handler(jmp_buf *jump, error_printer *printerror,
const char *contextstring)
@@ -128,8 +139,7 @@ push_error_handler(jmp_buf *jump, error_printer *printerror,
struct error_context *ec;
ec = error_context_new();
- ec->printerror = printerror;
- ec->contextstring = contextstring;
+ set_error_printer(ec, printerror, contextstring);
ec->jump = jump;
onerr_abort = 0;
}
@@ -170,8 +180,7 @@ run_cleanups(struct error_context *econ, int flagsetin)
recurserr.jump = &recurse_jump;
recurserr.cleanups= NULL;
recurserr.next= NULL;
- recurserr.printerror = print_cleanup_error;
- recurserr.contextstring= NULL;
+ set_error_printer(&recurserr, print_cleanup_error, NULL);
econtext= &recurserr;
cep->calls[i].call(cep->argc,cep->argv);
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]