libtool-patches
[Top][All Lists]
Advanced

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

[PATCH] Simplify argument parsing in cwrapper.


From: Ralf Wildenhues
Subject: [PATCH] Simplify argument parsing in cwrapper.
Date: Sun, 25 May 2008 23:10:42 +0200
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

* libltdl/config/ltmain.m4sh (func_emit_cwrapperexe_src):
Use NULL where appropriate.  Do not compute length of arguments
needlessly.
---

Let's make this a bit less redundant.  Testsuite is still running
(linux -> mingw cross).  OK to commit if it passes?

Thanks,
Ralf

 libltdl/config/ltmain.m4sh |   29 ++++++++++-------------------
 1 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 888b74b..6679ee3 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2952,7 +2952,7 @@ EOF
   /* DO want the lt- prefix here if it exists, so use target_name */
   lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
   XFREE (tmp_pathspec);
-  tmp_pathspec = 0;
+  tmp_pathspec = NULL;
 EOF
 
            case $host_os in
@@ -2986,19 +2986,16 @@ EOF
   newargc=0;
   for (i = 1; i < argc; i++)
     {
-      size_t arglen = strlen (argv[i]);
       if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
         {
-          if ((arglen > env_set_opt_len) && (argv[i][env_set_opt_len] == '='))
+          if (argv[i][env_set_opt_len] == '=')
             {
               const char *p = argv[i] + env_set_opt_len + 1;
               lt_opt_process_env_set (p);
             }
-          else if ((arglen == env_set_opt_len) &&
-                   (i + 1 < argc))
+          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
             {
-              lt_opt_process_env_set (argv[i + 1]);
-              i++; /* don't copy */
+              lt_opt_process_env_set (argv[++i]); /* don't copy */
             }
           else
             lt_fatal ("%s missing required argument", env_set_opt);
@@ -3006,17 +3003,14 @@ EOF
         }
       if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
         {
-          if ((arglen > env_prepend_opt_len) &&
-              (argv[i][env_prepend_opt_len] == '='))
+          if (argv[i][env_prepend_opt_len] == '=')
             {
               const char *p = argv[i] + env_prepend_opt_len + 1;
               lt_opt_process_env_prepend (p);
             }
-          else if ((arglen == env_prepend_opt_len) &&
-                   (i + 1 < argc))
+          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
             {
-              lt_opt_process_env_prepend (argv[i + 1]);
-              i++; /* don't copy */
+              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
             }
           else
             lt_fatal ("%s missing required argument", env_prepend_opt);
@@ -3024,17 +3018,14 @@ EOF
         }
       if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
         {
-          if ((arglen > env_append_opt_len) &&
-              (argv[i][env_append_opt_len] == '='))
+          if (argv[i][env_append_opt_len] == '=')
             {
               const char *p = argv[i] + env_append_opt_len + 1;
               lt_opt_process_env_append (p);
             }
-          else if ((arglen == env_append_opt_len) &&
-                   (i + 1 < argc))
+          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
             {
-              lt_opt_process_env_append (argv[i + 1]);
-              i++; /* don't copy */
+              lt_opt_process_env_append (argv[++i]); /* don't copy */
             }
           else
             lt_fatal ("%s missing required argument", env_append_opt);
-- 
1.5.5.40.g4cdda




reply via email to

[Prev in Thread] Current Thread [Next in Thread]