mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 00:52:46 +08:00
Replace C++-style \p with Markdown backticks
quick_replace '\\\\p ([a-zA-Z0-9_]+)' '`$1`' src/ Filtered to only lines beginning with //
This commit is contained in:
parent
a35925b3ed
commit
589639a87d
|
@ -149,7 +149,7 @@ pub struct Replacement {
|
|||
|
||||
impl Replacement {
|
||||
/// Construct a replacement from a replacer.
|
||||
/// The \p range is the range of the text matched by the replacer in the command line.
|
||||
/// The `range` is the range of the text matched by the replacer in the command line.
|
||||
/// The text is passed in separately as it may be the output of the replacer's function.
|
||||
pub fn new(range: SourceRange, mut text: WString, set_cursor_marker: Option<WString>) -> Self {
|
||||
let mut cursor = None;
|
||||
|
@ -184,7 +184,7 @@ pub struct AbbreviationSet {
|
|||
|
||||
impl AbbreviationSet {
|
||||
/// \return the list of replacers for an input token, in priority order.
|
||||
/// The \p position is given to describe where the token was found.
|
||||
/// The `position` is given to describe where the token was found.
|
||||
pub fn r#match(&self, token: &wstr, position: Position, cmd: &wstr) -> Vec<Replacer> {
|
||||
let mut result = vec![];
|
||||
|
||||
|
@ -270,7 +270,7 @@ impl AbbreviationSet {
|
|||
}
|
||||
|
||||
/// \return the list of replacers for an input token, in priority order, using the global set.
|
||||
/// The \p position is given to describe where the token was found.
|
||||
/// The `position` is given to describe where the token was found.
|
||||
pub fn abbrs_match(token: &wstr, position: Position, cmd: &wstr) -> Vec<Replacer> {
|
||||
with_abbrs(|set| set.r#match(token, position, cmd))
|
||||
.into_iter()
|
||||
|
|
24
src/ast.rs
24
src/ast.rs
|
@ -518,7 +518,7 @@ macro_rules! implement_leaf {
|
|||
}
|
||||
}
|
||||
impl $name {
|
||||
/// Set the parent fields of all nodes in the tree rooted at \p self.
|
||||
/// Set the parent fields of all nodes in the tree rooted at `self`.
|
||||
fn set_parents(&mut self) {}
|
||||
}
|
||||
};
|
||||
|
@ -672,7 +672,7 @@ macro_rules! define_list_node {
|
|||
}
|
||||
}
|
||||
impl $name {
|
||||
/// Set the parent fields of all nodes in the tree rooted at \p self.
|
||||
/// Set the parent fields of all nodes in the tree rooted at `self`.
|
||||
fn set_parents(&mut self) {
|
||||
for i in 0..self.count() {
|
||||
self[i].parent = Some(self);
|
||||
|
@ -771,7 +771,7 @@ macro_rules! implement_acceptor_for_branch {
|
|||
}
|
||||
}
|
||||
impl $name {
|
||||
/// Set the parent fields of all nodes in the tree rooted at \p self.
|
||||
/// Set the parent fields of all nodes in the tree rooted at `self`.
|
||||
fn set_parents(&mut self) {
|
||||
$(
|
||||
set_parent_of_field!(self, $field_name, $field_type);
|
||||
|
@ -2476,9 +2476,9 @@ impl Default for Ast {
|
|||
}
|
||||
|
||||
impl Ast {
|
||||
/// Construct an ast by parsing \p src as a job list.
|
||||
/// The ast attempts to produce \p type as the result.
|
||||
/// \p type may only be JobList or FreestandingArgumentList.
|
||||
/// Construct an ast by parsing `src` as a job list.
|
||||
/// The ast attempts to produce `type` as the result.
|
||||
/// `type` may only be JobList or FreestandingArgumentList.
|
||||
pub fn parse(
|
||||
src: &wstr,
|
||||
flags: ParseTreeFlags,
|
||||
|
@ -2511,7 +2511,7 @@ impl Ast {
|
|||
}
|
||||
|
||||
/// \return a textual representation of the tree.
|
||||
/// Pass the original source as \p orig.
|
||||
/// Pass the original source as `orig`.
|
||||
pub fn dump(&self, orig: &wstr) -> WString {
|
||||
let mut result = WString::new();
|
||||
|
||||
|
@ -2749,7 +2749,7 @@ macro_rules! internal_error {
|
|||
};
|
||||
}
|
||||
|
||||
/// Report an error based on \p fmt for the tokens' range
|
||||
/// Report an error based on `fmt` for the tokens' range
|
||||
macro_rules! parse_error {
|
||||
(
|
||||
$self:ident,
|
||||
|
@ -2764,7 +2764,7 @@ macro_rules! parse_error {
|
|||
}
|
||||
}
|
||||
|
||||
/// Report an error based on \p fmt for the source range \p range.
|
||||
/// Report an error based on `fmt` for the source range `range`.
|
||||
macro_rules! parse_error_range {
|
||||
(
|
||||
$self:ident,
|
||||
|
@ -3134,7 +3134,7 @@ impl<'s> Populator<'s> {
|
|||
self.flags.contains(ParseTreeFlags::LEAVE_UNTERMINATED)
|
||||
}
|
||||
|
||||
/// \return whether a list type \p type allows arbitrary newlines in it.
|
||||
/// \return whether a list type `type` allows arbitrary newlines in it.
|
||||
fn list_type_chomps_newlines(&self, typ: Type) -> bool {
|
||||
match typ {
|
||||
Type::argument_list => {
|
||||
|
@ -3187,7 +3187,7 @@ impl<'s> Populator<'s> {
|
|||
}
|
||||
}
|
||||
|
||||
/// \return whether a list type \p type allows arbitrary semicolons in it.
|
||||
/// \return whether a list type `type` allows arbitrary semicolons in it.
|
||||
fn list_type_chomps_semis(&self, typ: Type) -> bool {
|
||||
match typ {
|
||||
Type::argument_list => {
|
||||
|
@ -3264,7 +3264,7 @@ impl<'s> Populator<'s> {
|
|||
typ == Type::job_list && self.flags.contains(ParseTreeFlags::CONTINUE_AFTER_ERROR)
|
||||
}
|
||||
|
||||
/// \return a reference to a non-comment token at index \p idx.
|
||||
/// \return a reference to a non-comment token at index `idx`.
|
||||
fn peek_token(&mut self, idx: usize) -> &ParseToken {
|
||||
self.tokens.peek(idx)
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ pub struct Autoload {
|
|||
}
|
||||
|
||||
impl Autoload {
|
||||
/// Construct an autoloader that loads from the paths given by \p env_var_name.
|
||||
/// Construct an autoloader that loads from the paths given by `env_var_name`.
|
||||
pub fn new(env_var_name: &'static wstr) -> Self {
|
||||
Self {
|
||||
env_var_name,
|
||||
|
@ -219,8 +219,8 @@ impl AutoloadFileCache {
|
|||
&self.dirs
|
||||
}
|
||||
|
||||
/// Check if a command \p cmd can be loaded.
|
||||
/// If \p allow_stale is true, allow stale entries; otherwise discard them.
|
||||
/// Check if a command `cmd` can be loaded.
|
||||
/// If `allow_stale` is true, allow stale entries; otherwise discard them.
|
||||
/// This returns an autoloadable file, or none() if there is no such file.
|
||||
fn check(&mut self, cmd: &wstr, allow_stale: bool) -> Option<AutoloadableFile> {
|
||||
// Check hits.
|
||||
|
|
|
@ -478,7 +478,7 @@ impl<'source, 'ast> PrettyPrinterState<'source, 'ast> {
|
|||
}
|
||||
}
|
||||
|
||||
/// \return whether a range \p r overlaps an error range from our ast.
|
||||
/// \return whether a range `r` overlaps an error range from our ast.
|
||||
fn range_contained_error(&self, r: SourceRange) -> bool {
|
||||
let errs = self.errors.as_ref().unwrap();
|
||||
let range_is_before = |x: SourceRange, y: SourceRange| x.end().cmp(&y.start());
|
||||
|
@ -526,7 +526,7 @@ impl<'source, 'ast> PrettyPrinterState<'source, 'ast> {
|
|||
added_newline
|
||||
}
|
||||
|
||||
/// Given a string \p input, remove unnecessary quotes, etc.
|
||||
/// Given a string `input`, remove unnecessary quotes, etc.
|
||||
fn clean_text(&self, input: &wstr) -> WString {
|
||||
// Unescape the string - this leaves special markers around if there are any
|
||||
// expansions or anything. We specifically tell it to not compute backslash-escapes
|
||||
|
@ -557,7 +557,7 @@ impl<'source, 'ast> PrettyPrinterState<'source, 'ast> {
|
|||
}
|
||||
|
||||
// Emit a range of original text. This indents as needed, and also inserts preceding gap text.
|
||||
// If \p tolerate_line_splitting is set, then permit escaped newlines; otherwise collapse such
|
||||
// If `tolerate_line_splitting` is set, then permit escaped newlines; otherwise collapse such
|
||||
// lines.
|
||||
fn emit_text(&mut self, r: SourceRange, flags: GapFlags) {
|
||||
self.emit_gap_text_before(r, flags);
|
||||
|
|
|
@ -60,17 +60,17 @@ use crate::wutil::{
|
|||
use printf_compat::args::ToArg;
|
||||
use printf_compat::printf::sprintf_locale;
|
||||
|
||||
/// \return true if \p c is an octal digit.
|
||||
/// \return true if `c` is an octal digit.
|
||||
fn is_octal_digit(c: char) -> bool {
|
||||
('0'..='7').contains(&c)
|
||||
}
|
||||
|
||||
/// \return true if \p c is a decimal digit.
|
||||
/// \return true if `c` is a decimal digit.
|
||||
fn iswdigit(c: char) -> bool {
|
||||
c.is_ascii_digit()
|
||||
}
|
||||
|
||||
/// \return true if \p c is a hexadecimal digit.
|
||||
/// \return true if `c` is a hexadecimal digit.
|
||||
fn iswxdigit(c: char) -> bool {
|
||||
c.is_ascii_hexdigit()
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ struct builtin_printf_state_t<'a, 'b> {
|
|||
}
|
||||
|
||||
/// Convert to a scalar type. \return the result of conversion, and the end of the converted string.
|
||||
/// On conversion failure, \p end is not modified.
|
||||
/// On conversion failure, `end` is not modified.
|
||||
trait RawStringToScalarType: Copy + std::convert::From<u32> {
|
||||
/// Convert from a string to our self type.
|
||||
/// \return the result of conversion, and the remainder of the string.
|
||||
|
|
|
@ -387,7 +387,7 @@ impl<'a> SplitVar<'a> {
|
|||
}
|
||||
|
||||
/// Extract indexes from an argument of the form `var_name[index1 index2...]`.
|
||||
/// The argument \p arg is split into a variable name and list of indexes, which is returned by
|
||||
/// The argument `arg` is split into a variable name and list of indexes, which is returned by
|
||||
/// reference. Indexes are "expanded" in the sense that range expressions .. and negative values are
|
||||
/// handled.
|
||||
///
|
||||
|
@ -809,7 +809,7 @@ fn env_result_to_status(retval: EnvStackSetResult) -> Option<c_int> {
|
|||
})
|
||||
}
|
||||
|
||||
/// Return a list of new values for the variable \p varname, respecting the \p opts.
|
||||
/// Return a list of new values for the variable `varname`, respecting the `opts`.
|
||||
/// This handles the simple case where there are no indexes.
|
||||
fn new_var_values(
|
||||
varname: &wstr,
|
||||
|
@ -859,7 +859,7 @@ fn new_var_values_by_index(split: &SplitVar, argv: &[&wstr]) -> Vec<WString> {
|
|||
result = var.as_list().to_owned();
|
||||
}
|
||||
|
||||
// For each (index, argument) pair, set the element in our \p result to the replacement string.
|
||||
// For each (index, argument) pair, set the element in our `result` to the replacement string.
|
||||
// Extend the list with empty strings as needed. The indexes are 1-based.
|
||||
for (i, arg) in argv.iter().copied().enumerate() {
|
||||
let lidx = usize::try_from(split.indexes[i]).unwrap();
|
||||
|
|
|
@ -30,7 +30,7 @@ enum WaitHandleQuery<'a> {
|
|||
}
|
||||
|
||||
/// Walk the list of jobs, looking for a process with the given pid or proc name.
|
||||
/// Append all matching wait handles to \p handles.
|
||||
/// Append all matching wait handles to `handles`.
|
||||
/// \return true if we found a matching job (even if not waitable), false if not.
|
||||
fn find_wait_handles(
|
||||
query: WaitHandleQuery<'_>,
|
||||
|
@ -92,7 +92,7 @@ fn is_completed(wh: &WaitHandleRef) -> bool {
|
|||
}
|
||||
|
||||
/// Wait for the given wait handles to be marked as completed.
|
||||
/// If \p any_flag is set, wait for the first one; otherwise wait for all.
|
||||
/// If `any_flag` is set, wait for the first one; otherwise wait for all.
|
||||
/// \return a status code.
|
||||
fn wait_for_completion(parser: &Parser, whs: &[WaitHandleRef], any_flag: bool) -> Option<c_int> {
|
||||
if whs.is_empty() {
|
||||
|
|
|
@ -1249,7 +1249,7 @@ pub fn wcs2zstring(input: &wstr) -> CString {
|
|||
CString::new(until_nul).unwrap()
|
||||
}
|
||||
|
||||
/// Like wcs2string, but appends to \p receiver instead of returning a new string.
|
||||
/// Like wcs2string, but appends to `receiver` instead of returning a new string.
|
||||
pub fn wcs2string_appending(output: &mut Vec<u8>, input: &wstr) {
|
||||
output.reserve(input.len());
|
||||
wcs2string_callback(input, |buff| {
|
||||
|
@ -1258,7 +1258,7 @@ pub fn wcs2string_appending(output: &mut Vec<u8>, input: &wstr) {
|
|||
});
|
||||
}
|
||||
|
||||
/// \return the count of initial characters in \p in which are ASCII.
|
||||
/// \return the count of initial characters in `in` which are ASCII.
|
||||
fn count_ascii_prefix(inp: &[u8]) -> usize {
|
||||
// The C++ version had manual vectorization.
|
||||
inp.iter().take_while(|c| c.is_ascii()).count()
|
||||
|
@ -1553,7 +1553,7 @@ pub fn read_loop<Fd: AsRawFd>(fd: &Fd, buf: &mut [u8]) -> std::io::Result<usize>
|
|||
}
|
||||
}
|
||||
|
||||
/// Write the given paragraph of output, redoing linebreaks to fit \p termsize.
|
||||
/// Write the given paragraph of output, redoing linebreaks to fit `termsize`.
|
||||
pub fn reformat_for_screen(msg: &wstr, termsize: &Termsize) -> WString {
|
||||
let mut buff = WString::new();
|
||||
|
||||
|
|
|
@ -1968,11 +1968,11 @@ impl<'ctx> Completer<'ctx> {
|
|||
);
|
||||
}
|
||||
|
||||
// Invoke command-specific completions given by \p arg_data.
|
||||
// Invoke command-specific completions given by `arg_data`.
|
||||
// Then, for each target wrapped by the given command, update the command
|
||||
// line with that target and invoke this recursively.
|
||||
// The command whose completions to use is given by \p cmd. The full command line is given by \p
|
||||
// cmdline and the command's range in it is given by \p cmdrange. Note: the command range
|
||||
// The command whose completions to use is given by `cmd`. The full command line is given by \p
|
||||
// cmdline and the command's range in it is given by `cmdrange`. Note: the command range
|
||||
// may have a different length than the command itself, because the command is unescaped (i.e.
|
||||
// quotes removed).
|
||||
fn walk_wrap_chain(
|
||||
|
|
2
src/env/environment.rs
vendored
2
src/env/environment.rs
vendored
|
@ -327,7 +327,7 @@ impl EnvStack {
|
|||
}
|
||||
|
||||
/// Synchronizes universal variable changes.
|
||||
/// If \p always is set, perform synchronization even if there's no pending changes from this
|
||||
/// If `always` is set, perform synchronization even if there's no pending changes from this
|
||||
/// instance (that is, look for changes from other fish instances).
|
||||
/// \return a list of events for changed variables.
|
||||
#[allow(clippy::vec_box)]
|
||||
|
|
16
src/env/environment_impl.rs
vendored
16
src/env/environment_impl.rs
vendored
|
@ -480,7 +480,7 @@ impl EnvScopedImpl {
|
|||
let query = Query::new(flags);
|
||||
let mut names: HashSet<WString> = HashSet::new();
|
||||
|
||||
// Helper to add the names of variables from \p envs to names, respecting show_exported and
|
||||
// Helper to add the names of variables from `envs` to names, respecting show_exported and
|
||||
// show_unexported.
|
||||
let add_keys = |envs: &VarTable, names: &mut HashSet<WString>| {
|
||||
for (key, val) in envs.iter() {
|
||||
|
@ -707,7 +707,7 @@ impl EnvStackImpl {
|
|||
})
|
||||
}
|
||||
|
||||
/// Set a variable under the name \p key, using the given \p mode, setting its value to \p val.
|
||||
/// Set a variable under the name `key`, using the given `mode`, setting its value to `val`.
|
||||
pub fn set(&mut self, key: &wstr, mode: EnvMode, mut val: Vec<WString>) -> ModResult {
|
||||
let query = Query::new(mode);
|
||||
// Handle electric and read-only variables.
|
||||
|
@ -788,7 +788,7 @@ impl EnvStackImpl {
|
|||
result
|
||||
}
|
||||
|
||||
/// Remove a variable under the name \p key.
|
||||
/// Remove a variable under the name `key`.
|
||||
pub fn remove(&mut self, key: &wstr, mode: EnvMode) -> ModResult {
|
||||
let query = Query::new(mode);
|
||||
// Users can't remove read-only keys.
|
||||
|
@ -891,7 +891,7 @@ impl EnvStackImpl {
|
|||
var_names
|
||||
}
|
||||
|
||||
/// Find the first node in the chain starting at \p node which contains the given key \p key.
|
||||
/// Find the first node in the chain starting at `node` which contains the given key `key`.
|
||||
fn find_in_chain(node: &EnvNodeRef, key: &wstr) -> Option<EnvNodeRef> {
|
||||
#[allow(clippy::manual_find)]
|
||||
for cur in node.iter() {
|
||||
|
@ -902,7 +902,7 @@ impl EnvStackImpl {
|
|||
None
|
||||
}
|
||||
|
||||
/// Remove a variable from the chain \p node.
|
||||
/// Remove a variable from the chain `node`.
|
||||
/// Return true if the variable was found and removed.
|
||||
fn remove_from_chain(node: &mut EnvNodeRef, key: &wstr) -> bool {
|
||||
for cur in node.iter() {
|
||||
|
@ -917,9 +917,9 @@ impl EnvStackImpl {
|
|||
false
|
||||
}
|
||||
|
||||
/// Try setting \p key as an electric or readonly variable, whose value is provided by reference in \p val.
|
||||
/// Try setting `key` as an electric or readonly variable, whose value is provided by reference in `val`.
|
||||
/// Return an error code, or NOne if not an electric or readonly variable.
|
||||
/// \p val will not be modified upon a None return.
|
||||
/// `val` will not be modified upon a None return.
|
||||
fn try_set_electric(
|
||||
&mut self,
|
||||
key: &wstr,
|
||||
|
@ -1015,7 +1015,7 @@ impl EnvStackImpl {
|
|||
locked_uvars.set(key, new_var);
|
||||
}
|
||||
|
||||
/// Set a variable in a given node \p node.
|
||||
/// Set a variable in a given node `node`.
|
||||
fn set_in_node(node: &mut EnvNodeRef, key: &wstr, mut val: Vec<WString>, flags: VarFlags) {
|
||||
// Read the var from the node. In C++ this was node->env[key] which establishes a default.
|
||||
let mut node_ref = node.borrow_mut();
|
||||
|
|
|
@ -250,7 +250,7 @@ impl EnvUniversal {
|
|||
}
|
||||
}
|
||||
|
||||
/// Populate a variable table \p out_vars from a \p s string.
|
||||
/// Populate a variable table `out_vars` from a `s` string.
|
||||
/// This is exposed for testing only.
|
||||
/// \return the format of the file that we read.
|
||||
pub fn populate_variables(s: &[u8], out_vars: &mut VarTable) -> UvarFormat {
|
||||
|
@ -290,7 +290,7 @@ impl EnvUniversal {
|
|||
}
|
||||
|
||||
/// Guess a file format. Exposed for testing only.
|
||||
/// \return the format corresponding to file contents \p s.
|
||||
/// \return the format corresponding to file contents `s`.
|
||||
pub fn format_for_contents(s: &[u8]) -> UvarFormat {
|
||||
// Walk over leading comments, looking for one like '# version'
|
||||
let iter = LineIterator::new(s);
|
||||
|
|
42
src/exec.rs
42
src/exec.rs
|
@ -61,7 +61,7 @@ use std::slice;
|
|||
use std::sync::atomic::Ordering;
|
||||
use std::sync::{atomic::AtomicUsize, Arc};
|
||||
|
||||
/// Execute the processes specified by \p j in the parser \p.
|
||||
/// Execute the processes specified by `j` in the parser \p.
|
||||
/// On a true return, the job was successfully launched and the parser will take responsibility for
|
||||
/// cleaning it up. On a false return, the job could not be launched and the caller must clean it
|
||||
/// up.
|
||||
|
@ -268,7 +268,7 @@ pub fn exec_subshell(
|
|||
|
||||
/// Like exec_subshell, but only returns expansion-breaking errors. That is, a zero return means
|
||||
/// "success" (even though the command may have failed), a non-zero return means that we should
|
||||
/// halt expansion. If the \p pgid is supplied, then any spawned external commands should join that
|
||||
/// halt expansion. If the `pgid` is supplied, then any spawned external commands should join that
|
||||
/// pgroup.
|
||||
pub fn exec_subshell_for_expand(
|
||||
cmd: &wstr,
|
||||
|
@ -303,7 +303,7 @@ static FORK_COUNT: AtomicUsize = AtomicUsize::new(0);
|
|||
/// etc.
|
||||
type LaunchResult = Result<(), ()>;
|
||||
|
||||
/// Given an error \p err returned from either posix_spawn or exec, \return a process exit code.
|
||||
/// Given an error `err` returned from either posix_spawn or exec, \return a process exit code.
|
||||
fn exit_code_from_exec_error(err: libc::c_int) -> libc::c_int {
|
||||
assert!(err != 0, "Zero is success, not an error");
|
||||
match err {
|
||||
|
@ -512,8 +512,8 @@ fn internal_exec(vars: &EnvStack, j: &Job, block_io: IoChain) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Construct an internal process for the process p. In the background, write the data \p outdata to
|
||||
/// stdout and \p errdata to stderr, respecting the io chain \p ios. For example if target_fd is 1
|
||||
/// Construct an internal process for the process p. In the background, write the data `outdata` to
|
||||
/// stdout and `errdata` to stderr, respecting the io chain `ios`. For example if target_fd is 1
|
||||
/// (stdout), and there is a dup2 3->1, then we need to write to fd 3. Then exit the internal
|
||||
/// process.
|
||||
fn run_internal_process(p: &Process, outdata: Vec<u8>, errdata: Vec<u8>, ios: &IoChain) {
|
||||
|
@ -625,7 +625,7 @@ fn run_internal_process(p: &Process, outdata: Vec<u8>, errdata: Vec<u8>, ios: &I
|
|||
});
|
||||
}
|
||||
|
||||
/// If \p outdata or \p errdata are both empty, then mark the process as completed immediately.
|
||||
/// If `outdata` or `errdata` are both empty, then mark the process as completed immediately.
|
||||
/// Otherwise, run an internal process.
|
||||
fn run_internal_process_or_short_circuit(
|
||||
parser: &Parser,
|
||||
|
@ -662,7 +662,7 @@ fn run_internal_process_or_short_circuit(
|
|||
}
|
||||
}
|
||||
|
||||
/// Call fork() as part of executing a process \p p in a job \j. Execute \p child_action in the
|
||||
/// Call fork() as part of executing a process `p` in a job \j. Execute `child_action` in the
|
||||
/// context of the child.
|
||||
fn fork_child_for_process(
|
||||
job: &Job,
|
||||
|
@ -746,7 +746,7 @@ fn fork_child_for_process(
|
|||
|
||||
/// \return an newly allocated output stream for the given fd, which is typically stdout or stderr.
|
||||
/// This inspects the io_chain and decides what sort of output stream to return.
|
||||
/// If \p piped_output_needs_buffering is set, and if the output is going to a pipe, then the other
|
||||
/// If `piped_output_needs_buffering` is set, and if the output is going to a pipe, then the other
|
||||
/// end then synchronously writing to the pipe risks deadlock, so we must buffer it.
|
||||
fn create_output_stream_for_builtin(
|
||||
fd: RawFd,
|
||||
|
@ -949,7 +949,7 @@ fn function_restore_environment(parser: &Parser, block: BlockId) {
|
|||
}
|
||||
|
||||
// The "performer" function of a block or function process.
|
||||
// This accepts a place to execute as \p parser and then executes the result, returning a status.
|
||||
// This accepts a place to execute as `parser` and then executes the result, returning a status.
|
||||
// This is factored out in this funny way in preparation for concurrent execution.
|
||||
type ProcPerformer = dyn FnOnce(
|
||||
&Parser,
|
||||
|
@ -1030,7 +1030,7 @@ fn get_performer_for_process(
|
|||
}
|
||||
|
||||
/// Execute a block node or function "process".
|
||||
/// \p piped_output_needs_buffering if true, buffer the output.
|
||||
/// `piped_output_needs_buffering` if true, buffer the output.
|
||||
fn exec_block_or_func_process(
|
||||
parser: &Parser,
|
||||
j: &Job,
|
||||
|
@ -1184,10 +1184,10 @@ struct PartialPipes {
|
|||
write: Option<OwnedFd>,
|
||||
}
|
||||
|
||||
/// Executes a process \p \p in \p job, using the pipes \p pipes (which may have invalid fds if this
|
||||
/// Executes a process \p `in` `job`, using the pipes `pipes` (which may have invalid fds if this
|
||||
/// is the first or last process).
|
||||
/// \p deferred_pipes represents the pipes from our deferred process; if set ensure they get closed
|
||||
/// in any child. If \p is_deferred_run is true, then this is a deferred run; this affects how
|
||||
/// `deferred_pipes` represents the pipes from our deferred process; if set ensure they get closed
|
||||
/// in any child. If `is_deferred_run` is true, then this is a deferred run; this affects how
|
||||
/// certain buffering works.
|
||||
/// An error return here indicates that the process failed to launch, and the rest of
|
||||
/// the pipeline should be cancelled.
|
||||
|
@ -1356,7 +1356,7 @@ fn get_deferred_process(j: &Job) -> Option<usize> {
|
|||
None
|
||||
}
|
||||
|
||||
/// Given that we failed to execute process \p failed_proc in job \p job, mark that process and
|
||||
/// Given that we failed to execute process `failed_proc` in job `job`, mark that process and
|
||||
/// every subsequent process in the pipeline as aborted before launch.
|
||||
fn abort_pipeline_from(job: &Job, offset: usize) {
|
||||
for p in job.processes().iter().skip(offset) {
|
||||
|
@ -1392,7 +1392,7 @@ fn allow_exec_with_background_jobs(parser: &Parser) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
/// Populate \p lst with the output of \p buffer, perhaps splitting lines according to \p split.
|
||||
/// Populate `lst` with the output of `buffer`, perhaps splitting lines according to `split`.
|
||||
fn populate_subshell_output(lst: &mut Vec<WString>, buffer: &SeparatedBuffer, split: bool) {
|
||||
// Walk over all the elements.
|
||||
for elem in buffer.elements() {
|
||||
|
@ -1430,12 +1430,12 @@ fn populate_subshell_output(lst: &mut Vec<WString>, buffer: &SeparatedBuffer, sp
|
|||
}
|
||||
}
|
||||
|
||||
/// Execute \p cmd in a subshell in \p parser. If \p lst is not null, populate it with the output.
|
||||
/// Return $status in \p out_status.
|
||||
/// If \p job_group is set, any spawned commands should join that job group.
|
||||
/// If \p apply_exit_status is false, then reset $status back to its original value.
|
||||
/// \p is_subcmd controls whether we apply a read limit.
|
||||
/// \p break_expand is used to propagate whether the result should be "expansion breaking" in the
|
||||
/// Execute `cmd` in a subshell in `parser`. If `lst` is not null, populate it with the output.
|
||||
/// Return $status in `out_status`.
|
||||
/// If `job_group` is set, any spawned commands should join that job group.
|
||||
/// If `apply_exit_status` is false, then reset $status back to its original value.
|
||||
/// `is_subcmd` controls whether we apply a read limit.
|
||||
/// `break_expand` is used to propagate whether the result should be "expansion breaking" in the
|
||||
/// sense that subshells used during string expansion should halt that expansion. \return the value
|
||||
/// of $status.
|
||||
fn exec_subshell_internal(
|
||||
|
|
|
@ -207,7 +207,7 @@ pub fn expand_one(
|
|||
/// If the expansion resulted in no or an empty command, the command will be an empty string. Note
|
||||
/// that API does not distinguish between expansion resulting in an empty command (''), and
|
||||
/// expansion resulting in no command (e.g. unset variable).
|
||||
/// If \p skip_wildcards is true, then do not do wildcard expansion
|
||||
/// If `skip_wildcards` is true, then do not do wildcard expansion
|
||||
/// \return an expand error.
|
||||
pub fn expand_to_command_and_args(
|
||||
instr: &wstr,
|
||||
|
@ -792,7 +792,7 @@ fn expand_variables(
|
|||
ExpandResult::ok()
|
||||
}
|
||||
|
||||
/// Perform brace expansion, placing the expanded strings into \p out.
|
||||
/// Perform brace expansion, placing the expanded strings into `out`.
|
||||
fn expand_braces(
|
||||
input: WString,
|
||||
flags: ExpandFlags,
|
||||
|
@ -916,8 +916,8 @@ fn expand_braces(
|
|||
ExpandResult::ok()
|
||||
}
|
||||
|
||||
/// Expand a command substitution \p input, executing on \p ctx, and inserting the results into
|
||||
/// \p out_list, or any errors into \p errors. \return an expand result.
|
||||
/// Expand a command substitution `input`, executing on `ctx`, and inserting the results into
|
||||
/// `out_list`, or any errors into `errors`. \return an expand result.
|
||||
pub fn expand_cmdsubst(
|
||||
input: WString,
|
||||
ctx: &OperationContext,
|
||||
|
|
|
@ -138,7 +138,7 @@ impl FdEventSignaller {
|
|||
}
|
||||
|
||||
/// Perform a poll to see if an event is received.
|
||||
/// If \p wait is set, wait until it is readable; this does not consume the event
|
||||
/// If `wait` is set, wait until it is readable; this does not consume the event
|
||||
/// but guarantees that the next call to wait() will not block.
|
||||
/// \return true if readable, false if not readable, or not interrupted by a signal.
|
||||
pub fn poll(&self, wait: bool /* = false */) -> bool {
|
||||
|
|
|
@ -176,7 +176,7 @@ pub fn make_autoclose_pipes() -> nix::Result<AutoClosePipes> {
|
|||
|
||||
/// If the given fd is in the "user range", move it to a new fd in the "high range".
|
||||
/// zsh calls this movefd().
|
||||
/// \p input_has_cloexec describes whether the input has CLOEXEC already set, so we can avoid
|
||||
/// `input_has_cloexec` describes whether the input has CLOEXEC already set, so we can avoid
|
||||
/// setting it again.
|
||||
/// \return the fd, which always has CLOEXEC set; or an invalid fd on failure, in
|
||||
/// which case an error will have been printed, and the input fd closed.
|
||||
|
@ -202,7 +202,7 @@ fn heightenize_fd(fd: OwnedFd, input_has_cloexec: bool) -> nix::Result<OwnedFd>
|
|||
Ok(unsafe { OwnedFd::from_raw_fd(newfd) })
|
||||
}
|
||||
|
||||
/// Sets CLO_EXEC on a given fd according to the value of \p should_set.
|
||||
/// Sets CLO_EXEC on a given fd according to the value of `should_set`.
|
||||
pub fn set_cloexec(fd: RawFd, should_set: bool /* = true */) -> c_int {
|
||||
// Note we don't want to overwrite existing flags like O_NONBLOCK which may be set. So fetch the
|
||||
// existing flags and modify them.
|
||||
|
@ -270,7 +270,7 @@ pub fn open_dir(path: &CStr, mode: nix::sys::stat::Mode) -> nix::Result<OwnedFd>
|
|||
open_cloexec(path, OFlag::O_RDONLY | OFlag::O_DIRECTORY, mode).map(OwnedFd::from)
|
||||
}
|
||||
|
||||
/// Close a file descriptor \p fd, retrying on EINTR.
|
||||
/// Close a file descriptor `fd`, retrying on EINTR.
|
||||
pub fn exec_close(fd: RawFd) {
|
||||
assert!(fd >= 0, "Invalid fd");
|
||||
while unsafe { libc::close(fd) } == -1 {
|
||||
|
|
|
@ -228,7 +228,7 @@ fn apply_one_wildcard(wc_esc: &wstr, sense: bool) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Set the active flog categories according to the given wildcard \p wc.
|
||||
/// Set the active flog categories according to the given wildcard `wc`.
|
||||
pub fn activate_flog_categories_by_pattern(wc_ptr: &wstr) {
|
||||
let mut wc: WString = wc_ptr.into();
|
||||
// Normalize underscores to dashes, allowing the user to be sloppy.
|
||||
|
|
|
@ -177,7 +177,7 @@ fn autoload_names(names: &mut HashSet<WString>, get_hidden: bool) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Add a function. This may mutate \p props to set is_autoload.
|
||||
/// Add a function. This may mutate `props` to set is_autoload.
|
||||
pub fn add(name: WString, props: Arc<FunctionProperties>) {
|
||||
let mut funcset = FUNCTION_SET.lock().unwrap();
|
||||
|
||||
|
@ -221,7 +221,7 @@ pub fn get_props_autoload(name: &wstr, parser: &Parser) -> Option<Arc<FunctionPr
|
|||
get_props(name)
|
||||
}
|
||||
|
||||
/// Returns true if the function named \p cmd exists.
|
||||
/// Returns true if the function named `cmd` exists.
|
||||
/// This may autoload.
|
||||
pub fn exists(cmd: &wstr, parser: &Parser) -> bool {
|
||||
parser.assert_can_execute();
|
||||
|
@ -231,7 +231,7 @@ pub fn exists(cmd: &wstr, parser: &Parser) -> bool {
|
|||
get_props_autoload(cmd, parser).is_some()
|
||||
}
|
||||
|
||||
/// Returns true if the function \p cmd either is loaded, or exists on disk in an autoload
|
||||
/// Returns true if the function `cmd` either is loaded, or exists on disk in an autoload
|
||||
/// directory.
|
||||
pub fn exists_no_autoload(cmd: &wstr) -> bool {
|
||||
if !valid_func_name(cmd) {
|
||||
|
|
|
@ -316,7 +316,7 @@ fn autosuggest_parse_command(
|
|||
None
|
||||
}
|
||||
|
||||
/// Given an item \p item from the history which is a proposed autosuggestion, return whether the
|
||||
/// Given an item `item` from the history which is a proposed autosuggestion, return whether the
|
||||
/// autosuggestion is valid. It may not be valid if e.g. it is attempting to cd into a directory
|
||||
/// which does not exist.
|
||||
pub fn autosuggest_validate_from_history(
|
||||
|
|
|
@ -638,7 +638,7 @@ impl EventQueuePeeker<'_> {
|
|||
}
|
||||
|
||||
/// Check if the next event is the given character. This advances the index on success only.
|
||||
/// If \p escaped is set, then return false if this (or any other) character had a timeout.
|
||||
/// If `escaped` is set, then return false if this (or any other) character had a timeout.
|
||||
fn next_is_char(&mut self, style: &KeyNameStyle, key: Key, escaped: bool) -> bool {
|
||||
assert!(
|
||||
self.idx <= self.peeked.len(),
|
||||
|
@ -773,7 +773,7 @@ impl Drop for EventQueuePeeker<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// \return true if a given \p peeker matches a given sequence of char events given by \p str.
|
||||
/// \return true if a given `peeker` matches a given sequence of char events given by `str`.
|
||||
fn try_peek_sequence(peeker: &mut EventQueuePeeker, style: &KeyNameStyle, seq: &[Key]) -> bool {
|
||||
assert!(
|
||||
!seq.is_empty(),
|
||||
|
|
|
@ -115,7 +115,7 @@ impl SeparatedBuffer {
|
|||
&self.elements
|
||||
}
|
||||
|
||||
/// Append the given data with separation type \p sep.
|
||||
/// Append the given data with separation type `sep`.
|
||||
pub fn append(&mut self, data: &[u8], sep: SeparationType) -> bool {
|
||||
if !self.try_add_size(data.len()) {
|
||||
return false;
|
||||
|
@ -145,7 +145,7 @@ impl SeparatedBuffer {
|
|||
!self.elements.is_empty() && !self.elements.last().unwrap().is_explicitly_separated()
|
||||
}
|
||||
|
||||
/// Mark that we are about to add the given size \p delta to the buffer. \return true if we
|
||||
/// Mark that we are about to add the given size `delta` to the buffer. \return true if we
|
||||
/// succeed, false if we exceed buffer_limit.
|
||||
fn try_add_size(&mut self, delta: usize) -> bool {
|
||||
if self.discard {
|
||||
|
|
|
@ -385,7 +385,7 @@ impl Outputter {
|
|||
&self.contents
|
||||
}
|
||||
|
||||
/// Output any buffered data to the given \p fd.
|
||||
/// Output any buffered data to the given `fd`.
|
||||
fn flush_to(&mut self, fd: RawFd) {
|
||||
if fd >= 0 && !self.contents.is_empty() {
|
||||
let _ = common::write_loop(&fd, &self.contents);
|
||||
|
|
|
@ -113,7 +113,7 @@ impl ParseExecutionContext {
|
|||
}
|
||||
}
|
||||
|
||||
// Report an error, setting $status to \p status. Always returns
|
||||
// Report an error, setting $status to `status`. Always returns
|
||||
// 'end_execution_reason_t::error'.
|
||||
macro_rules! report_error {
|
||||
( $self:ident, $ctx:expr, $status:expr, $node:expr, $fmt:expr $(, $arg:expr )* $(,)? ) => {
|
||||
|
|
|
@ -31,7 +31,7 @@ use std::ops::Range;
|
|||
use std::{iter, ops};
|
||||
|
||||
/// Handles slices: the square brackets in an expression like $foo[5..4]
|
||||
/// \return the length of the slice starting at \p in, or 0 if there is no slice, or None on error.
|
||||
/// \return the length of the slice starting at `in`, or 0 if there is no slice, or None on error.
|
||||
/// This never accepts incomplete slices.
|
||||
pub fn parse_util_slice_length(input: &wstr) -> Option<usize> {
|
||||
const openc: char = '[';
|
||||
|
@ -1566,8 +1566,8 @@ fn detect_errors_in_backgrounded_job(
|
|||
errored
|
||||
}
|
||||
|
||||
/// Given a source buffer \p buff_src and decorated statement \p dst within it, return true if there
|
||||
/// is an error and false if not. \p storage may be used to reduce allocations.
|
||||
/// Given a source buffer `buff_src` and decorated statement `dst` within it, return true if there
|
||||
/// is an error and false if not. `storage` may be used to reduce allocations.
|
||||
fn detect_errors_in_decorated_statement(
|
||||
buff_src: &wstr,
|
||||
dst: &ast::DecoratedStatement,
|
||||
|
|
|
@ -807,7 +807,7 @@ impl Parser {
|
|||
}
|
||||
|
||||
/// Update any universal variables and send event handlers.
|
||||
/// If \p always is set, then do it even if we have no pending changes (that is, look for
|
||||
/// If `always` is set, then do it even if we have no pending changes (that is, look for
|
||||
/// changes from other fish instances); otherwise only sync if this instance has changed uvars.
|
||||
pub fn sync_uvars_and_fire(&self, always: bool) {
|
||||
if self.syncs_uvars.load() {
|
||||
|
@ -1128,7 +1128,7 @@ fn print_profile(items: &[ProfileItem], out: RawFd) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Append stack trace info for the block \p b to \p trace.
|
||||
/// Append stack trace info for the block `b` to `trace`.
|
||||
fn append_block_description_to_stack_trace(parser: &Parser, b: &Block, trace: &mut WString) {
|
||||
let mut print_call_site = false;
|
||||
match b.typ() {
|
||||
|
|
|
@ -186,7 +186,7 @@ fn maybe_issue_path_warning(
|
|||
printf!("\n");
|
||||
}
|
||||
|
||||
/// Finds the path of an executable named \p cmd, by looking in $PATH taken from \p vars.
|
||||
/// Finds the path of an executable named `cmd`, by looking in $PATH taken from `vars`.
|
||||
/// \returns the path if found, none if not.
|
||||
pub fn path_get_path(cmd: &wstr, vars: &dyn Environment) -> Option<WString> {
|
||||
let result = path_try_get_path(cmd, vars);
|
||||
|
@ -206,7 +206,7 @@ pub static DEFAULT_PATH: Lazy<[WString; 3]> = Lazy::new(|| {
|
|||
]
|
||||
});
|
||||
|
||||
/// Finds the path of an executable named \p cmd, by looking in $PATH taken from \p vars.
|
||||
/// Finds the path of an executable named `cmd`, by looking in $PATH taken from `vars`.
|
||||
/// On success, err will be 0 and the path is returned.
|
||||
/// On failure, we return the "best path" with err set appropriately.
|
||||
/// For example, if we find a non-executable file, we will return its path and EACCESS.
|
||||
|
@ -591,8 +591,8 @@ impl BaseDirectory {
|
|||
}
|
||||
}
|
||||
|
||||
/// Attempt to get a base directory, creating it if necessary. If a variable named \p xdg_var is
|
||||
/// set, use that directory; otherwise use the path \p non_xdg_homepath rooted in $HOME. \return the
|
||||
/// Attempt to get a base directory, creating it if necessary. If a variable named `xdg_var` is
|
||||
/// set, use that directory; otherwise use the path `non_xdg_homepath` rooted in $HOME. \return the
|
||||
/// result; see the base_directory_t fields.
|
||||
#[cfg_attr(test, allow(unused_variables), allow(unreachable_code))]
|
||||
fn make_base_directory(xdg_var: &wstr, non_xdg_homepath: &wstr) -> BaseDirectory {
|
||||
|
|
10
src/proc.rs
10
src/proc.rs
|
@ -153,7 +153,7 @@ impl ProcStatus {
|
|||
(status, empty)
|
||||
}
|
||||
|
||||
/// Encode a return value \p ret and signal \p sig into a status value like waitpid() does.
|
||||
/// Encode a return value `ret` and signal `sig` into a status value like waitpid() does.
|
||||
const fn w_exitcode(ret: i32, sig: i32) -> i32 {
|
||||
#[cfg(HAVE_WAITSTATUS_SIGNAL_RET)]
|
||||
// It's encoded signal and then status
|
||||
|
@ -1145,7 +1145,7 @@ pub fn set_job_control_mode(mode: JobControl) {
|
|||
static JOB_CONTROL_MODE: AtomicU8 = AtomicU8::new(JobControl::interactive as u8);
|
||||
|
||||
/// Notify the user about stopped or terminated jobs, and delete completed jobs from the job list.
|
||||
/// If \p interactive is set, allow removing interactive jobs; otherwise skip them.
|
||||
/// If `interactive` is set, allow removing interactive jobs; otherwise skip them.
|
||||
/// \return whether text was printed to stdout.
|
||||
pub fn job_reap(parser: &Parser, allow_interactive: bool) -> bool {
|
||||
parser.assert_can_execute();
|
||||
|
@ -1243,7 +1243,7 @@ pub fn proc_init() {
|
|||
signal_set_handlers_once(false);
|
||||
}
|
||||
|
||||
/// Set the status of \p proc to \p status.
|
||||
/// Set the status of `proc` to `status`.
|
||||
fn handle_child_status(job: &Job, proc: &Process, status: &ProcStatus) {
|
||||
proc.status.update(status);
|
||||
if status.stopped() {
|
||||
|
@ -1288,7 +1288,7 @@ pub fn proc_wait_any(parser: &Parser) {
|
|||
process_clean_after_marking(parser, is_interactive);
|
||||
}
|
||||
|
||||
/// Send SIGHUP to the list \p jobs, excepting those which are in fish's pgroup.
|
||||
/// Send SIGHUP to the list `jobs`, excepting those which are in fish's pgroup.
|
||||
pub fn hup_jobs(jobs: &JobList) {
|
||||
let fish_pgrp = unsafe { libc::getpgrp() };
|
||||
for j in jobs {
|
||||
|
@ -1476,7 +1476,7 @@ fn process_mark_finished_children(parser: &Parser, block_ok: bool) {
|
|||
reap_disowned_pids();
|
||||
}
|
||||
|
||||
/// Generate process_exit events for any completed processes in \p j.
|
||||
/// Generate process_exit events for any completed processes in `j`.
|
||||
fn generate_process_exit_events(j: &Job, out_evts: &mut Vec<Event>) {
|
||||
// Historically we have avoided generating events for foreground jobs from event handlers, as an
|
||||
// event handler may itself produce a new event.
|
||||
|
|
|
@ -240,8 +240,8 @@ fn reader_push_ret(
|
|||
data
|
||||
}
|
||||
|
||||
/// Push a new reader environment controlled by \p conf, using the given history name.
|
||||
/// If \p history_name is empty, then save history in-memory only; do not write it to disk.
|
||||
/// Push a new reader environment controlled by `conf`, using the given history name.
|
||||
/// If `history_name` is empty, then save history in-memory only; do not write it to disk.
|
||||
pub fn reader_push(parser: &Parser, history_name: &wstr, conf: ReaderConfig) {
|
||||
// Public variant which discards the return value.
|
||||
reader_push_ret(parser, history_name, conf);
|
||||
|
@ -1342,7 +1342,7 @@ pub fn combine_command_and_autosuggestion(cmdline: &wstr, autosuggestion: &wstr)
|
|||
}
|
||||
|
||||
impl ReaderData {
|
||||
/// \return true if the command line has changed and repainting is needed. If \p colors is not
|
||||
/// \return true if the command line has changed and repainting is needed. If `colors` is not
|
||||
/// null, then also return true if the colors have changed.
|
||||
fn is_repaint_needed(&self, mcolors: Option<&[HighlightSpec]>) -> bool {
|
||||
// Note: this function is responsible for detecting all of the ways that the command line may
|
||||
|
@ -1394,7 +1394,7 @@ impl ReaderData {
|
|||
}
|
||||
|
||||
/// Generate a new layout data from the current state of the world.
|
||||
/// If \p mcolors has a value, then apply it; otherwise extend existing colors.
|
||||
/// If `mcolors` has a value, then apply it; otherwise extend existing colors.
|
||||
fn make_layout_data(&self) -> LayoutData {
|
||||
let mut result = LayoutData::default();
|
||||
let focused_on_pager = self.active_edit_line_tag() == EditableLineTag::SearchField;
|
||||
|
@ -1417,14 +1417,14 @@ impl ReaderData {
|
|||
}
|
||||
|
||||
/// Generate a new layout data from the current state of the world, and paint with it.
|
||||
/// If \p mcolors has a value, then apply it; otherwise extend existing colors.
|
||||
/// If `mcolors` has a value, then apply it; otherwise extend existing colors.
|
||||
fn layout_and_repaint(&mut self, reason: &wstr) {
|
||||
self.rendered_layout = self.make_layout_data();
|
||||
self.paint_layout(reason);
|
||||
}
|
||||
|
||||
/// Paint the last rendered layout.
|
||||
/// \p reason is used in FLOG to explain why.
|
||||
/// `reason` is used in FLOG to explain why.
|
||||
fn paint_layout(&mut self, reason: &wstr) {
|
||||
FLOGF!(reader_render, "Repainting from %ls", reason);
|
||||
let data = &self.rendered_layout;
|
||||
|
@ -4493,7 +4493,7 @@ fn expand_replacer(
|
|||
))
|
||||
}
|
||||
|
||||
// Extract all the token ranges in \p str, along with whether they are a command.
|
||||
// Extract all the token ranges in `str`, along with whether they are a command.
|
||||
// Tokens containing command substitutions are skipped; this ensures tokens are non-overlapping.
|
||||
struct PositionedToken {
|
||||
range: SourceRange,
|
||||
|
@ -4997,8 +4997,8 @@ pub fn check_exit_loop_maybe_warning(data: Option<&mut ReaderData>) -> bool {
|
|||
true
|
||||
}
|
||||
|
||||
/// Given that the user is tab-completing a token \p wc whose cursor is at \p pos in the token,
|
||||
/// try expanding it as a wildcard, populating \p result with the expanded string.
|
||||
/// Given that the user is tab-completing a token `wc` whose cursor is at `pos` in the token,
|
||||
/// try expanding it as a wildcard, populating `result` with the expanded string.
|
||||
fn try_expand_wildcard(
|
||||
parser: &Parser,
|
||||
wc: WString,
|
||||
|
|
|
@ -79,7 +79,7 @@ impl ReaderHistorySearch {
|
|||
self.mode == SearchMode::Prefix
|
||||
}
|
||||
|
||||
/// Move the history search in the given direction \p dir.
|
||||
/// Move the history search in the given direction `dir`.
|
||||
pub fn move_in_direction(&mut self, dir: SearchDirection) -> bool {
|
||||
if dir == SearchDirection::Forward {
|
||||
self.move_forwards()
|
||||
|
|
|
@ -61,7 +61,7 @@ impl Line {
|
|||
self.text.clear();
|
||||
}
|
||||
|
||||
/// Append a single character \p txt to the line with color \p c.
|
||||
/// Append a single character `txt` to the line with color `c`.
|
||||
pub fn append(&mut self, character: char, highlight: HighlightSpec) {
|
||||
self.text.push(HighlightedChar {
|
||||
highlight,
|
||||
|
@ -69,7 +69,7 @@ impl Line {
|
|||
})
|
||||
}
|
||||
|
||||
/// Append a nul-terminated string \p txt to the line, giving each character \p color.
|
||||
/// Append a nul-terminated string `txt` to the line, giving each character `color`.
|
||||
pub fn append_str(&mut self, txt: &wstr, highlight: HighlightSpec) {
|
||||
for c in txt.chars() {
|
||||
self.append(c, highlight);
|
||||
|
@ -91,12 +91,12 @@ impl Line {
|
|||
self.text[idx].highlight
|
||||
}
|
||||
|
||||
/// Append the contents of \p line to this line.
|
||||
/// Append the contents of `line` to this line.
|
||||
pub fn append_line(&mut self, line: &Line) {
|
||||
self.text.extend_from_slice(&line.text);
|
||||
}
|
||||
|
||||
/// \return the width of this line, counting up to no more than \p max characters.
|
||||
/// \return the width of this line, counting up to no more than `max` characters.
|
||||
/// This follows fish_wcswidth() semantics, except that characters whose width would be -1 are
|
||||
/// treated as 0.
|
||||
pub fn wcswidth_min_0(&self, max: usize /* = usize::MAX */) -> usize {
|
||||
|
@ -1133,7 +1133,7 @@ impl LayoutCache {
|
|||
self.esc_cache.len()
|
||||
}
|
||||
|
||||
/// Insert the entry \p str in its sorted position, if it is not already present in the cache.
|
||||
/// Insert the entry `str` in its sorted position, if it is not already present in the cache.
|
||||
pub fn add_escape_code(&mut self, s: WString) {
|
||||
if let Err(pos) = self.esc_cache.binary_search(&s) {
|
||||
self.esc_cache.insert(pos, s);
|
||||
|
@ -1158,7 +1158,7 @@ impl LayoutCache {
|
|||
esc_seq_len
|
||||
}
|
||||
|
||||
/// \return the length of a string that matches a prefix of \p entry.
|
||||
/// \return the length of a string that matches a prefix of `entry`.
|
||||
pub fn find_escape_code(&self, entry: &wstr) -> usize {
|
||||
// Do a binary search and see if the escape code right before our entry is a prefix of our
|
||||
// entry. Note this assumes that escape codes are prefix-free: no escape code is a prefix of
|
||||
|
@ -1177,7 +1177,7 @@ impl LayoutCache {
|
|||
0
|
||||
}
|
||||
|
||||
/// Computes a prompt layout for \p prompt_str, perhaps truncating it to \p max_line_width.
|
||||
/// Computes a prompt layout for `prompt_str`, perhaps truncating it to `max_line_width`.
|
||||
/// \return the layout, and optionally the truncated prompt itself, by reference.
|
||||
pub fn calc_prompt_layout(
|
||||
&mut self,
|
||||
|
@ -1494,13 +1494,13 @@ fn is_visual_escape_seq(code: &wstr) -> Option<usize> {
|
|||
None
|
||||
}
|
||||
|
||||
/// \return whether \p c ends a measuring run.
|
||||
/// \return whether `c` ends a measuring run.
|
||||
fn is_run_terminator(c: char) -> bool {
|
||||
matches!(c, '\0' | '\n' | '\r' | '\x0C')
|
||||
}
|
||||
|
||||
/// Measure a run of characters in \p input starting at \p start.
|
||||
/// Stop when we reach a run terminator, and return its index in \p out_end (if not null).
|
||||
/// Measure a run of characters in `input` starting at `start`.
|
||||
/// Stop when we reach a run terminator, and return its index in `out_end` (if not null).
|
||||
/// Note \0 is a run terminator so there will always be one.
|
||||
/// We permit escape sequences to have run terminators other than \0. That is, escape sequences may
|
||||
/// have embedded newlines, etc.; it's unclear if this is possible but we allow it.
|
||||
|
@ -1532,7 +1532,7 @@ fn measure_run_from(
|
|||
width
|
||||
}
|
||||
|
||||
/// Attempt to truncate the prompt run \p run, which has width \p width, to \p no more than
|
||||
/// Attempt to truncate the prompt run `run`, which has width `width`, to `no` more than
|
||||
/// desired_width. \return the resulting width and run by reference.
|
||||
fn truncate_run(
|
||||
run: &mut WString,
|
||||
|
|
|
@ -164,7 +164,7 @@ impl TermsizeContainer {
|
|||
data.current()
|
||||
}
|
||||
|
||||
/// If our termsize is stale, update it, using \p parser to fire any events that may be
|
||||
/// If our termsize is stale, update it, using `parser` to fire any events that may be
|
||||
/// registered for COLUMNS and LINES.
|
||||
/// This requires a shared reference so it can work from a static.
|
||||
/// \return the updated termsize.
|
||||
|
|
|
@ -129,7 +129,7 @@ impl GenerationsList {
|
|||
]
|
||||
}
|
||||
|
||||
/// Set the value of \p topic to the smaller of our value and the value in \p other.
|
||||
/// Set the value of `topic` to the smaller of our value and the value in `other`.
|
||||
pub fn set_min_from(&mut self, topic: topic_t, other: &Self) {
|
||||
if self.get(topic) > other.get(topic) {
|
||||
self.set(topic, other.get(topic));
|
||||
|
@ -456,11 +456,11 @@ impl topic_monitor_t {
|
|||
}
|
||||
|
||||
/// Given a list of input generations, attempt to update them to something newer.
|
||||
/// If \p gens is older, then just return those by reference, and directly return false (not
|
||||
/// If `gens` is older, then just return those by reference, and directly return false (not
|
||||
/// becoming the reader).
|
||||
/// If \p gens is current and there is not a reader, then do not update \p gens and return true,
|
||||
/// If `gens` is current and there is not a reader, then do not update `gens` and return true,
|
||||
/// indicating we should become the reader. Now it is our responsibility to wait on the
|
||||
/// semaphore and notify on a change via the condition variable. If \p gens is current, and
|
||||
/// semaphore and notify on a change via the condition variable. If `gens` is current, and
|
||||
/// there is already a reader, then wait until the reader notifies us and try again.
|
||||
fn try_update_gens_maybe_becoming_reader(&self, gens: &mut GenerationsList) -> bool {
|
||||
let mut become_reader = false;
|
||||
|
@ -547,11 +547,11 @@ impl topic_monitor_t {
|
|||
return gens;
|
||||
}
|
||||
|
||||
/// For each valid topic in \p gens, check to see if the current topic is larger than
|
||||
/// the value in \p gens.
|
||||
/// If \p wait is set, then wait if there are no changes; otherwise return immediately.
|
||||
/// For each valid topic in `gens`, check to see if the current topic is larger than
|
||||
/// the value in `gens`.
|
||||
/// If `wait` is set, then wait if there are no changes; otherwise return immediately.
|
||||
/// \return true if some topic changed, false if none did.
|
||||
/// On a true return, this updates the generation list \p gens.
|
||||
/// On a true return, this updates the generation list `gens`.
|
||||
pub fn check(&self, gens: &GenerationsList, wait: bool) -> bool {
|
||||
if !gens.any_valid() {
|
||||
return false;
|
||||
|
|
|
@ -148,7 +148,7 @@ impl<'a> IntoCharIter for CharsUtf32<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// \return true if \p prefix is a prefix of \p contents.
|
||||
/// \return true if `prefix` is a prefix of `contents`.
|
||||
fn iter_prefixes_iter<Prefix, Contents>(prefix: Prefix, mut contents: Contents) -> bool
|
||||
where
|
||||
Prefix: Iterator,
|
||||
|
|
|
@ -157,9 +157,9 @@ impl StringFuzzyMatch {
|
|||
matches!(self.typ, ContainType::substr | ContainType::subseq)
|
||||
}
|
||||
|
||||
/// Try creating a fuzzy match for \p string against \p match_against.
|
||||
/// \p string is something like "foo" and \p match_against is like "FooBar".
|
||||
/// If \p anchor_start is set, then only exact and prefix matches are permitted.
|
||||
/// Try creating a fuzzy match for `string` against `match_against`.
|
||||
/// `string` is something like "foo" and `match_against` is like "FooBar".
|
||||
/// If `anchor_start` is set, then only exact and prefix matches are permitted.
|
||||
pub fn try_create(
|
||||
string: &wstr,
|
||||
match_against: &wstr,
|
||||
|
@ -272,8 +272,8 @@ pub fn string_fuzzy_match_string(
|
|||
}
|
||||
|
||||
/// Implementation of wcs2string that accepts a callback.
|
||||
/// This invokes \p func with (const char*, size_t) pairs.
|
||||
/// If \p func returns false, it stops; otherwise it continues.
|
||||
/// This invokes `func` with (const char*, size_t) pairs.
|
||||
/// If `func` returns false, it stops; otherwise it continues.
|
||||
/// \return false if the callback returned false, otherwise true.
|
||||
pub fn wcs2string_callback(input: &wstr, mut func: impl FnMut(&[u8]) -> bool) -> bool {
|
||||
let mut state = zero_mbstate();
|
||||
|
@ -330,10 +330,10 @@ pub fn split_string(val: &wstr, sep: char) -> Vec<WString> {
|
|||
val.split(sep).map(wstr::to_owned).collect()
|
||||
}
|
||||
|
||||
/// Split a string by runs of any of the separator characters provided in \p seps.
|
||||
/// Note the delimiters are the characters in \p seps, not \p seps itself.
|
||||
/// \p seps may contain the NUL character.
|
||||
/// Do not output more than \p max_results results. If we are to output exactly that much,
|
||||
/// Split a string by runs of any of the separator characters provided in `seps`.
|
||||
/// Note the delimiters are the characters in `seps`, not `seps` itself.
|
||||
/// `seps` may contain the NUL character.
|
||||
/// Do not output more than `max_results` results. If we are to output exactly that much,
|
||||
/// the last output is the remainder of the input, including leading delimiters,
|
||||
/// except for the first. This is historical behavior.
|
||||
/// Example: split_string_tok(" a b c ", " ", 3) -> {"a", "b", " c "}
|
||||
|
@ -489,7 +489,7 @@ pub fn trim(input: WString, any_of: Option<&wstr>) -> WString {
|
|||
}
|
||||
|
||||
/// \return the number of escaping backslashes before a character.
|
||||
/// \p idx may be "one past the end."
|
||||
/// `idx` may be "one past the end."
|
||||
pub fn count_preceding_backslashes(text: &wstr, idx: usize) -> usize {
|
||||
assert!(idx <= text.len(), "Out of bounds");
|
||||
text.chars()
|
||||
|
|
|
@ -269,7 +269,7 @@ fn test_normalize_path() {
|
|||
assert_eq!(norm_path(L!("foo/././bar/.././baz")), "foo/baz");
|
||||
}
|
||||
|
||||
/// Given an input path \p path and a working directory \p wd, do a "normalizing join" in a way
|
||||
/// Given an input path `path` and a working directory `wd`, do a "normalizing join" in a way
|
||||
/// appropriate for cd. That is, return effectively wd + path while resolving leading ../s from
|
||||
/// path. The intent here is to allow 'cd' out of a directory which may no longer exist, without
|
||||
/// allowing 'cd' into a directory that may not exist; see #5341.
|
||||
|
@ -586,7 +586,7 @@ pub fn file_id_for_path_narrow(path: &CStr) -> FileId {
|
|||
}
|
||||
result
|
||||
}
|
||||
/// Given that \p cursor is a pointer into \p base, return the offset in characters.
|
||||
/// Given that `cursor` is a pointer into `base`, return the offset in characters.
|
||||
/// This emulates C pointer arithmetic:
|
||||
/// `wstr_offset_in(cursor, base)` is equivalent to C++ `cursor - base`.
|
||||
pub fn wstr_offset_in(cursor: &wstr, base: &wstr) -> usize {
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<Iter: Iterator<Item = char>> CharsIterator<Iter> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Parse the given \p src as an integer.
|
||||
/// Parse the given `src` as an integer.
|
||||
/// If mradix is not None, it is used as the radix; otherwise the radix is inferred:
|
||||
/// - Leading 0x or 0X means 16.
|
||||
/// - Leading 0 means 8.
|
||||
|
|
Loading…
Reference in New Issue
Block a user