Skip to content

Commit ae63a3e

Browse files
committed
Make getopts count (and thus align/paginate) in terms of codepoints not bytes.
1 parent db55cd9 commit ae63a3e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libextra/getopts.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ pub enum FailType {
501501
pub mod groups {
502502
use getopts::{HasArg, Long, Maybe, Multi, No, Occur, Opt, Optional, Req};
503503
use getopts::{Short, Yes};
504+
use std::str;
504505

505506
/** one group of options, e.g., both -h and --help, along with
506507
* their shared description and properties
@@ -691,7 +692,7 @@ pub mod groups {
691692

692693
// FIXME: #5516
693694
// here we just need to indent the start of the description
694-
let rowlen = row.len();
695+
let rowlen = str::count_chars(row, 0, row.len());
695696
if rowlen < 24 {
696697
do (24 - rowlen).times {
697698
row.push_char(' ')
@@ -798,7 +799,7 @@ pub mod groups {
798799
cont
799800
};
800801

801-
ss.iter().enumerate().advance(|x| machine(x));
802+
ss.char_offset_iter().advance(|x| machine(x));
802803

803804
// Let the automaton 'run out' by supplying trailing whitespace
804805
while cont && match state { B | C => true, A => false } {

0 commit comments

Comments
 (0)