use LEN() macros for arrays - stagit-gopher - A git gopher frontend. (mirror)
 (HTM) git clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit ee1e685d9d6391f5eba3c539462c76623d5b50de
 (DIR) parent 12facdbeb1a1c012d16bca8cd8d77b04ee8d10ae
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sun, 15 Nov 2020 21:21:39 +0100
       
       use LEN() macros for arrays
       
       from Augustin Fabre <augustin@augfab.fr>
       
       Diffstat:
         M stagit-gopher.c                     |       6 ++++--
       
       1 file changed, 4 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/stagit-gopher.c b/stagit-gopher.c
       @@ -18,6 +18,8 @@
        
        #include "compat.h"
        
       +#define LEN(s)    (sizeof(s)/sizeof(*s))
       +
        struct deltainfo {
                git_patch *patch;
        
       @@ -1314,7 +1316,7 @@ main(int argc, char *argv[])
                }
        
                /* check LICENSE */
       -        for (i = 0; i < sizeof(licensefiles) / sizeof(*licensefiles) && !license; i++) {
       +        for (i = 0; i < LEN(licensefiles) && !license; i++) {
                        if (!git_revparse_single(&obj, repo, licensefiles[i]) &&
                            git_object_type(obj) == GIT_OBJ_BLOB)
                                license = licensefiles[i] + strlen("HEAD:");
       @@ -1322,7 +1324,7 @@ main(int argc, char *argv[])
                }
        
                /* check README */
       -        for (i = 0; i < sizeof(readmefiles) / sizeof(*readmefiles) && !readme; i++) {
       +        for (i = 0; i < LEN(readmefiles) && !readme; i++) {
                        if (!git_revparse_single(&obj, repo, readmefiles[i]) &&
                            git_object_type(obj) == GIT_OBJ_BLOB)
                                readme = readmefiles[i] + strlen("HEAD:");