X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=form%2Ffty_enum.c;h=16695cd29915fd09b24ddc387b1d35aa21f97e03;hp=0e128083689a7847a2a351946d0fe911ab60f289;hb=refs%2Ftags%2Fv4.2;hpb=3a9b6a3bf0269231bef7de74757a910dedd04e0c diff --git a/form/fty_enum.c b/form/fty_enum.c index 0e128083..16695cd2 100644 --- a/form/fty_enum.c +++ b/form/fty_enum.c @@ -13,7 +13,7 @@ #include "form.priv.h" -MODULE_ID("$Id: fty_enum.c,v 1.5 1997/02/15 17:33:59 tom Exp $") +MODULE_ID("$Id: fty_enum.c,v 1.8 1997/10/18 19:33:20 tom Exp $") typedef struct { char **kwds; @@ -63,15 +63,15 @@ static void *Make_Enum_Type(va_list * ap) static void *Copy_Enum_Type(const void * argp) { const enumARG *ap = (const enumARG *)argp; - enumARG *new = (enumARG *)0; + enumARG *result = (enumARG *)0; if (argp) { - new = (enumARG *)malloc(sizeof(enumARG)); - if (new) - *new = *ap; + result = (enumARG *)malloc(sizeof(enumARG)); + if (result) + *result = *ap; } - return (void *)new; + return (void *)result; } /*--------------------------------------------------------------------------- @@ -127,9 +127,8 @@ static int Compare(const unsigned char *s, const unsigned char *buf, } else { - while(toupper(*s)==toupper(*buf)) + while(toupper(*s++)==toupper(*buf)) { - s++; if (*buf++=='\0') return EXACT; } } @@ -170,7 +169,7 @@ static bool Check_Enum_Field(FIELD * field, const void * argp) { if ((res=Compare((unsigned char *)s,bp,ccase))!=NOMATCH) { - t=s; + p=t=s; /* t is at least a partial match */ if ((unique && res!=EXACT)) { while( (p = *kwds++) ) @@ -181,16 +180,19 @@ static bool Check_Enum_Field(FIELD * field, const void * argp) { t = p; break; - } - t = (char *)0; + } + else + t = (char *)0; } } - } + } if (t) { set_field_buffer(field,0,t); return TRUE; } + if (!p) + break; } } return FALSE;