Use a index loop instead so the loop can end
authorRobert Pengelly <robertapengelly@hotmail.com>
Mon, 21 Apr 2025 09:42:42 +0000 (10:42 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Mon, 21 Apr 2025 09:42:42 +0000 (10:42 +0100)
lib.c

diff --git a/lib.c b/lib.c
index fcb19717ddb0959c5fccf94b6d487ddd9ee8fed7..c6c0717b5d78c2c79db86372af48b4b1259c5040 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -80,7 +80,7 @@ static void print_usage (void) {
 
     if (program_name) {
     
-        struct options_with_use *options_with_use;
+        int emul_count = sizeof (emulation_table) / sizeof (emulation_table[0]), i;
         
         fprintf (stderr, "Usage: %s [options] file...\n\n", program_name);
         fprintf (stderr, "Options:\n\n");
@@ -113,11 +113,11 @@ static void print_usage (void) {
         
         fprintf (stderr, "\n");
         
-        for (options_with_use = emulation_table; ; options_with_use++) {
+        for (i = 0; i < emul_count; i++) {
         
-            if (options_with_use->print_help) {
+            if (emulation_table[i].print_help) {
             
-                options_with_use->print_help ();
+                emulation_table[i].print_help ();
                 fprintf (stderr, "\n");
             
             }