The following commit has been merged in the lenny branch:
commit 9080bf737b8beb5b34efb7546e39857787412e23
Author: Guillem Jover <[EMAIL PROTECTED]>
Date:   Wed Oct 15 09:34:36 2008 +0300

    libdpkg: Refactor error handler execution code
    
    Move all longjmp calls to a new run_error_handler function.

diff --git a/ChangeLog b/ChangeLog
index abc54c2..5f5aaab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-11-14  Guillem Jover  <[EMAIL PROTECTED]>
+
+       * lib/ehandle.c (run_error_handler): New function.
+       (push_error_handler): Use run_error_handler instead of directly
+       calling longjmp.
+       (ohshit): Likewise.
+       (ohshitvb): Likewise.
+       (ohshitv): Likewise.
+       (ohshite): Likewise.
+
 2008-11-07  Raphael Hertzog  <[EMAIL PROTECTED]>
 
        * scripts/Dpkg/Version.pm: Synchronize code with version used by
diff --git a/lib/ehandle.c b/lib/ehandle.c
index 5d857ed..fbd69c2 100644
--- a/lib/ehandle.c
+++ b/lib/ehandle.c
@@ -70,6 +70,14 @@ void set_error_display(error_printer *printerror,
   econtext->contextstring= contextstring;
 }
 
+static void run_error_handler(void) NONRETURNING;
+
+static void
+run_error_handler(void)
+{
+  longjmp(*econtext->jbufp, 1);
+}
+
 void push_error_handler(jmp_buf *jbufp,
                         error_printer *printerror,
                         const char *contextstring) {
@@ -80,7 +88,8 @@ void push_error_handler(jmp_buf *jbufp,
     snprintf(errmsgbuf, sizeof(errmsgbuf), "%s%s", 
            _("out of memory pushing error handler: "), strerror(e));
     errmsg= errmsgbuf;
-    if (econtext) longjmp(*econtext->jbufp,1);
+    if (econtext)
+      run_error_handler();
     fprintf(stderr, "%s: %s\n", thisname, errmsgbuf); exit(2);
   }
   necp->next= econtext;
@@ -219,7 +228,8 @@ void ohshit(const char *fmt, ...) {
   vsnprintf(errmsgbuf,sizeof(errmsgbuf),fmt,al);
   va_end(al);
   errmsg= errmsgbuf;
-  longjmp(*econtext->jbufp,1);
+
+  run_error_handler();
 }
 
 void print_error_fatal(const char *emsg, const char *contextstring) {
@@ -232,13 +242,15 @@ void ohshitvb(struct varbuf *vb) {
   m= m_malloc(strlen(vb->buf));
   strcpy(m,vb->buf);
   errmsg= m;
-  longjmp(*econtext->jbufp,1);
+
+  run_error_handler();
 }
 
 void ohshitv(const char *fmt, va_list al) {
   vsnprintf(errmsgbuf,sizeof(errmsgbuf),fmt,al);
   errmsg= errmsgbuf;
-  longjmp(*econtext->jbufp,1);
+
+  run_error_handler();
 }
 
 void ohshite(const char *fmt, ...) {
@@ -253,7 +265,8 @@ void ohshite(const char *fmt, ...) {
 
   snprintf(errmsgbuf,sizeof(errmsgbuf),"%s: %s",buf,strerror(e));
   errmsg= errmsgbuf; 
-  longjmp(*econtext->jbufp,1);
+
+  run_error_handler();
 }
 
 void warningf(const char *fmt, ...) {

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to