1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-24 01:56:26 -05:00

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>
This commit is contained in:
Thiago Farina 2010-06-11 01:32:18 -03:00 committed by Linus Torvalds
parent 9489673a1b
commit 3b4567fb81
4 changed files with 18 additions and 14 deletions

3
bind.c
View File

@ -12,6 +12,7 @@
#include "edef.h" #include "edef.h"
#include "efunc.h" #include "efunc.h"
#include "epath.h" #include "epath.h"
#include "util.h"
int help(int f, int n) int help(int f, int n)
{ /* give me some help!!!! { /* give me some help!!!!
@ -532,7 +533,7 @@ char *flook(char *fname, int hflag)
#endif #endif
/* look it up via the old table method */ /* 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]); strcpy(fspec, pathname[i]);
strcat(fspec, fname); strcat(fspec, fname);

View File

@ -5,9 +5,10 @@
* *
* modified by Petri Kutvonen * modified by Petri Kutvonen
*/ */
#ifndef EPATH_H_
#define EPATH_H_
/* possible names and paths of help files under different OSs */ /* possible names and paths of help files under different OSs */
static char *pathname[] = static char *pathname[] =
#if MSDOS #if MSDOS
{ {
@ -39,4 +40,4 @@ static char *pathname[] =
"sys$sysdevice:[vmstools]"}; "sys$sysdevice:[vmstools]"};
#endif #endif
#define NPNAMES (sizeof(pathname)/sizeof(char *)) #endif /* EPATH_H_ */

4
eval.c
View File

@ -39,12 +39,12 @@ char *gtfun(char *fname)
/* look the function up in the function table */ /* look the function up in the function table */
fname[3] = 0; /* only first 3 chars significant */ fname[3] = 0; /* only first 3 chars significant */
mklower(fname); /* and let it be upper or lower case */ 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) if (strcmp(fname, funcs[fnum].f_name) == 0)
break; break;
/* return errorm on a bad reference */ /* return errorm on a bad reference */
if (fnum == NFUNCS) if (fnum == ARRAY_SIZE(funcs))
return (errorm); return (errorm);
/* if needed, retrieve the first argument */ /* if needed, retrieve the first argument */

8
evar.h
View File

@ -6,8 +6,10 @@
* modified by Petri Kutvonen * 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 { typedef struct UVAR {
char u_name[NVSIZE + 1]; /* name of user variable */ char u_name[NVSIZE + 1]; /* name of user variable */
char *u_value; /* value (string) */ char *u_value; /* value (string) */
@ -165,8 +167,6 @@ static UFUNC funcs[] = {
{ "xla", TRINAMIC }, /* XLATE character string translation */ { "xla", TRINAMIC }, /* XLATE character string translation */
}; };
#define NFUNCS sizeof(funcs) / sizeof(UFUNC)
/* and its preprocesor definitions */ /* and its preprocesor definitions */
#define UFADD 0 #define UFADD 0
@ -208,3 +208,5 @@ static UFUNC funcs[] = {
#define UFBXOR 36 #define UFBXOR 36
#define UFBNOT 37 #define UFBNOT 37
#define UFXLATE 38 #define UFXLATE 38
#endif /* EVAR_H_ */