Ralf Wildenhues <[EMAIL PROTECTED]> writes:

> -     if (v1 == "") d1 = v1; else { d1 = substr(v1, 1, 1); v1 = substr(v1,2) }
> -     if (v2 == "") d2 = v2; else { d2 = substr(v2, 1, 1); v2 = substr(v2,2) }
> +     if (v1"" == "") d1 = v1; else { d1 = substr(v1, 1, 1); v1 = 
> substr(v1,2) }
> +     if (v2"" == "") d2 = v2; else { d2 = substr(v2, 1, 1); v2 = 
> substr(v2,2) }

That looks fairly safe, but even safer would be to use the length function,
since earlier bits of the code already do that.  I installed this:

2005-08-25  Paul Eggert  <[EMAIL PROTECTED]>

        * lib/m4sugar/m4sh.m4 (_AS_VERSION_COMPARE_PREPARE):
        Work around bug in Solaris 9 (and 10) /usr/xpg4/bin/awk.

--- m4sh.m4     17 Jun 2005 20:37:37 -0000      1.148
+++ m4sh.m4     25 Aug 2005 21:29:54 -0000      1.149
@@ -1074,8 +1074,8 @@ m4_defun([_AS_VERSION_COMPARE_PREPARE],
        }
       } else {
        # The normal case, without worrying about digits.
-       if (v1 == "") d1 = v1; else { d1 = substr(v1, 1, 1); v1 = substr(v1,2) }
-       if (v2 == "") d2 = v2; else { d2 = substr(v2, 1, 1); v2 = substr(v2,2) }
+       if (length(v1)) { d1 = substr(v1, 1, 1); v1 = substr(v1,2) } else d1=v1
+       if (length(v2)) { d2 = substr(v2, 1, 1); v2 = substr(v2,2) } else d2=v2
       }
       if (d1 < d2) exit 1
       if (d1 > d2) exit 2


Reply via email to