mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
[string] Be explicit about nextstr() type
This commit is contained in:
parent
ca897807eb
commit
88e6930b57
1 changed files with 11 additions and 11 deletions
|
@ -502,7 +502,7 @@ static int string_escape(parser_t &parser, io_streams_t &streams, int argc, wcha
|
||||||
|
|
||||||
int nesc = 0;
|
int nesc = 0;
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto arg = aiter.nextstr()) {
|
while (const wcstring *arg = aiter.nextstr()) {
|
||||||
streams.out.append(escape_string(*arg, flags, opts.escape_style));
|
streams.out.append(escape_string(*arg, flags, opts.escape_style));
|
||||||
streams.out.append(L'\n');
|
streams.out.append(L'\n');
|
||||||
nesc++;
|
nesc++;
|
||||||
|
@ -524,7 +524,7 @@ static int string_unescape(parser_t &parser, io_streams_t &streams, int argc, wc
|
||||||
if (retval != STATUS_CMD_OK) return retval;
|
if (retval != STATUS_CMD_OK) return retval;
|
||||||
|
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto arg = aiter.nextstr()) {
|
while (const wcstring *arg = aiter.nextstr()) {
|
||||||
wcstring result;
|
wcstring result;
|
||||||
if (unescape_string(*arg, &result, flags, opts.escape_style)) {
|
if (unescape_string(*arg, &result, flags, opts.escape_style)) {
|
||||||
streams.out.append(result);
|
streams.out.append(result);
|
||||||
|
@ -547,7 +547,7 @@ static int string_join(parser_t &parser, io_streams_t &streams, int argc, wchar_
|
||||||
const wchar_t *sep = opts.arg1;
|
const wchar_t *sep = opts.arg1;
|
||||||
int nargs = 0;
|
int nargs = 0;
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto arg = aiter.nextstr()) {
|
while (const wcstring *arg = aiter.nextstr()) {
|
||||||
if (!opts.quiet) {
|
if (!opts.quiet) {
|
||||||
if (nargs > 0) {
|
if (nargs > 0) {
|
||||||
streams.out.append(sep);
|
streams.out.append(sep);
|
||||||
|
@ -572,7 +572,7 @@ static int string_length(parser_t &parser, io_streams_t &streams, int argc, wcha
|
||||||
|
|
||||||
int nnonempty = 0;
|
int nnonempty = 0;
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto arg = aiter.nextstr()) {
|
while (const wcstring *arg = aiter.nextstr()) {
|
||||||
size_t n = arg->length();
|
size_t n = arg->length();
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
nnonempty++;
|
nnonempty++;
|
||||||
|
@ -849,7 +849,7 @@ static int string_match(parser_t &parser, io_streams_t &streams, int argc, wchar
|
||||||
}
|
}
|
||||||
|
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto arg = aiter.nextstr()) {
|
while (const wcstring *arg = aiter.nextstr()) {
|
||||||
if (!matcher->report_matches(*arg)) {
|
if (!matcher->report_matches(*arg)) {
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1030,7 @@ static int string_replace(parser_t &parser, io_streams_t &streams, int argc, wch
|
||||||
}
|
}
|
||||||
|
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto arg = aiter.nextstr()) {
|
while (const wcstring *arg = aiter.nextstr()) {
|
||||||
if (!replacer->replace_matches(*arg)) return STATUS_INVALID_ARGS;
|
if (!replacer->replace_matches(*arg)) return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1053,7 +1053,7 @@ static int string_split(parser_t &parser, io_streams_t &streams, int argc, wchar
|
||||||
wcstring_list_t splits;
|
wcstring_list_t splits;
|
||||||
size_t arg_count = 0;
|
size_t arg_count = 0;
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto arg = aiter.nextstr()) {
|
while (const wcstring *arg = aiter.nextstr()) {
|
||||||
if (opts.right) {
|
if (opts.right) {
|
||||||
split_about(arg->rbegin(), arg->rend(), sep.rbegin(), sep.rend(), &splits, opts.max, opts.no_empty);
|
split_about(arg->rbegin(), arg->rend(), sep.rbegin(), sep.rend(), &splits, opts.max, opts.no_empty);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1118,7 +1118,7 @@ static int string_repeat(parser_t &parser, io_streams_t &streams, int argc, wcha
|
||||||
bool is_empty = true;
|
bool is_empty = true;
|
||||||
|
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
if (auto word = aiter.nextstr()) {
|
if (const wcstring *word = aiter.nextstr()) {
|
||||||
const bool limit_repeat =
|
const bool limit_repeat =
|
||||||
(opts.max > 0 && word->length() * opts.count > (size_t)opts.max) || !opts.count;
|
(opts.max > 0 && word->length() * opts.count > (size_t)opts.max) || !opts.count;
|
||||||
const wcstring repeated =
|
const wcstring repeated =
|
||||||
|
@ -1146,7 +1146,7 @@ static int string_sub(parser_t &parser, io_streams_t &streams, int argc, wchar_t
|
||||||
|
|
||||||
int nsub = 0;
|
int nsub = 0;
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto s = aiter.nextstr()) {
|
while (const wcstring *s = aiter.nextstr()) {
|
||||||
typedef wcstring::size_type size_type;
|
typedef wcstring::size_type size_type;
|
||||||
size_type pos = 0;
|
size_type pos = 0;
|
||||||
size_type count = wcstring::npos;
|
size_type count = wcstring::npos;
|
||||||
|
@ -1194,7 +1194,7 @@ static int string_trim(parser_t &parser, io_streams_t &streams, int argc, wchar_
|
||||||
size_t ntrim = 0;
|
size_t ntrim = 0;
|
||||||
|
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto arg = aiter.nextstr()) {
|
while (const wcstring *arg = aiter.nextstr()) {
|
||||||
// Begin and end are respectively the first character to keep on the left, and first
|
// Begin and end are respectively the first character to keep on the left, and first
|
||||||
// character to trim on the right. The length is thus end - start.
|
// character to trim on the right. The length is thus end - start.
|
||||||
size_t begin = 0, end = arg->size();
|
size_t begin = 0, end = arg->size();
|
||||||
|
@ -1227,7 +1227,7 @@ static int string_transform(parser_t &parser, io_streams_t &streams, int argc, w
|
||||||
|
|
||||||
int n_transformed = 0;
|
int n_transformed = 0;
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (auto arg = aiter.nextstr()) {
|
while (const wcstring *arg = aiter.nextstr()) {
|
||||||
wcstring transformed(*arg);
|
wcstring transformed(*arg);
|
||||||
std::transform(transformed.begin(), transformed.end(), transformed.begin(), func);
|
std::transform(transformed.begin(), transformed.end(), transformed.begin(), func);
|
||||||
if (transformed != *arg) n_transformed++;
|
if (transformed != *arg) n_transformed++;
|
||||||
|
|
Loading…
Reference in a new issue