File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed
Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1818### Fixed
1919* Relaxed assertions on ` Encoding::Struct ` /` Encoding::Union ` 's name to allow
2020 unicode identifiers.
21+ * Strip more modifiers to allow encoding parsing to work on macOS 10.7.
2122
2223
2324## [ 4.1.0] - 2025-01-22
Original file line number Diff line number Diff line change @@ -254,8 +254,6 @@ impl Encoding {
254254 pub fn equivalent_to_str ( & self , s : & str ) -> bool {
255255 let mut parser = Parser :: new ( s) ;
256256
257- parser. strip_leading_qualifiers ( ) ;
258-
259257 if let Some ( ( ) ) = parser. expect_encoding ( self , NestingLevel :: new ( ) ) {
260258 // if the given encoding can be successfully removed from the
261259 // start and an empty string remains, they were fully equivalent!
@@ -784,6 +782,17 @@ mod tests {
784782 !" * c";
785783 !" ^^c";
786784 }
785+
786+ // Regression test for https://github.com/madsmtm/objc2/issues/834.
787+ fn modifiers_behind_pointers() {
788+ Encoding::Pointer(&Encoding::Object);
789+ " ^@";
790+ ~" ^r@";
791+ ~" rrr^rrrr@";
792+ !" ^^r@";
793+ !" r@";
794+ !" ^@r"; // Unsure?
795+ }
787796 }
788797
789798 #[test]
Original file line number Diff line number Diff line change @@ -124,8 +124,6 @@ impl EncodingBox {
124124 /// Returns an error if the string was an ill-formatted encoding string.
125125 pub fn from_start_of_str ( s : & mut & str ) -> Result < Self , ParseError > {
126126 let mut parser = Parser :: new ( s) ;
127- parser. strip_leading_qualifiers ( ) ;
128-
129127 match parser. parse_encoding_or_none ( ) {
130128 Err ( ErrorKind :: Unknown ( b'0' ..=b'9' ) ) => {
131129 let remaining = parser. remaining ( ) ;
@@ -168,8 +166,6 @@ impl FromStr for EncodingBox {
168166
169167 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
170168 let mut parser = Parser :: new ( s) ;
171- parser. strip_leading_qualifiers ( ) ;
172-
173169 parser
174170 . parse_encoding_or_none ( )
175171 . and_then ( |enc| parser. expect_empty ( ) . map ( |( ) | enc) )
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ impl<'a> Parser<'a> {
181181
182182impl Parser < ' _ > {
183183 /// Strip leading qualifiers, if any.
184- pub ( crate ) fn strip_leading_qualifiers ( & mut self ) {
184+ fn strip_leading_qualifiers ( & mut self ) {
185185 // TODO: Add API for accessing and outputting qualifiers.
186186 #[ allow( clippy:: byte_char_slices) ]
187187 const QUALIFIERS : & [ u8 ] = & [
@@ -270,6 +270,8 @@ impl Parser<'_> {
270270 }
271271
272272 pub ( crate ) fn expect_encoding ( & mut self , enc : & Encoding , level : NestingLevel ) -> Option < ( ) > {
273+ self . strip_leading_qualifiers ( ) ;
274+
273275 match enc. helper ( ) {
274276 Helper :: Primitive ( primitive) => {
275277 match primitive {
@@ -426,6 +428,8 @@ impl Parser<'_> {
426428 }
427429
428430 fn parse_inner ( & mut self ) -> Result < ParseInner > {
431+ self . strip_leading_qualifiers ( ) ;
432+
429433 if self . is_empty ( ) {
430434 return Ok ( ParseInner :: Empty ) ;
431435 }
You can’t perform that action at this time.
0 commit comments