diff options
author | Thiago Farina <tfransosi@gmail.com> | 2010-06-11 01:32:18 -0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-06-11 12:48:59 -0700 |
commit | 3b4567fb813aac3c924477cbdfbdf47b19bbce9f (patch) | |
tree | c2c1e51c8e8ed0638901f2f6730eef3a54164b4d | |
parent | 9489673a1b15b764d774cef4fa15e6e0222821e3 (diff) | |
download | uemacs-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.c | 13 | ||||
-rw-r--r-- | epath.h | 5 | ||||
-rw-r--r-- | eval.c | 4 | ||||
-rw-r--r-- | evar.h | 10 |
4 files changed, 18 insertions, 14 deletions
@@ -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); @@ -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_ */ @@ -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 */ @@ -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_ */ |