@@ -89,13 +89,12 @@ pub fn test_getpwuid_r_2() {
8989 let mut __off: usize = 0 ;
9090 for __s in & __strs {
9191 __ptrs. push( __buf. offset( __off) ) ;
92- let mut __dst = __buf. offset( __off) ;
93- for __b in __s. iter( ) {
94- __dst. write( * __b) ;
95- __dst += 1 ;
96- }
97- __dst. write( 0 ) ;
98- __off += __s. len( ) + 1 ;
92+ let __end = __s. len( ) ;
93+ __buf. offset( __off) . with_slice_mut( __end + 1 , |__sl| {
94+ __sl[ ..__end] . copy_from_slice( __s) ;
95+ __sl[ __end] = 0 ;
96+ } ) ;
97+ __off += __end + 1 ;
9998 }
10099 __pwbuf. with_mut( |__pw| * __pw = Passwd :: from_user_in( & __u, & __ptrs) ) ;
101100 __out. write( __pwbuf. clone( ) ) ;
@@ -170,6 +169,7 @@ pub fn test_getpwuid_r_erange_3() {
170169 ) ) ;
171170 let result: Value < Ptr < libcc2rs:: Passwd > > =
172171 Rc :: new ( RefCell :: new ( Ptr :: < libcc2rs:: Passwd > :: null ( ) ) ) ;
172+ libcc2rs:: cpp2rust_errno ( ) . write ( 0 ) ;
173173 assert ! (
174174 ( ( ( {
175175 let __pwbuf = ( pw. as_pointer( ) ) . clone( ) ;
@@ -197,13 +197,12 @@ pub fn test_getpwuid_r_erange_3() {
197197 let mut __off: usize = 0 ;
198198 for __s in & __strs {
199199 __ptrs. push( __buf. offset( __off) ) ;
200- let mut __dst = __buf. offset( __off) ;
201- for __b in __s. iter( ) {
202- __dst. write( * __b) ;
203- __dst += 1 ;
204- }
205- __dst. write( 0 ) ;
206- __off += __s. len( ) + 1 ;
200+ let __end = __s. len( ) ;
201+ __buf. offset( __off) . with_slice_mut( __end + 1 , |__sl| {
202+ __sl[ ..__end] . copy_from_slice( __s) ;
203+ __sl[ __end] = 0 ;
204+ } ) ;
205+ __off += __end + 1 ;
207206 }
208207 __pwbuf. with_mut( |__pw| * __pw = Passwd :: from_user_in( & __u, & __ptrs) ) ;
209208 __out. write( __pwbuf. clone( ) ) ;
@@ -224,6 +223,7 @@ pub fn test_getpwuid_r_erange_3() {
224223 != 0 )
225224 ) ;
226225 assert ! ( ( ( ( ( * result. borrow( ) ) . is_null( ) ) as i32 ) != 0 ) ) ;
226+ assert ! ( ( ( ( ( libcc2rs:: cpp2rust_errno( ) . read( ) ) == 34 ) as i32 ) != 0 ) ) ;
227227}
228228pub fn main ( ) {
229229 std:: process:: exit ( main_0 ( ) ) ;
0 commit comments