Skip to content

Commit

Permalink
Merge pull request #4777 from Joining7943/tail-change-text-static-to-…
Browse files Browse the repository at this point in the history
…const

'tail': Change static global variables to const
  • Loading branch information
cakebaker committed May 3, 2023
2 parents 90e0d30 + c6f6c87 commit 82eb04c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 39 deletions.
37 changes: 18 additions & 19 deletions src/uu/tail/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ const USAGE: &str = help_usage!("tail.md");

pub mod options {
pub mod verbosity {
pub static QUIET: &str = "quiet";
pub static VERBOSE: &str = "verbose";
pub const QUIET: &str = "quiet";
pub const VERBOSE: &str = "verbose";
}
pub static BYTES: &str = "bytes";
pub static FOLLOW: &str = "follow";
pub static LINES: &str = "lines";
pub static PID: &str = "pid";
pub static SLEEP_INT: &str = "sleep-interval";
pub static ZERO_TERM: &str = "zero-terminated";
pub static DISABLE_INOTIFY_TERM: &str = "-disable-inotify"; // NOTE: three hyphens is correct
pub static USE_POLLING: &str = "use-polling";
pub static RETRY: &str = "retry";
pub static FOLLOW_RETRY: &str = "F";
pub static MAX_UNCHANGED_STATS: &str = "max-unchanged-stats";
pub static ARG_FILES: &str = "files";
pub static PRESUME_INPUT_PIPE: &str = "-presume-input-pipe"; // NOTE: three hyphens is correct
pub const BYTES: &str = "bytes";
pub const FOLLOW: &str = "follow";
pub const LINES: &str = "lines";
pub const PID: &str = "pid";
pub const SLEEP_INT: &str = "sleep-interval";
pub const ZERO_TERM: &str = "zero-terminated";
pub const DISABLE_INOTIFY_TERM: &str = "-disable-inotify"; // NOTE: three hyphens is correct
pub const USE_POLLING: &str = "use-polling";
pub const RETRY: &str = "retry";
pub const FOLLOW_RETRY: &str = "F";
pub const MAX_UNCHANGED_STATS: &str = "max-unchanged-stats";
pub const ARG_FILES: &str = "files";
pub const PRESUME_INPUT_PIPE: &str = "-presume-input-pipe"; // NOTE: three hyphens is correct
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -470,12 +470,11 @@ pub fn parse_args(args: impl uucore::Args) -> UResult<Settings> {

pub fn uu_app() -> Command {
#[cfg(target_os = "linux")]
pub static POLLING_HELP: &str = "Disable 'inotify' support and use polling instead";
const POLLING_HELP: &str = "Disable 'inotify' support and use polling instead";
#[cfg(all(unix, not(target_os = "linux")))]
pub static POLLING_HELP: &str = "Disable 'kqueue' support and use polling instead";
const POLLING_HELP: &str = "Disable 'kqueue' support and use polling instead";
#[cfg(target_os = "windows")]
pub static POLLING_HELP: &str =
"Disable 'ReadDirectoryChanges' support and use polling instead";
const POLLING_HELP: &str = "Disable 'ReadDirectoryChanges' support and use polling instead";

Command::new(uucore::util_name())
.version(crate_version!())
Expand Down
28 changes: 14 additions & 14 deletions src/uu/tail/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@

// spell-checker:ignore (ToDO) kqueue

pub static DASH: &str = "-";
pub static DEV_STDIN: &str = "/dev/stdin";
pub static STDIN_HEADER: &str = "standard input";
pub static NO_FILES_REMAINING: &str = "no files remaining";
pub static NO_SUCH_FILE: &str = "No such file or directory";
pub static BECOME_INACCESSIBLE: &str = "has become inaccessible";
pub static BAD_FD: &str = "Bad file descriptor";
pub const DASH: &str = "-";
pub const DEV_STDIN: &str = "/dev/stdin";
pub const STDIN_HEADER: &str = "standard input";
pub const NO_FILES_REMAINING: &str = "no files remaining";
pub const NO_SUCH_FILE: &str = "No such file or directory";
pub const BECOME_INACCESSIBLE: &str = "has become inaccessible";
pub const BAD_FD: &str = "Bad file descriptor";
#[cfg(target_os = "linux")]
pub static BACKEND: &str = "inotify";
pub const BACKEND: &str = "inotify";
#[cfg(all(unix, not(target_os = "linux")))]
pub static BACKEND: &str = "kqueue";
pub const BACKEND: &str = "kqueue";
#[cfg(target_os = "windows")]
pub static BACKEND: &str = "ReadDirectoryChanges";
pub static FD0: &str = "/dev/fd/0";
pub static IS_A_DIRECTORY: &str = "Is a directory";
pub static DEV_TTY: &str = "/dev/tty";
pub static DEV_PTMX: &str = "/dev/ptmx";
pub const BACKEND: &str = "ReadDirectoryChanges";
pub const FD0: &str = "/dev/fd/0";
pub const IS_A_DIRECTORY: &str = "Is a directory";
pub const DEV_TTY: &str = "/dev/tty";
pub const DEV_PTMX: &str = "/dev/ptmx";
12 changes: 6 additions & 6 deletions tests/by-util/test_tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ use tail::chunks::BUFFER_SIZE as CHUNK_BUFFER_SIZE;
))]
use tail::text;

static FOOBAR_TXT: &str = "foobar.txt";
static FOOBAR_2_TXT: &str = "foobar2.txt";
static FOOBAR_WITH_NULL_TXT: &str = "foobar_with_null.txt";
const FOOBAR_TXT: &str = "foobar.txt";
const FOOBAR_2_TXT: &str = "foobar2.txt";
const FOOBAR_WITH_NULL_TXT: &str = "foobar_with_null.txt";
#[allow(dead_code)]
static FOLLOW_NAME_TXT: &str = "follow_name.txt";
const FOLLOW_NAME_TXT: &str = "follow_name.txt";
#[allow(dead_code)]
static FOLLOW_NAME_SHORT_EXP: &str = "follow_name_short.expected";
const FOLLOW_NAME_SHORT_EXP: &str = "follow_name_short.expected";
#[allow(dead_code)]
static FOLLOW_NAME_EXP: &str = "follow_name.expected";
const FOLLOW_NAME_EXP: &str = "follow_name.expected";

#[cfg(not(windows))]
const DEFAULT_SLEEP_INTERVAL_MILLIS: u64 = 1000;
Expand Down

0 comments on commit 82eb04c

Please sign in to comment.