Welcome to little lamb

Code » limb » commit 17f15c3

parseopt: Remove unused PARSEOPT_IS_LONG

author Olivier Brunel
2023-07-23 17:24:40 UTC
committer Olivier Brunel
2023-07-24 10:16:43 UTC
parent 71c70282bffa02b40390b2ae150d08c1163aa743

parseopt: Remove unused PARSEOPT_IS_LONG

src/doc/parseopt.h/parseopt.3.md +0 -4
src/doc/parseopt.h/parseopt.h.0.md +1 -1
src/liblimb/include/limb/parseopt.h +2 -5
src/liblimb/parseopt.h/parseopt.c +20 -26

diff --git a/src/doc/parseopt.h/parseopt.3.md b/src/doc/parseopt.h/parseopt.3.md
index 56db5e6..dda3ffd 100644
--- a/src/doc/parseopt.h/parseopt.3.md
+++ b/src/doc/parseopt.h/parseopt.3.md
@@ -137,10 +137,6 @@ constructed as a bitwise-inclusive OR of flags from the following list :
 : *PARSEOPT_SILENT*
 :: Do not emit any warnings in case of errors.
 
-: *PARSEOPT_IS_LONG*
-:: /Intended for internal use./ Assumes all elements of `argv` are option
-:: elements, composed of long option names directly (i.e. without "--" prefix).
-
 
 # RETURN VALUE
 
diff --git a/src/doc/parseopt.h/parseopt.h.0.md b/src/doc/parseopt.h/parseopt.h.0.md
index 696d6c7..4c0a90e 100644
--- a/src/doc/parseopt.h/parseopt.h.0.md
+++ b/src/doc/parseopt.h/parseopt.h.0.md
@@ -34,7 +34,7 @@ The following constants are defined :
 : *OPTID_SHORTOPT*
 :: Special ID for an option, meaning to return its `shortopt` instead.
 
-: *PARSEOPT_IS_LONG*, *PARSEOPT_STRICT*, *PARSEOPT_SILENT*
+: *PARSEOPT_STRICT*, *PARSEOPT_SILENT*
 :: Flags that can be passed to [parseopt](3).
 
 ## Structures
diff --git a/src/liblimb/include/limb/parseopt.h b/src/liblimb/include/limb/parseopt.h
index 405a63a..80b793e 100644
--- a/src/liblimb/include/limb/parseopt.h
+++ b/src/liblimb/include/limb/parseopt.h
@@ -36,11 +36,8 @@ struct option {
 };
 
 enum {
-    /* private */
-    PARSEOPT_IS_LONG    = 1 << 0,
-    /* public */
-    PARSEOPT_STRICT     = 1 << 1,
-    PARSEOPT_SILENT     = 1 << 2,
+    PARSEOPT_STRICT     = 1 << 0,
+    PARSEOPT_SILENT     = 1 << 1,
 };
 
 /* opaque structure -- use macros below to access its public members */
diff --git a/src/liblimb/parseopt.h/parseopt.c b/src/liblimb/parseopt.h/parseopt.c
index 4a04b34..a891c6e 100644
--- a/src/liblimb/parseopt.h/parseopt.c
+++ b/src/liblimb/parseopt.h/parseopt.c
@@ -24,34 +24,28 @@ again:
 
     arg = argv[ctx->cur] + ctx->off;
 
-    if (flags & PARSEOPT_IS_LONG) {
-        is_long = arg_long = 1;
-        if (!*arg)
-            return (errno = EINVAL, -1);
-    } else {
-        if (ctx->off == 0) {
-            if (*arg != '-')
-                /* not an option, so no more options */
-                return 0;
-            /* move on to the option */
-            ++ctx->off;
-            ++arg;
-        }
+    if (ctx->off == 0) {
+        if (*arg != '-')
+            /* not an option, so no more options */
+            return 0;
+        /* move on to the option */
+        ++ctx->off;
+        ++arg;
+    }
 
-        if (!*arg) {
-            if (ctx->off == 1)
-                return (errno = EINVAL, -1);
-            /* next argument */
-            ++ctx->cur;
-            ctx->off = 0;
-            goto again;
-        }
+    if (!*arg) {
+        if (ctx->off == 1)
+            return (errno = EINVAL, -1);
+        /* next argument */
+        ++ctx->cur;
+        ctx->off = 0;
+        goto again;
+    }
 
-        is_long = arg_long = (ctx->off == 1 && *arg == '-');
-        if (is_long) {
-            ++ctx->off;
-            ++arg;
-        }
+    is_long = arg_long = (ctx->off == 1 && *arg == '-');
+    if (is_long) {
+        ++ctx->off;
+        ++arg;
     }
 
     if (is_long) {