Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Test failure with negative substring offsets



Does this make it work? (and if so, why? :)

---
 Src/subst.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Src/subst.c b/Src/subst.c
index 5628c11..e4cd061 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2888,9 +2888,9 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
                    if (offset_hack_argzero)
                        alen++;
                    if (length_set) {
-                       if (length < 0)
+                       if (length < (zlong)0)
                            length += alen - offset;
-                       if (length < 0) {
+                       if (length < (zlong)0) {
                            zerr("substring expression: %d < %d",
                                 length + offset, offset);
                            return NULL;
@@ -2927,20 +2927,20 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
                    }
                    given_offset = offset;
                    MB_METACHARINIT();
-                   if (length_set && length < 0)
+                   if (length_set && length < (zlong)0)
                        length -= offset;
                    for (sptr = val; *sptr && offset; ) {
                        sptr += MB_METACHARLEN(sptr);
                        offset--;
                    }
                    if (length_set) {
-                       if (length < 0) {
+                       if (length < (zlong)0) {
                            MB_METACHARINIT();
                            for (eptr = val; *eptr; ) {
                                eptr += MB_METACHARLEN(eptr);
                                length++;
                            }
-                           if (length < 0) {
+                           if (length < (zlong)0) {
                                zerr("substring expression: %d < %d",
                                     length + given_offset, given_offset);
                                return NULL;

--



Messages sorted by: Reverse Date, Date, Thread, Author