ptx: contexts stop at line ends without -S, and -S drops the sentence end
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 74/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 24.3k
- Forks
- 2.1k
- Merge medio
- 1 d 20 h
- PR fusionados (30 d)
- 380
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de uutils/coreutils
-
U - od
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
U - pr
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
U - nl
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
U - uniq
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
U - unexpand
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
Todos los issues de uutils/coreutils
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
hydro-project/hydro#3289 ·
Los mantenedores suelen responder en 1 día
-
diagram-bug good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
enhapu-afk/omaspec#4 ·
-
priority: low ☕️ type: bug 🐛
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
bug security
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 4 días