This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository e16-epplets.

View the commit online.

commit 3d94b4f32536762397e2920dc48b591d3aa475ec
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Sat Aug 10 15:28:02 2024 +0200

    E-Slides: Cosmetics
    
    Mostly shuffling some code around to avoid forward declarations.
---
 epplets/E-Slides.c | 185 ++++++++++++++++++++++++++---------------------------
 1 file changed, 89 insertions(+), 96 deletions(-)

diff --git a/epplets/E-Slides.c b/epplets/E-Slides.c
index 04d8025..3e7f963 100644
--- a/epplets/E-Slides.c
+++ b/epplets/E-Slides.c
@@ -30,8 +30,6 @@
 #else
 #define D(x) ((void) 0)
 #endif
-#define BEGMATCH(a, b)  (!strncasecmp((a), (b), (sizeof(b) - 1)))
-#define NONULL(x)       ((x) ? (x) : (""))
 
 #define PREV_PIC()      do {if (idx == 1) idx = image_cnt - 1; else if (idx == 0) idx = image_cnt - 2; else idx -= 2;} while (0)
 #define CUR_PIC()       ((idx == 0) ? (image_cnt - 1) : (idx - 1))
@@ -46,7 +44,7 @@
 static Epplet_gadget close_button, play_button, pause_button, prev_button,
     next_button, cfg_button, cfg_popup, picture;
 static Epplet_gadget cfg_tb_path, cfg_tb_delay, cfg_tb_zoom;
-static unsigned long idx = 0, image_cnt = 0;
+static unsigned int idx = 0, image_cnt = 0;
 static double   delay = 5.0;
 static const char *zoom_cmd;
 static char   **filenames = NULL, *path;
@@ -57,16 +55,52 @@ static int      cfg_auto_setbg = AUTOBG_OFF, cfg_maintain_aspect =
 static Window   config_win = None;
 static int      w = 3, h = 3;
 
-static char   **randomize_file_list(char **names, unsigned long num);
-static char   **sort_file_list(char **names, unsigned long num);
-
 static void     config_cb(void *data);
-static unsigned char get_images(char *image_path);
+
+static void
+randomize_file_list(char **names, unsigned int len)
+{
+    int             r;
+    unsigned int    i;
+    char           *tmp;
+
+    for (i = 0; i < len - 1; i++)
+    {
+        r = (int)((len - i - 1) * ((float)rand()) / (RAND_MAX + 1.0)) + i + 1;
+        tmp = names[i];
+        names[i] = names[r];
+        names[r] = tmp;
+    }
+}
+
+static void
+sort_file_list(char **names, unsigned int len)
+{
+    unsigned int    i;
+    unsigned char   done = 0;
+
+    while (!done)
+    {
+        done = 1;
+        for (i = 0; i < len - 1; i++)
+        {
+            if (strcmp(names[i], names[i + 1]) > 0)
+            {
+                char           *tmp;
+
+                tmp = names[i];
+                names[i] = names[i + 1];
+                names[i + 1] = tmp;
+                done = 0;
+            }
+        }
+    }
+}
 
 static char   **
