From 1142b82fe4dec980846a620409bb462f765ea74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= Date: Wed, 5 Jun 2013 00:49:19 +0200 Subject: contrib/{sloppy,unrat}.c: make this code actually readable... --- contrib/sloppy.c | 67 ++++++++++++++++++++++++++++++++------------------------ contrib/unrat.c | 55 +++++++++++++++++++++++++++------------------- 2 files changed, 71 insertions(+), 51 deletions(-) (limited to 'contrib') diff --git a/contrib/sloppy.c b/contrib/sloppy.c index 066dce1..3656476 100644 --- a/contrib/sloppy.c +++ b/contrib/sloppy.c @@ -6,12 +6,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * unrat is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, @@ -27,26 +27,26 @@ #include #include -int (*defaulthandler)(Display *, XErrorEvent *); +int (*defaulthandler) (Display *, XErrorEvent *); int -errorhandler(Display *display, XErrorEvent *error) +errorhandler (Display *display, XErrorEvent *error) { - if(error->error_code!=BadWindow) - (*defaulthandler)(display,error); + if (error->error_code != BadWindow) + (*defaulthandler) (display, error); return 0; } int -spawn(char *cmd) +spawn (char *cmd) { int pid; - pid = fork(); - if (pid == 0) + pid = fork (); + if (pid == 0) { - execl("/bin/sh", "sh", "-c", cmd, (char *)NULL); - _exit(EXIT_FAILURE); + execl ("/bin/sh", "sh", "-c", cmd, (char *)NULL); + _exit (EXIT_FAILURE); } return pid; } @@ -57,42 +57,51 @@ main (void) Display *display; int i, numscreens; - display = XOpenDisplay(NULL); - if(!display) + display = XOpenDisplay (NULL); + if (!display) { fprintf (stderr, "sloppy: could not open display\n"); - exit(1); + exit (1); } - defaulthandler = XSetErrorHandler(errorhandler); - numscreens = ScreenCount(display); + defaulthandler = XSetErrorHandler (errorhandler); + numscreens = ScreenCount (display); - for (i=0; i #include -int (*defaulthandler)(Display *, XErrorEvent *); +int (*defaulthandler) (Display *, XErrorEvent *); int -errorhandler(Display *display, XErrorEvent *error) +errorhandler (Display *display, XErrorEvent *error) { - if(error->error_code!=BadWindow) - (*defaulthandler)(display,error); + if (error->error_code != BadWindow) + (*defaulthandler) (display,error); + return 0; } @@ -47,25 +48,27 @@ main (void) Display *display; int i, numscreens; - display = XOpenDisplay(NULL); - if(!display) + display = XOpenDisplay (NULL); + if (!display) { fprintf (stderr, "unrat: could not open display\n"); - exit(1); + exit (1); } - defaulthandler = XSetErrorHandler(errorhandler); - numscreens = ScreenCount(display); + defaulthandler = XSetErrorHandler (errorhandler); + numscreens = ScreenCount (display); - for (i=0; i