ptx: contexts stop at line ends without -S, and -S drops the sentence end

オープン
#15,864 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
cli

調査の方向性

Start in src/uu/ptx/src/ptx.rs, especially read_lines around line 327 and the -S handling around line 323. Compare default and -S output with the two examples in the issue, then check the ptx tests for coverage. Done means default mode joins contexts across lines as GNU ptx does, while -S preserves the matched sentence end and does not mark the final sentence as truncated.

索引モデルが issue の本文から書いたものです。

説明

Without -S, GNU ptx (in its default GNU mode) builds contexts from sentences, not lines: a sentence ends at ., ? or ! (optionally followed by closing quotes or brackets) that is followed by an end of line, a tab or two spaces, and lines in between are joined. uutils ptx uses each line on its own:

$ printf 'one two\nthree four\n' > f
$ ptx f
                               three   four
                                       one two
                                       three four
                                 one   two
$ gnuptx f    # GNU coreutils 9.12
                       one two three   four
                                       one two three four
                             one two   three four
                                 one   two three four

-G output matches, as there a line is the unit for both.

Passing a sentence regexp with -S gets closer, but two more differences show up there: the matched sentence end is dropped from the context, and the last sentence ends with a truncation flag because the final newline becomes a trailing space:

$ printf 'Hello world.  Foo bar\n' > g
$ ptx -S '\.  ' g
                                       Foo bar/
                                       Hello world
                                 Foo   bar/
                               Hello   world
$ gnuptx -S '\.  ' g
                                       Foo bar
                                       Hello world.
                                 Foo   bar
                               Hello   world.

The line split is buffer.lines() in read_lines (src/uu/ptx/src/ptx.rs:327); with -S, re.split(&buffer) throws away the matched text and s.replace('\n', " ") (ptx.rs:323) turns the final newline into the trailing space.

uutils coreutils main 91d4f6ada, GNU coreutils 9.12.

主要言語
Rust
スター
24.3k
フォーク
2.1k
平均マージ
2日 6時間
マージ済み PR(30日)
399

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

uutils/coreutils のほかの issue

uutils/coreutils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。