diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-08-24 13:35:36 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-08-24 13:35:36 +0300 |
commit | edb45ae46449ddabcac3dea6b3f42c6cec01510a (patch) | |
tree | a27a046df30e4ead8f36c559dabdecb2fa1d7ea5 /src/app_del.c | |
parent | 82de29cf7bad3d9cbb0aeb4dbe756ad2bde73eb3 (diff) | |
download | apk-tools-edb45ae46449ddabcac3dea6b3f42c6cec01510a.tar.gz apk-tools-edb45ae46449ddabcac3dea6b3f42c6cec01510a.tar.bz2 apk-tools-edb45ae46449ddabcac3dea6b3f42c6cec01510a.tar.xz apk-tools-edb45ae46449ddabcac3dea6b3f42c6cec01510a.zip |
enforce options definitions to bind the enum and the descriptor
This uses some macro trickery to make sure that there's one-to-one
mapping with the option index enum and the descriptor. The down
side is that enum's are generated via #define's and editors might
not pick them up for auto completion, but the benefits are more:
it's no longer possible have mismatching enum value and descriptor
index, and the amount of source code lines is less.
Diffstat (limited to 'src/app_del.c')
-rw-r--r-- | src/app_del.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/app_del.c b/src/app_del.c index 32398b3..aa7ab4f 100644 --- a/src/app_del.c +++ b/src/app_del.c @@ -19,13 +19,10 @@ struct del_ctx { int errors; }; -enum { - OPT_DEL_redepends, -}; +#define DEL_OPTIONS(OPT) \ + OPT(OPT_DEL_redepends, APK_OPT_SH("r") "rdepends") -static const char option_desc[] = - APK_OPTAPPLET - APK_OPT2n("rdepends", "r"); +APK_OPT_APPLET(option_desc, DEL_OPTIONS); static int option_parse_applet(void *pctx, struct apk_db_options *dbopts, int opt, const char *optarg) { |