Skip to content

Fix a bug in Prepend handling #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "unicode-segmentation"
version = "1.0.0"
version = "1.0.1"
authors = ["kwantam <kwantam@gmail.com>"]

homepage = "https://github.com/unicode-rs/unicode-segmentation"
Expand Down
14 changes: 5 additions & 9 deletions src/grapheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ impl<'a> Iterator for Graphemes<'a> {
}
break; // rule GB4
}
Start => match cat {
gr::GC_Control => break,
Start | Prepend => match cat {
gr::GC_Control => { // rule GB5
take_curr = state == Start;
break;
}
gr::GC_L => HangulL,
gr::GC_LV | gr::GC_V => HangulLV,
gr::GC_LVT | gr::GC_T => HangulLVT,
Expand Down Expand Up @@ -163,13 +166,6 @@ impl<'a> Iterator for Graphemes<'a> {
break;
}
},
Prepend => match cat { // rule GB9b
gr::GC_Control => {
take_curr = false;
break;
}
_ => continue
},
Regional => match cat { // rule GB12/GB13
gr::GC_Regional_Indicator => FindExtend,
_ => {
Expand Down
5 changes: 5 additions & 0 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ fn test_graphemes() {
("\u{20}\u{600}\u{600}\u{20}",
&["\u{20}", "\u{600}\u{600}\u{20}"],
&["\u{20}", "\u{600}", "\u{600}", "\u{20}"]),

// Test for Prepend followed by two Any chars
("\u{600}\u{20}\u{20}",
&["\u{600}\u{20}", "\u{20}"],
&["\u{600}", "\u{20}", "\u{20}"]),
];

for &(s, g) in TEST_SAME {
Expand Down