]> Dogcows Code - chaz/openbox/commitdiff
add strict ansi compliance
authorDana Jansens <danakj@orodu.net>
Fri, 21 Mar 2003 20:25:34 +0000 (20:25 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 21 Mar 2003 20:25:34 +0000 (20:25 +0000)
engines/openbox/openbox.c
m4/openbox.m4
openbox/event.c
openbox/openbox.c
openbox/plugin.c
openbox/timer.c
render/color.c
render/font.c
render/mask.c
render/render.c
render/test.c

index 06b366168161fc079580d6710aae632d1ecd7506..3115df74c477f2c5f7f8a53ab3afbda9b13763da 100644 (file)
@@ -177,7 +177,7 @@ gboolean startup()
     a_unfocused_title = appearance_new(Surface_Planar, 0);
     a_focused_label = appearance_new(Surface_Planar, 1);
     a_unfocused_label = appearance_new(Surface_Planar, 1);
-    a_icon = appearance_new(Surface_Planar, 0);//1);
+    a_icon = appearance_new(Surface_Planar, 0);/*1);*/
     a_focused_handle = appearance_new(Surface_Planar, 0);
     a_unfocused_handle = appearance_new(Surface_Planar, 0);
 
index aef68281a6702d78bc46d7db223a1df51a417c16..98033c9ff40b66106413d18a5d51d0aa3cd4ab33 100644 (file)
@@ -5,12 +5,18 @@
 # Sets the CVS environment variable when building CVS sources.
 AC_DEFUN([OB_DEBUG],
 [
-  DEBUG="no"
-  AC_MSG_CHECKING([build target type])
+  AC_MSG_CHECKING([build type])
 
   AC_ARG_ENABLE([debug],
-  [  --enable-debug          build a debug version default=no],
-  [DEBUG=$enableval],[])
+  [  --enable-debug          build a debug version default=yes],
+  [DEBUG=$enableval], [DEBUG="yes"])
+
+  AC_ARG_ENABLE([strict-ansi],
+  [  --enable-strict-ansi    Enable strict ANSI compliance build default=no],
+  [STRICT=$enableval], [STRICT="no"])
+  if test "$GCC" = "yes" && test "$STRICT" = "yes"; then
+    CFLAGS="$CFLAGS -ansi -pedantic -D_XOPEN_SOURCE"
+  fi
 
   # cvs builds are always debug
   CVS=""
@@ -18,17 +24,20 @@ AC_DEFUN([OB_DEBUG],
   test "$CVS" = "yes" && DEBUG="yes"
 
   if test "$DEBUG" = "yes"; then
-    if test "$CVS" = "yes"; then
-      AC_MSG_RESULT([DEBUG (CVS build)])
-    else
-      AC_MSG_RESULT([DEBUG])
-    fi
-    AC_DEFINE([DEBUG], [1], [Creating a debug build])
+    MSG="DEBUG"
   else
-    AC_MSG_RESULT([RELEASE])
-# keep the asserts in
-#    AC_DEFINE([NDEBUG], [1], [Creating a release build])
+    MSG="RELEASE"
   fi
+  if test "$CVS" = "yes"; then
+    MSG="$MSG (CVS build)"
+  fi
+  if test "$STRICT" = "yes"; then
+    MSG="$MSG with strict ANSI compliance"
+  fi
+  AC_MSG_RESULT([$MSG])
+  
+  test "$DEBUG" = "yes" && \
+      AC_DEFINE([DEBUG], [1], [Creating a debug build])
 
   AM_CONDITIONAL(CVS, test "$CVS" = "yes")
 ])
@@ -56,26 +65,10 @@ AC_DEFUN([OB_COMPILER_FLAGS],
       FLAGS="$FLAGS -Wcast-qual -Wbad-function-cast -Wpointer-arith"
       # for Python.h
       FLAGS="$FLAGS -Wno-long-long"
-    else
-      FLAGS=""
     fi
-#  else
-#    AC_MSG_RESULT([no, trying other compilers])
-#    AC_MSG_CHECKING(for MIPSpro)
-#    mips_pro_ver=`$CC -version 2>&1 | grep -i mipspro | cut -f4 -d ' '`
-#    if test -z "$mips_pro_ver"; then
-#      AC_MSG_RESULT([no])
-#    else
-#      AC_MSG_RESULT([yes, version $mips_pro_ver.])
-#      AC_MSG_CHECKING(for -LANG:std in CFLAGS)
-#      lang_std_not_set=`echo $CFLAGS | grep "\-LANG:std"`
-#      if test "x$lang_std_not_set" = "x"; then
-#        AC_MSG_RESULT([not set, setting.])
-#        FLAGS="-LANG:std"
-#      else
-#        AC_MSG_RESULT([already set.])
-#      fi
-#    fi
+    if test "$STRICT" = "yes"; then
+      FLAGS="$FLAGS -ansi -pedantic -D_XOPEN_SOURCE"
+    fi
   fi
   AC_MSG_CHECKING([for compiler specific flags])
   AC_MSG_RESULT([$FLAGS])
index 68615facf7cc5258ccf8bcf71087f5f28ed7604a..97e1412f00e902ef634b4949f360f44d08db14ca 100644 (file)
@@ -15,6 +15,9 @@
 #include <X11/Xlib.h>
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
+#ifdef HAVE_SYS_SELECT_H
+#  include <sys/select.h>
+#endif
 
 static void event_process(XEvent *e);
 static void event_handle_root(XEvent *e);
index a4f527b1824690ac6f61731459cc58ece0104dae..04e07ab628fc1e8d73e70e2d30fbcfced47234bc 100644 (file)
@@ -19,9 +19,6 @@
 #ifdef HAVE_FCNTL_H
 #  include <fcntl.h>
 #endif
-#ifdef HAVE_SYS_SELECT_H
-#  include <sys/select.h>
-#endif
 #ifdef HAVE_SIGNAL_H
 #  include <signal.h>
 #endif
@@ -78,7 +75,7 @@ int main(int argc, char **argv)
     sigemptyset(&sigset);
     action.sa_handler = dispatch_signal;
     action.sa_mask = sigset;
-    action.sa_flags = SA_NOCLDSTOP | SA_NODEFER;
+    action.sa_flags = SA_NOCLDSTOP;
     sigaction(SIGUSR1, &action, (struct sigaction *) NULL);
     sigaction(SIGPIPE, &action, (struct sigaction *) NULL);
     sigaction(SIGSEGV, &action, (struct sigaction *) NULL);
index 247d490a5faa03fe5b1c090f8cc6a6f33a2aae52..a8556fc728ba56a900d8fabea74f3ba2c76ac799 100644 (file)
@@ -46,8 +46,8 @@ static Plugin *plugin_new(char *name)
         return NULL;
     }
 
-    p->startup = load_sym(p->module, name, "plugin_startup");
-    p->shutdown = load_sym(p->module, name, "plugin_shutdown");
+    p->startup = (PluginStartup)load_sym(p->module, name, "plugin_startup");
+    p->shutdown = (PluginShutdown)load_sym(p->module, name, "plugin_shutdown");
 
     if (p->startup == NULL || p->shutdown == NULL) {
         g_module_close(p->module);
index 0cec366f16a9eefa90158a7b60733c0496657e3f..b6a82cd37fe7eba1443f3268265d70d6ffe0d4fc 100644 (file)
@@ -10,12 +10,21 @@ static GSList *timers; /* nearest timer is at the top */
 
 #define NEAREST_TIMEOUT (((Timer*)timers->data)->timeout)
 
+static long timecompare(GTimeVal *a, GTimeVal *b)
+{
+    long r;
+
+    if ((r = b->tv_sec - a->tv_sec)) return r;
+    return b->tv_usec - a->tv_sec;
+    
+}
+
 static void insert_timer(Timer *self)
 {
     GSList *it;
     for (it = timers; it != NULL; it = it->next) {
        Timer *t = it->data;
-       if (!timercmp(&self->timeout, &t->timeout, >)) {
+        if (timecompare(&self->timeout, &t->timeout) <= 0) {
            timers = g_slist_insert_before(timers, it, self);
            break;
        }
@@ -99,7 +108,7 @@ void timer_dispatch(GTimeVal **wait)
        
        /* the queue is sorted, so if this timer shouldn't fire, none are 
           ready */
-       if (!timercmp(&now, &NEAREST_TIMEOUT, >))
+        if (timecompare(&now, &NEAREST_TIMEOUT) <= 0)
            break;
 
        /* we set the last fired time to delay msec after the previous firing,
index 10ad5e3b95cec7657ccd229fa4822dcb2f29448e..0d3f81321a6c64c129b9e57e51c9cdc376a08f52 100644 (file)
@@ -17,7 +17,7 @@ color_rgb *color_parse(char *colorname)
     XColor xcol;
 
     g_assert(colorname != NULL);
-    // get rgb values from colorname                                  
+    /* get rgb values from colorname */
 
     xcol.red = 0;
     xcol.green = 0;
@@ -50,56 +50,57 @@ color_rgb *color_new(int r, int g, int b)
     return NULL;
 }
 
-//XXX same color could be pointed to twice, this might have to be a refcount
+/*XXX same color could be pointed to twice, this might have to be a refcount*/
 
 void color_free(color_rgb *c)
 {
     if (c->gc != None)
         XFreeGC(ob_display, c->gc);
-    free(c);
+    g_free(c);
 }
 
 void reduce_depth(pixel32 *data, XImage *im)
 {
-  // since pixel32 is the largest possible pixel size, we can share the array
-  int r, g, b;
-  int x,y;
-  pixel16 *p = (pixel16*) data;
-  switch (im->bits_per_pixel) {
-  case 32:
-    if ((render_red_offset != default_red_shift) ||
-        (render_blue_offset != default_blue_shift) ||
-        (render_green_offset != default_green_shift)) {
-      for (y = 0; y < im->height; y++) {
-        for (x = 0; x < im->width; x++) {
-          r = (data[x] >> default_red_shift) & 0xFF;
-          g = (data[x] >> default_green_shift) & 0xFF;
-          b = (data[x] >> default_blue_shift) & 0xFF;
-          data[x] = (r << render_red_offset) + (g << render_green_offset) +
-            (b << render_blue_offset);
+    /* since pixel32 is the largest possible pixel size, we can share the
+       array*/
+    int r, g, b;
+    int x,y;
+    pixel16 *p = (pixel16*) data;
+    switch (im->bits_per_pixel) {
+    case 32:
+        if ((render_red_offset != default_red_shift) ||
+            (render_blue_offset != default_blue_shift) ||
+            (render_green_offset != default_green_shift)) {
+            for (y = 0; y < im->height; y++) {
+                for (x = 0; x < im->width; x++) {
+                    r = (data[x] >> default_red_shift) & 0xFF;
+                    g = (data[x] >> default_green_shift) & 0xFF;
+                    b = (data[x] >> default_blue_shift) & 0xFF;
+                    data[x] = (r << render_red_offset) + (g << render_green_offset) +
+                        (b << render_blue_offset);
+                }
+                data += im->width;
+            } 
         }
-        data += im->width;
-      } 
-    }
-    break;
-  case 16:
-    for (y = 0; y < im->height; y++) {
-      for (x = 0; x < im->width; x++) {
-        r = (data[x] >> default_red_shift) & 0xFF;
-        r = r >> render_red_shift;
-        g = (data[x] >> default_green_shift) & 0xFF;
-        g = g >> render_green_shift;
-        b = (data[x] >> default_blue_shift) & 0xFF;
-        b = b >> render_blue_shift;
-        p[x] = (r << render_red_offset)
-             + (g << render_green_offset)
-             + (b << render_blue_offset);
-      }
-      data += im->width;
-      p += im->bytes_per_line/2;
+        break;
+    case 16:
+        for (y = 0; y < im->height; y++) {
+            for (x = 0; x < im->width; x++) {
+                r = (data[x] >> default_red_shift) & 0xFF;
+                r = r >> render_red_shift;
+                g = (data[x] >> default_green_shift) & 0xFF;
+                g = g >> render_green_shift;
+                b = (data[x] >> default_blue_shift) & 0xFF;
+                b = b >> render_blue_shift;
+                p[x] = (r << render_red_offset)
+                    + (g << render_green_offset)
+                    + (b << render_blue_offset);
+            }
+            data += im->width;
+            p += im->bytes_per_line/2;
+        }
+        break;
+    default:
+        g_message("your bit depth is currently unhandled\n");
     }
-    break;
-  default:
-    g_message("your bit depth is currently unhandled\n");
-  }
 }
index d9bc4987bef84a2a441bdd891f8c580f0d2cc030..405cf1c395c9dcf22cda9878a6885dd54e8ab2bd 100644 (file)
@@ -62,7 +62,7 @@ ObFont *font_open(char *fontstring)
     g_warning(_("Unable to load font: %s\n"), "fixed");
     g_warning(_("Aborting!.\n"));
 
-    exit(3); // can't continue without a font
+    exit(3); /* can't continue without a font */
 }
 
 void font_close(ObFont *f)
index 868c76125aad1f88c0b871fec9e9280673e16ca4..5f5aa263057dc30b0c2e6bf4b9b3778b4a1e7bc8 100644 (file)
@@ -19,19 +19,19 @@ void pixmap_mask_free(pixmap_mask *m)
 void mask_draw(Pixmap p, TextureMask *m, int width, int height)
 {
     int x, y;
-    if (m->mask == None) return; // no mask given
+    if (m->mask == None) return; /* no mask given */
 
-    // set the clip region
+    /* set the clip region */
     x = (width - m->mask->w) / 2;
     y = (height - m->mask->h) / 2;
     XSetClipMask(ob_display, m->color->gc, m->mask->mask);
     XSetClipOrigin(ob_display, m->color->gc, x, y);
 
-    // fill in the clipped region
+    /* fill in the clipped region */
     XFillRectangle(ob_display, p, m->color->gc, x, y,
                    x + m->mask->w, y + m->mask->h);
 
-    // unset the clip region
+    /* unset the clip region */
     XSetClipMask(ob_display, m->color->gc, None);
     XSetClipOrigin(ob_display, m->color->gc, 0, 0);
 }
index df0ed282e0d757f7e2e4e69679b39540e0c84d8b..7129974c56d0b32dcbd8c705fb118a65130ba7de 100644 (file)
@@ -24,8 +24,8 @@ void render_startup(void)
 
     if (render_depth < 8) {
       XVisualInfo vinfo_template, *vinfo_return;
-      // search for a TrueColor Visual... if we can't find one...
-      // we will use the default visual for the screen
+      /* search for a TrueColor Visual... if we can't find one...
+         we will use the default visual for the screen */
       int vinfo_nitems;
       int best = -1;
 
@@ -40,7 +40,7 @@ void render_startup(void)
         for (i = 0; i < vinfo_nitems; ++i) {
           if (vinfo_return[i].depth > max_depth) {
             if (max_depth == 24 && vinfo_return[i].depth > 24)
-              break;          // prefer 24 bit over 32
+                break;          /* prefer 24 bit over 32 */
             max_depth = vinfo_return[i].depth;
             best = i;
           }
@@ -66,7 +66,7 @@ void truecolor_startup(void)
   timage = XCreateImage(ob_display, render_visual, render_depth,
                         ZPixmap, 0, NULL, 1, 1, 32, 0);
   g_assert(timage != NULL);
-  // find the offsets for each color in the visual's masks
+  /* find the offsets for each color in the visual's masks */
   red_mask = timage->red_mask;
   green_mask = timage->green_mask;
   blue_mask = timage->blue_mask;
@@ -122,8 +122,8 @@ void x_paint(Window win, Appearance *l, int x, int y, int w, int h)
                           ZPixmap, 0, NULL, w, h, 32, 0);
         g_assert(im != NULL);
         im->byte_order = endian;
-        im->data = (unsigned char *)l->surface.data.planar.pixel_data;
-        reduce_depth(im->data, im);
+        im->data = (char *)l->surface.data.planar.pixel_data;
+        reduce_depth((pixel32*)im->data, im);
         XPutImage(ob_display, l->pixmap, DefaultGC(ob_display, ob_screen),
                   im, 0, 0, x, y, w, h);
         im->data = NULL;
index b42f553d5365bc964dec0932ac0a3e952205f02e..459d26621b4fa4376a03c07d6c6e54908d52f96a 100644 (file)
@@ -41,11 +41,11 @@ int main()
        win =
            XCreateWindow(ob_display, RootWindow(ob_display, 0)
                           , 10, 10, w, h, 10, 
-                          CopyFromParent,      // depth
-                         CopyFromParent,       // class
-                         CopyFromParent,       // visual
-                         0,    // valuemask
-                         0);   // attributes
+                          CopyFromParent,      /* depth */
+                         CopyFromParent,       /* class */
+                         CopyFromParent,       /* visual */
+                         0,                    /* valuemask */
+                         0);                   /* attributes */
        XMapWindow(ob_display, win);
        XSelectInput(ob_display, win, ExposureMask | StructureNotifyMask);
        root = RootWindow (ob_display, DefaultScreen (ob_display));
This page took 0.034672 seconds and 4 git commands to generate.