From 35f29adb96c082cd94ec0c72c62556b4fde1e05c Mon Sep 17 00:00:00 2001
From: wangmengc <wangmengc@uniontech.com>
Date: Fri, 13 Dec 2024 17:15:50 +0800
Subject: [PATCH] fix echo {a..z}

---
 r_braces/src/lib.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/r_braces/src/lib.rs b/r_braces/src/lib.rs
index ee83ac1..d36ff1f 100644
--- a/r_braces/src/lib.rs
+++ b/r_braces/src/lib.rs
@@ -378,7 +378,7 @@ pub unsafe extern "C" fn brace_expand(
     loop  {
         if *amble.offset(j as isize) as libc::c_int == 0 as libc::c_int  {
             tack = expand_seqterm (amble, alen);
-            if tack.is_null() {
+            if !tack.is_null() {
                 break;
             }
             else if !text.offset((i+1) as isize).is_null() {
@@ -692,7 +692,9 @@ unsafe extern "C" fn expand_seqterm(
     lhs = substring(text, 0 as libc::c_int, lhs_l);
     rhs = substring(
         text,
-        (lhs_l + std::mem::size_of::<[libc::c_char; 3]> as libc::c_int - 1 as libc::c_int ),
+        (lhs_l as libc::c_ulong)
+                .wrapping_add(::std::mem::size_of::<[libc::c_char; 3]>() as libc::c_ulong)
+               .wrapping_sub(1 as libc::c_int as libc::c_ulong) as libc::c_int,
         tlen as libc::c_int,
     );    
     if *lhs.offset(0 as libc::c_int as isize) as libc::c_int == 0 as libc::c_int
-- 
2.39.3