-dirscan(char *dir, unsigned long *num)
+dirscan(char *dir, unsigned int *num)
 {
-    unsigned long   i, dirlen;
+    unsigned int    i, dirlen;
     DIR            *dirp;
     char          **names;
     struct dirent  *dp;
@@ -78,13 +112,13 @@ dirscan(char *dir, unsigned long *num)
     if ((!dir) || (!*dir))
     {
         *num = 0;
-        return ((char **)NULL);
+        return NULL;
     }
     dirp = opendir(dir);
     if (!dirp)
     {
         *num = 0;
-        return ((char **)NULL);
+        return NULL;
     }
     /* count # of entries in dir (worst case) */
     for (dirlen = 0; (dp = readdir(dirp)); dirlen++);
@@ -93,7 +127,7 @@ dirscan(char *dir, unsigned long *num)
     {
         closedir(dirp);
         *num = 0;
-        return ((char **)NULL);
+        return NULL;
     }
     names = malloc(dirlen * sizeof(char *));
     D((" -> Storing names at %8p.\n", names));
@@ -101,7 +135,7 @@ dirscan(char *dir, unsigned long *num)
     if (!names)
     {
         *num = 0;
-        return ((char **)NULL);
+        return NULL;
     }
     rewinddir(dirp);
     for (i = 0; (dp = readdir(dirp));)
@@ -112,8 +146,7 @@ dirscan(char *dir, unsigned long *num)
             D((" -> About to stat() %s\n", fullname));
             if (stat(fullname, &filestat))
             {
-                D((" -> Couldn't stat() file %s -- %s\n", dp->d_name,
-                   strerror(errno)));
+                D((" -> Couldn't stat() file %s -- %m\n", dp->d_name));
             }
             else
             {
@@ -140,12 +173,12 @@ dirscan(char *dir, unsigned long *num)
     {
         closedir(dirp);
         *num = 0;
-        return ((char **)NULL);
+        return NULL;
     }
     closedir(dirp);
     *num = dirlen;
     names = realloc(names, dirlen * sizeof(char *));
-    D((" -> Final directory length is %lu.  List moved to %8p\n", *num, names));
+    D((" -> Final directory length is %u. List moved to %8p\n", *num, names));
 
     if (randomize)
     {
@@ -155,49 +188,7 @@ dirscan(char *dir, unsigned long *num)
     {
         sort_file_list(names, dirlen);
     }
-    return (names);
-}
-
-static char   **
-randomize_file_list(char **names, unsigned long len)
-{
-    int             r;
-    unsigned long   i;
-    char           *tmp;
-
-    for (i = 0; i < len - 1; i++)
-    {
-        r = (int)((len - i - 1) * ((float)rand()) / (RAND_MAX + 1.0)) + i + 1;
-        tmp = names[i];
-        names[i] = names[r];
-        names[r] = tmp;
-    }
-    return (names);
-}
-
-static char   **
-sort_file_list(char **names, unsigned long len)
-{
-    unsigned long   i;
-    unsigned char   done = 0;
-
-    while (!done)
-    {
-        done = 1;
-        for (i = 0; i < len - 1; i++)
-        {
-            if (strcmp(names[i], names[i + 1]) > 0)
-            {
-                char           *tmp;
-
-                tmp = names[i];
-                names[i] = names[i + 1];
-                names[i + 1] = tmp;
-                done = 0;
-            }
-        }
-    }
-    return (names);
+    return names;
 }
 
 static void
@@ -233,9 +224,9 @@ static void
 change_image(void *data __UNUSED__)
 {
     Imlib_Image    *im = NULL;
-    double          ratio = 0.0;
-    unsigned long   first = idx;
-    int             new_w = 0, new_h = 0, new_x = 3, new_y = 3;
+    double          ratio;
+    unsigned int    first = idx;
+    int             new_w, new_h, new_x, new_y;
 
     if (!filenames)
         return;
@@ -257,6 +248,7 @@ change_image(void *data __UNUSED__)
             return;
         }
     }
+
     new_w = (w * 16 - 6);
     new_h = (h * 16 - 6);
     imlib_context_set_image(im);
@@ -280,6 +272,7 @@ change_image(void *data __UNUSED__)
     new_y = ((h * 16) / 2) - (new_h / 2);
     Epplet_move_change_image(picture, new_x, new_y, new_w, new_h,
                              filenames[idx]);
+
     INC_PIC();
     switch (auto_setbg)
     {
@@ -422,6 +415,38 @@ delete_cb(void *data __UNUSED__, Window win __UNUSED__)
     return 1;
 }
 
+static int
+get_images(char *image_path)
+{
+    char          **temp;
+    unsigned int    cnt;
+
+    temp = dirscan(image_path, &cnt);
+    if (cnt == 0)
+    {
+        Epplet_dialog_ok("Unable to find any files in %s!", image_path);
+        Esync();
+        return 0;
+    }
+    else if (idx >= cnt)
+    {
+        idx = 0;
+    }
+    chdir(image_path);
+
+    if (filenames)
+    {
+        unsigned int    i;
+
+        for (i = 0; i < image_cnt; i++)
+            free(filenames[i]);
+        free(filenames);
+    }
+    image_cnt = cnt;
+    filenames = temp;
+    return 1;
+}
+
 static void
 apply_config(void)
 {
@@ -633,42 +658,10 @@ parse_config(void)
     randomize = atoi(Epplet_query_config_def("randomize", "0"));
 }
 
-static unsigned char
-get_images(char *image_path)
-{
-    char          **temp;
-    unsigned long   cnt;
-
-    temp = dirscan(image_path, &cnt);
-    if (cnt == 0)
-    {
-        Epplet_dialog_ok("Unable to find any files in %s!", image_path);
-        Esync();
-        return 0;
-    }
-    else if (idx >= cnt)
-    {
-        idx = 0;
-    }
-    chdir(image_path);
-
-    if (filenames)
-    {
-        unsigned int    i;
-
-        for (i = 0; i < image_cnt; i++)
-            free(filenames[i]);
-        free(filenames);
-    }
-    image_cnt = cnt;
-    filenames = temp;
-    return 1;
-}
-
 int
 main(int argc, char **argv)
 {
-    int             j = 0;
+    int             j;
 
     Epplet_adjust_priority(10);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to