mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
fix(ptx): Remove truncation characters from TeX output
The GNU `ptx` implementation does not display truncation markers (e.g., "/") when using the TeX (`--format=tex`) output format. This change updates the `format_tex_line` function to prevent truncation markers from being included in the TeX output, aligning uutils' behavior with GNU's.
This commit is contained in:
parent
9064619efd
commit
bdd8939d1b
1 changed files with 16 additions and 13 deletions
|
|
@ -6,6 +6,7 @@
|
|||
// spell-checker:ignore (ToDOs) corasick memchr Roff trunc oset iset CHARCLASS
|
||||
|
||||
use std::cmp;
|
||||
use std::cmp::PartialEq;
|
||||
use std::collections::{BTreeSet, HashMap, HashSet};
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fmt::Write as FmtWrite;
|
||||
|
|
@ -22,7 +23,7 @@ use uucore::error::{FromIo, UError, UResult, UUsageError};
|
|||
use uucore::format_usage;
|
||||
use uucore::translate;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum OutFormat {
|
||||
Dumb,
|
||||
Roff,
|
||||
|
|
@ -511,19 +512,21 @@ fn get_output_chunks(
|
|||
// and get the string.
|
||||
let head_str: String = all_before[head_beg..head_end].iter().collect();
|
||||
head.push_str(&head_str);
|
||||
//The TeX mode does not output truncation characters.
|
||||
if config.format != OutFormat::Tex {
|
||||
// put right context truncation string if needed
|
||||
if after_end != all_after.len() && tail_beg == tail_end {
|
||||
after.push_str(&config.trunc_str);
|
||||
} else if after_end != all_after.len() && tail_end != all_after.len() {
|
||||
tail.push_str(&config.trunc_str);
|
||||
}
|
||||
|
||||
// put right context truncation string if needed
|
||||
if after_end != all_after.len() && tail_beg == tail_end {
|
||||
after.push_str(&config.trunc_str);
|
||||
} else if after_end != all_after.len() && tail_end != all_after.len() {
|
||||
tail.push_str(&config.trunc_str);
|
||||
}
|
||||
|
||||
// put left context truncation string if needed
|
||||
if before_beg != 0 && head_beg == head_end {
|
||||
before = format!("{}{before}", config.trunc_str);
|
||||
} else if before_beg != 0 && head_beg != 0 {
|
||||
head = format!("{}{head}", config.trunc_str);
|
||||
// put left context truncation string if needed
|
||||
if before_beg != 0 && head_beg == head_end {
|
||||
before = format!("{}{before}", config.trunc_str);
|
||||
} else if before_beg != 0 && head_beg != 0 {
|
||||
head = format!("{}{head}", config.trunc_str);
|
||||
}
|
||||
}
|
||||
|
||||
(tail, before, after, head)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue