Subject: [[email-masked]: FvwmButtons - somewhat harder...]

From: Dominik Vogt <[email-masked]>
Date: Wed, 16 Dec 1998 13:48:21 +0100

----- Forwarded message from [email-masked] -----

Date: Tue, 15 Dec 1998 21:02:24 -0500
Subject: FvwmButtons - somewhat harder...
From: [email-masked]
To: [email-masked]

Hi,
This patch is more difficult because I stripped the TABs out of
FvwmButtons.c (nasty things and no-one can ever agree how many spaces
they should represent). I shall list my significant changes instead:

FvwmButtons.c >>>>>>>>>>>>>>>

#include <setjmp.h>

...

#ifdef __GNUC__
#  define _GNU_ATTR_NORETURN_  __attribute__((noreturn))
#else
#  define _GNU_ATTR_NORETURN_
#endif

...

void DeadPipe(int) _GNU_ATTR_NORETURN_
static void DeadPipeCleanup(void);
static void DeadPipeHandler(int sig);
...
static void nocolor(const char *a, const char *b) _GNU_ATTR_NORETURN_;
...

static sigjmp_buf  deadjump;

...

/*
** DeadPipe()
** Externally callable function to quit!
void DeadPipe(int nonsense)
{
  exit(1);
}

/*
** DeadPipeHandler()
** Signal handler that will make the event loop terminate
*/
static void DeadPipeHandler(int sig)
{
  siglongjmp(deadjump,1);
}

/*
** DeadPipeCleanup()
** Remove all the windows from the Button-Bar, and close them as
necessary.
** Note that this is an exit-procedure and so will be called
automatically
*/
static void DeadPipeCleanup(void)
{
 ... original cleanup code , except it doesn't call exit()
}

...

static XErrorHandler oldErrorHandler=NULL;
int myErrorHandler(Display *dpy, XErrorEvent *event)
{
  /* fprintf( ... etc */
  /* Don't call the default handler - it kills the button-bar.
   * We want to give the button-bar a chance to respawn its dead button
   */
  /* return (*oldErrorHandler)(dpy,event); */
  return 0;
}

int main( ...
{
  char *s;
...

  MyName = argv[0];
  s = strrchr(MyName,'/');
  if (s) MyName = s+1;

 - No need to allocate storage for the module name; just assign MyName
in a more cunning way.
...

  /*
  ** Now that we have finished initialising everything,
  ** it is safe(r) to install the clean-up handlers ...
  */
  atexit(DeadPipeCleanup);
  if ( !sigsetjmp(deadjump,1) )
  {
    struct sigaction  sigact;

    /* Do NOT install the signal handlers until the long-jump
     * has been safely initialised ...
     */
    sigemptyset(&sigact.sa_mask);
    sigact.sa_flags = 0;
    sigact.sa_handler = DeadPipeHandler;

    sigaction(SIGPIPE,&sigact,NULL);
    sigaction(SIGINT,&sigact,NULL);
    sigaction(SIGHUP,&sigact,NULL);
    sigaction(SIGQUIT,&sigact,NULL);
    sigaction(SIGTERM,&sigact,NULL);

    Loop();
  }
  /**/
  return 0;
}

The attachment contains the rest of the changes - mostly fixes for
compiler warnings.

Cheers,
Chris

----- End forwarded message -----

-- 
Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/14-4596, fax: 07031/14-3883, [email-masked]
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].

---

From: [email-masked] (Paul D. Smith)
Date: 16 Dec 1998 10:11:22 -0500

%% Dominik Vogt <[email-masked]> writes:

  c> #ifdef __GNUC__
  c> #  define _GNU_ATTR_NORETURN_  __attribute__((noreturn))
  c> #else
  c> #  define _GNU_ATTR_NORETURN_
  c> #endif

Note this isn't the right way to handle these GCC extensions.  They were
designed precisely so they could be removed without this type of thing.
The are dang handy, though; I esp. like the printf format attributes but
those require even more testing since they weren't introduced until
later versions of GCC.

I will check in some changes today that enable/disable this stuff
correctly, pulled from my work on other GNU packages.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].