]> skyeroc.xyz Git - dgamelaunch/commitdiff
use an ARRAY_SIZE macro if available, if not, #define it
authorJoshua Kwan <joshk@triplehelix.org>
Sat, 3 Jan 2004 02:10:35 +0000 (02:10 +0000)
committerJoshua Kwan <joshk@triplehelix.org>
Sat, 3 Jan 2004 02:10:35 +0000 (02:10 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@49 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

dgamelaunch.c

index 7562f2709ce705fa3b88afcf9910b62552bacdb3..f27e0d3188d8417e16e28d8bde7e2a47e33e4499 100644 (file)
 
 #ifdef __linux__
 # include <pty.h>
+# include <libiberty.h>
+#endif
+
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(x) sizeof(x) / sizeof(x[0])
 #endif
 
 #include <grp.h>
@@ -207,7 +212,7 @@ loadbanner (struct dg_banner *ban)
                 {
                   strncat (bufnew, VERSION, 80 - i);
                   b += 8;       /* skip the whole $VERSION string */
-                  i += sizeof (VERSION) / sizeof (VERSION[0]);
+                  i += ARRAY_SIZE(VERSION);
                 }
 
               if (strlen (b) == 0)
@@ -484,9 +489,7 @@ domailuser (char *username)
 
   assert (loggedin);
 
-  len =
-    (sizeof (LOC_SPOOLDIR) / sizeof (LOC_SPOOLDIR[0])) + strlen (username) +
-    1;
+  len = ARRAY_SIZE(LOC_SPOOLDIR) +  strlen (username) + 1;
   spool_fn = malloc (len + 1);
   time (&now);
   snprintf (spool_fn, len, "%s/%s", LOC_SPOOLDIR, username);
@@ -1153,9 +1156,7 @@ main (void)
   /* environment */
   snprintf (atrcfilename, 81, "@%s", rcfilename);
 
-  len =
-    (sizeof (LOC_SPOOLDIR) / sizeof (LOC_SPOOLDIR[0])) +
-    strlen (me->username) + 1;
+  len = ARRAY_SIZE(LOC_SPOOLDIR) + strlen (me->username) + 1;
   spool = malloc (len + 1);
   snprintf (spool, len, "%s/%s", LOC_SPOOLDIR, me->username);