From f536645e587fbf0845498e3581df9b697811b3b4 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Fri, 28 Jan 2022 13:59:25 +0100 Subject: [PATCH] [form] str2form returned type enum form_type --- src/document/forms.c | 4 ++-- src/document/forms.h | 3 ++- src/formhist/formhist.c | 6 ++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/document/forms.c b/src/document/forms.c index 745cdb3f..b97bd9f2 100644 --- a/src/document/forms.c +++ b/src/document/forms.c @@ -41,7 +41,7 @@ static struct form_type_name form_type2name[] = { #define FORM_TYPE_COUNT (sizeof(form_type2name)/sizeof(struct form_type_name)) -int +enum form_type str2form_type(char *s) { int n; @@ -50,7 +50,7 @@ str2form_type(char *s) if (!strcmp(form_type2name[n].name, s)) return form_type2name[n].num; - return -1; + return FC_NONE; } char * diff --git a/src/document/forms.h b/src/document/forms.h index 3e13c979..f3f565b4 100644 --- a/src/document/forms.h +++ b/src/document/forms.h @@ -71,6 +71,7 @@ enum form_type { FC_RESET, FC_BUTTON, FC_HIDDEN, + FC_NONE = -1 }; enum form_mode { @@ -125,7 +126,7 @@ struct el_form_control { }; /* Numerical form type <-> form type name */ -int str2form_type(char *s); +enum form_type str2form_type(char *s); char *form_type2str(enum form_type num); struct form *init_form(void); diff --git a/src/formhist/formhist.c b/src/formhist/formhist.c index 9f3f7c61..5de8144d 100644 --- a/src/formhist/formhist.c +++ b/src/formhist/formhist.c @@ -143,7 +143,6 @@ load_formhist_from_file(void) char *type, *name, *value; char *enc_value; enum form_type ftype; - int ret; if (tmp[0] == '\n' && !tmp[1]) break; @@ -180,9 +179,8 @@ cont: if (!p) goto fail; *p = '\0'; - ret = str2form_type(type); - if (ret == -1) goto fail; - ftype = ret; + ftype = str2form_type(type); + if (ftype == FC_NONE) goto fail; if (form->dontsave) continue;