[glib: 1/2] goption.c: Simplfy parse_short_option()




commit b21766ec3c5daa584762e822abd229a312907f3a
Author: Avinash Sonawane <rootkea gmail com>
Date:   Fri Mar 19 14:08:27 2021 +0530

    goption.c: Simplfy parse_short_option()

 glib/goption.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
---
diff --git a/glib/goption.c b/glib/goption.c
index a351f84cb..c974598c8 100644
--- a/glib/goption.c
+++ b/glib/goption.c
@@ -1543,23 +1543,14 @@ parse_short_option (GOptionContext *context,
 
               if (idx < *argc - 1)
                 {
-                  if (!OPTIONAL_ARG (&group->entries[j]))
+                  if (OPTIONAL_ARG (&group->entries[j]) && ((*argv)[idx + 1][0] == '-'))
+                    value = NULL;
+                  else
                     {
                       value = (*argv)[idx + 1];
                       add_pending_null (context, &((*argv)[idx + 1]), NULL);
                       *new_idx = idx + 1;
                     }
-                  else
-                    {
-                      if ((*argv)[idx + 1][0] == '-')
-                        value = NULL;
-                      else
-                        {
-                          value = (*argv)[idx + 1];
-                          add_pending_null (context, &((*argv)[idx + 1]), NULL);
-                          *new_idx = idx + 1;
-                        }
-                    }
                 }
               else if (idx >= *argc - 1 && OPTIONAL_ARG (&group->entries[j]))
                 value = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]