@@ -89,27 +89,27 @@ impl FromStr for MapsEntry {
89
89
// Note that paths may contain spaces, so we can't use `str::split` for parsing (until
90
90
// Split::remainder is stabalized #77998).
91
91
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
92
- let ( range_str, s) = s. trim ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
92
+ let ( range_str, s) = s. trim_start ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
93
93
if range_str. is_empty ( ) {
94
94
return Err ( "Couldn't find address" ) ;
95
95
}
96
96
97
- let ( perms_str, s) = s. trim ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
97
+ let ( perms_str, s) = s. trim_start ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
98
98
if perms_str. is_empty ( ) {
99
99
return Err ( "Couldn't find permissions" ) ;
100
100
}
101
101
102
- let ( offset_str, s) = s. trim ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
102
+ let ( offset_str, s) = s. trim_start ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
103
103
if offset_str. is_empty ( ) {
104
104
return Err ( "Couldn't find offset" ) ;
105
105
}
106
106
107
- let ( dev_str, s) = s. trim ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
107
+ let ( dev_str, s) = s. trim_start ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
108
108
if dev_str. is_empty ( ) {
109
109
return Err ( "Couldn't find dev" ) ;
110
110
}
111
111
112
- let ( inode_str, s) = s. trim ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
112
+ let ( inode_str, s) = s. trim_start ( ) . split_once ( ' ' ) . unwrap_or ( ( s, "" ) ) ;
113
113
if inode_str. is_empty ( ) {
114
114
return Err ( "Couldn't find inode" ) ;
115
115
}
@@ -278,4 +278,18 @@ fn check_maps_entry_parsing_32bit() {
278
278
pathname: "/executable/path/with multiple-continues spaces" . into( ) ,
279
279
}
280
280
) ;
281
+ assert_eq ! (
282
+ " b7c79000-b7e02000 r--p 00000000 08:01 60662705 \
283
+ /executable/path/starts-with-spaces"
284
+ . parse:: <MapsEntry >( )
285
+ . unwrap( ) ,
286
+ MapsEntry {
287
+ address: ( 0xb7c79000 , 0xb7e02000 ) ,
288
+ perms: [ 'r' , '-' , '-' , 'p' ] ,
289
+ offset: 0x00000000 ,
290
+ dev: ( 0x08 , 0x01 ) ,
291
+ inode: 0x60662705 ,
292
+ pathname: "/executable/path/starts-with-spaces" . into( ) ,
293
+ }
294
+ ) ;
281
295
}
0 commit comments