From 3b4567fb813aac3c924477cbdfbdf47b19bbce9f Mon Sep 17 00:00:00 2001 From: Thiago Farina Date: Fri, 11 Jun 2010 01:32:18 -0300 Subject: [PATCH] uemacs: Use ARRAY_SIZE in more places. Signed-off-by: Thiago Farina Signed-off-by: Linus Torvalds --- bind.c | 13 +++++++------ epath.h | 5 +++-- eval.c | 4 ++-- evar.h | 10 ++++++---- 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 -#include "estruct.h" -#include "edef.h" -#include "efunc.h" -#include "epath.h" +#include +#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_ */