From 46caba5943149b1302b3ff3c6706e85c1927f01f Mon Sep 17 00:00:00 2001 From: wjf-hs Date: Wed, 30 Apr 2025 14:08:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E6=98=AF=E4=B8=8D=E5=AF=B9=EF=BC=8C?= =?UTF-8?q?=E8=BF=99=E4=B9=88=E5=A4=84=E7=90=86=E6=84=9F=E8=A7=89=E5=A5=BD?= =?UTF-8?q?=E5=A4=8D=E6=9D=82=E5=95=8A=EF=BC=8C=E6=98=AF=E4=B8=8D=E6=98=AF?= =?UTF-8?q?=E6=88=91=E5=85=A8=E9=83=A8=E4=BF=AE=E6=94=B9=E4=B8=BA=E9=97=AD?= =?UTF-8?q?=E5=8C=BA=E9=97=B4=E5=AE=B9=E6=98=93=E5=A4=84=E7=90=86=E4=B8=80?= =?UTF-8?q?=E7=82=B9=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/list.c | 90 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/src/list.c b/src/list.c index 9524eff..55415a8 100644 --- a/src/list.c +++ b/src/list.c @@ -347,11 +347,61 @@ done: bool contain_last_obj = false; int temp = 0; bool negative = false; + + int start0 = start; + int end0 = end; if (step == 0) { return NULL; } + if(start0 == LIST_UNLIMITED) + { + start = 0 - (int)LIST_UNLIMITED; + } + + if(end0 == LIST_UNLIMITED) + { + end = (int)LIST_UNLIMITED; + } + + if(start < 0) + { + start += (int)self->size(self); + if(start < 0) + { + start = 0; + } + } + else + { + if(start >= (int)self->size(self)) + { + empty = true; + } + } + + if(end < 0) + { + end += (int)self->size(self); + if(end < 0) + { + empty = true; + } + } + else + { + if (end >= (int)self->size(self)) + { + end = (int)self->size(self); + } + + if(step < 0) + { + contain_last_obj = true; + } + } + if(step < 0) { negative = true; @@ -375,45 +425,7 @@ done: { end = temp; } - } - - if(start < 0) - { - start += (int)self->size(self); - if(start < 0) - { - start = 0; - } - } - else - { - if(start == LIST_UNLIMITED) - { - start = 0; - contain_last_obj = true; - } - - if(start >= (int)self->size(self)) - { - empty = true; - } - } - - if(end < 0) - { - end += (int)self->size(self); - if(end < 0) - { - empty = true; - } - } - else - { - if (end == LIST_UNLIMITED || end >= (int)self->size(self)) - { - end = (int)self->size(self) - 1; - contain_last_obj = true; - } + end = temp; } if(start >= end)