HomeFreeBSD

sh: introduce a function to iterate over all aliases

Description

sh: introduce a function to iterate over all aliases

Currently the data structure holding alias information is opaque for
consumers outside alias.c and there is no way to iterate over all
aliases, which will become needed by a future commit.

The new function "iteralias" takes a null pointer to return the first
alias or an existing alias to return the next one, unless there is
no alias to return, in which case it returns a null pointer.

I slightly changed the static function hashalias so that it returns the
index into the array holding link heads, and not the link head directly.
In this form it's easier to use by iteralias and the slight adjustment
in the three existing callers doesn't look too bad.

Differential Revision: https://reviews.freebsd.org/D40619

Details

Provenance
pstefAuthored on Apr 29 2023, 8:23 PM
Differential Revision
D40619: sh: auto-complete functions and aliases
Parents
rG63b6e661d25c: sh: reindent a for loop in parser.c
Branches
Unknown
Tags
Unknown