@@ -89,27 +89,27 @@ impl FromStr for MapsEntry {
8989 // Note that paths may contain spaces, so we can't use `str::split` for parsing (until
9090 // Split::remainder is stabalized #77998).
9191 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, "" ) ) ;
9393 if range_str. is_empty ( ) {
9494 return Err ( "Couldn't find address" ) ;
9595 }
9696
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, "" ) ) ;
9898 if perms_str. is_empty ( ) {
9999 return Err ( "Couldn't find permissions" ) ;
100100 }
101101
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, "" ) ) ;
103103 if offset_str. is_empty ( ) {
104104 return Err ( "Couldn't find offset" ) ;
105105 }
106106
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, "" ) ) ;
108108 if dev_str. is_empty ( ) {
109109 return Err ( "Couldn't find dev" ) ;
110110 }
111111
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, "" ) ) ;
113113 if inode_str. is_empty ( ) {
114114 return Err ( "Couldn't find inode" ) ;
115115 }
@@ -278,4 +278,18 @@ fn check_maps_entry_parsing_32bit() {
278278 pathname: "/executable/path/with multiple-continues spaces" . into( ) ,
279279 }
280280 ) ;
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+ ) ;
281295}
0 commit comments