aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Farina <tfransosi@gmail.com>2010-06-11 01:32:18 -0300
committerLinus Torvalds <torvalds@linux-foundation.org>2010-06-11 12:48:59 -0700
commit3b4567fb813aac3c924477cbdfbdf47b19bbce9f (patch)
treec2c1e51c8e8ed0638901f2f6730eef3a54164b4d
parent9489673a1b15b764d774cef4fa15e6e0222821e3 (diff)
downloaduemacs-3b4567fb813aac3c924477cbdfbdf47b19bbce9f.tar.gz
uemacs: Use ARRAY_SIZE in more places.
Signed-off-by: Thiago Farina <thiago.farina@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--bind.c13
-rw-r--r--epath.h5
-rw-r--r--eval.c4
-rw-r--r--evar.h10
4 files changed, 18 insertions, 14 deletions
diff --git a/bind.c b/bind.c
index e7b5265..2b90175 100644
--- a/bind.c
+++ b/bind.c
@@ -7,11 +7,12 @@
* modified by Petri Kutvonen
*/
-#include <stdio.h>
-#include "estruct.h"
-#include "edef.h"
-#include "efunc.h"
-#include "epath.h"
+#include <stdio.h>
+#include "estruct.h"
+#include "edef.h"
+#include "efunc.h"
+#include "epath.h"
+#include "util.h"
int help(int f, int n)
{ /* give me some help!!!!
@@ -532,7 +533,7 @@ char *flook(char *fname, int hflag)
#endif
/* look it up via the old table method */
- for (i = 2; i < NPNAMES; i++) {
+ for (i = 2; i < ARRAY_SIZE(pathname); i++) {
strcpy(fspec, pathname[i]);
strcat(fspec, fname);
diff --git a/epath.h b/epath.h
index 1a6b7fe..1e85aaa 100644
--- a/epath.h
+++ b/epath.h
@@ -5,9 +5,10 @@
*
* modified by Petri Kutvonen
*/
+#ifndef EPATH_H_
+#define EPATH_H_
/* possible names and paths of help files under different OSs */
-
static char *pathname[] =
#if MSDOS
{
@@ -39,4 +40,4 @@ static char *pathname[] =
"sys$sysdevice:[vmstools]"};
#endif
-#define NPNAMES (sizeof(pathname)/sizeof(char *))
+#endif /* EPATH_H_ */
diff --git a/eval.c b/eval.c
index 158c336..269b4d2 100644
--- a/eval.c
+++ b/eval.c
@@ -39,12 +39,12 @@ char *gtfun(char *fname)
/* look the function up in the function table */
fname[3] = 0; /* only first 3 chars significant */
mklower(fname); /* and let it be upper or lower case */
- for (fnum = 0; fnum < NFUNCS; fnum++)
+ for (fnum = 0; fnum < ARRAY_SIZE(funcs); fnum++)
if (strcmp(fname, funcs[fnum].f_name) == 0)
break;
/* return errorm on a bad reference */
- if (fnum == NFUNCS)
+ if (fnum == ARRAY_SIZE(funcs))
return (errorm);
/* if needed, retrieve the first argument */
diff --git a/evar.h b/evar.h
index 3ad1a68..50e6fbb 100644
--- a/evar.h
+++ b/evar.h
@@ -6,8 +6,10 @@
* modified by Petri Kutvonen
*/
-/* structure to hold user variables and their definitions */
+#ifndef EVAR_H_
+#define EVAR_H_
+/* structure to hold user variables and their definitions */
typedef struct UVAR {
char u_name[NVSIZE + 1]; /* name of user variable */
char *u_value; /* value (string) */
@@ -165,9 +167,7 @@ static UFUNC funcs[] = {
{ "xla", TRINAMIC }, /* XLATE character string translation */
};
-#define NFUNCS sizeof(funcs) / sizeof(UFUNC)
-
-/* and its preprocesor definitions */
+/* and its preprocesor definitions */
#define UFADD 0
#define UFSUB 1
@@ -208,3 +208,5 @@ static UFUNC funcs[] = {
#define UFBXOR 36
#define UFBNOT 37
#define UFXLATE 38
+
+#endif /* EVAR_H_ */