mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Fixed indentation in builtin_printf.cpp
This commit is contained in:
parent
fb3a41d3ad
commit
fba984272a
1 changed files with 394 additions and 418 deletions
|
@ -203,7 +203,6 @@ print_esc_char (wchar_t c)
|
|||
besides the backslash.
|
||||
If OCTAL_0 is nonzero, octal escapes are of the form \0ooo, where o
|
||||
is an octal digit; otherwise they are of the form \ooo. */
|
||||
|
||||
static int print_esc (const wchar_t *escstart, bool octal_0)
|
||||
{
|
||||
const wchar_t *p = escstart + 1;
|
||||
|
@ -259,7 +258,6 @@ static int print_esc (const wchar_t *escstart, bool octal_0)
|
|||
|| (uni_value >= 0xd800 && uni_value <= 0xdfff))
|
||||
append_format(stderr_buffer, _(L"invalid universal character name \\%c%0*x"),
|
||||
esc_char, (esc_char == L'u' ? 4 : 8), uni_value);
|
||||
|
||||
append_format(stdout_buffer, L"%lc", uni_value);
|
||||
}
|
||||
else
|
||||
|
@ -316,7 +314,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
length_modifier = PRIdMAX;
|
||||
length_modifier_len = sizeof PRIdMAX - 2;
|
||||
break;
|
||||
|
||||
case L'a': case L'e': case L'f': case L'g':
|
||||
case L'A': case L'E': case L'F': case L'G':
|
||||
length_modifier = L"L";
|
||||
|
@ -331,7 +328,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
length_modifier_len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
p = new wchar_t[length + length_modifier_len + 2];
|
||||
q = static_cast<wchar_t*>(mempcpy (p, start, sizeof(wchar_t) * length));
|
||||
q = static_cast<wchar_t*>(mempcpy (q, length_modifier, sizeof(wchar_t) * length_modifier_len));
|
||||
|
@ -368,7 +364,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
case L'x':
|
||||
case L'X':
|
||||
{
|
||||
|
||||
uintmax_t arg = vstrtoumax (argument);
|
||||
if (!have_field_width)
|
||||
{
|
||||
|
@ -396,7 +391,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
case L'g':
|
||||
case L'G':
|
||||
{
|
||||
|
||||
long double arg = vstrtold (argument);
|
||||
if (!have_field_width)
|
||||
{
|
||||
|
@ -421,7 +415,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
else
|
||||
append_format(stdout_buffer, fmt.c_str(), field_width, *argument);
|
||||
break;
|
||||
|
||||
case L's':
|
||||
if (!have_field_width)
|
||||
{
|
||||
|
@ -432,7 +425,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (!have_precision)
|
||||
append_format(stdout_buffer, fmt.c_str(), field_width, argument);
|
||||
else
|
||||
|
@ -440,7 +432,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
free (p);
|
||||
}
|
||||
|
||||
|
@ -448,8 +439,7 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
arguments to any `%' directives.
|
||||
Return the number of elements of ARGV used. */
|
||||
|
||||
static int print_formatted (const wchar_t *format, int argc, wchar_t **argv)
|
||||
{
|
||||
static int print_formatted (const wchar_t *format, int argc, wchar_t **argv) {
|
||||
int save_argc = argc; /* Preserve original value. */
|
||||
const wchar_t *f; /* Pointer into `format'. */
|
||||
const wchar_t *direc_start; /* Start of % directive. */
|
||||
|
@ -460,25 +450,20 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
int precision = 0; /* Arg to second '*'. */
|
||||
wchar_t ok[UCHAR_MAX + 1]; /* ok['x'] is true if %x is allowed. */
|
||||
|
||||
for (f = format; *f != L'\0'; ++f)
|
||||
{
|
||||
switch (*f)
|
||||
{
|
||||
for (f = format; *f != L'\0'; ++f) {
|
||||
switch (*f) {
|
||||
case L'%':
|
||||
direc_start = f++;
|
||||
direc_length = 1;
|
||||
have_field_width = have_precision = false;
|
||||
if (*f == L'%')
|
||||
{
|
||||
if (*f == L'%') {
|
||||
append_format(stdout_buffer, L"%lc", L'%');
|
||||
break;
|
||||
}
|
||||
if (*f == L'b')
|
||||
{
|
||||
if (*f == L'b') {
|
||||
/* FIXME: Field width and precision are not supported
|
||||
for %b, even though POSIX requires it. */
|
||||
if (argc > 0)
|
||||
{
|
||||
if (argc > 0) {
|
||||
print_esc_string (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
|
@ -491,9 +476,8 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
ok['f'] = ok['F'] = ok['g'] = ok['G'] = ok['i'] = ok['o'] =
|
||||
ok['s'] = ok['u'] = ok['x'] = ok['X'] = 1;
|
||||
|
||||
for (;; f++, direc_length++)
|
||||
switch (*f)
|
||||
{
|
||||
for (;; f++, direc_length++) {
|
||||
switch (*f) {
|
||||
#if (__GLIBC__ == 2 && 2 <= __GLIBC_MINOR__) || 3 <= __GLIBC__
|
||||
case L'I':
|
||||
#endif
|
||||
|
@ -512,20 +496,18 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
default:
|
||||
goto no_more_flag_characters;
|
||||
}
|
||||
}
|
||||
no_more_flag_characters:;
|
||||
|
||||
if (*f == L'*')
|
||||
{
|
||||
if (*f == L'*') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0)
|
||||
{
|
||||
if (argc > 0) {
|
||||
intmax_t width = vstrtoimax (*argv);
|
||||
if (INT_MIN <= width && width <= INT_MAX)
|
||||
field_width = width;
|
||||
else
|
||||
append_format(stderr_buffer, _(L"invalid field width: %ls"),
|
||||
*argv);
|
||||
append_format(stderr_buffer, _(L"invalid field width: %ls"), *argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
|
@ -535,55 +517,50 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
have_field_width = true;
|
||||
}
|
||||
else {
|
||||
while (iswdigit(*f))
|
||||
{
|
||||
while (iswdigit(*f)) {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
}
|
||||
if (*f == L'.')
|
||||
{
|
||||
if (*f == L'.') {
|
||||
++f;
|
||||
++direc_length;
|
||||
ok['c'] = 0;
|
||||
if (*f == L'*')
|
||||
{
|
||||
if (*f == L'*') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0)
|
||||
{
|
||||
if (argc > 0) {
|
||||
intmax_t prec = vstrtoimax (*argv);
|
||||
if (prec < 0)
|
||||
{
|
||||
if (prec < 0) {
|
||||
/* A negative precision is taken as if the
|
||||
precision were omitted, so -1 is safe
|
||||
here even if prec < INT_MIN. */
|
||||
precision = -1;
|
||||
}
|
||||
else if (INT_MAX < prec)
|
||||
append_format(stderr_buffer, _(L"invalid precision: %ls"),
|
||||
*argv);
|
||||
else
|
||||
append_format(stderr_buffer, _(L"invalid precision: %ls"), *argv);
|
||||
else {
|
||||
precision = prec;
|
||||
}
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
else {
|
||||
precision = 0;
|
||||
}
|
||||
have_precision = true;
|
||||
}
|
||||
else
|
||||
while (iswdigit(*f))
|
||||
{
|
||||
else {
|
||||
while (iswdigit(*f)) {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (*f == L'l' || *f == L'L' || *f == L'h'
|
||||
|| *f == L'j' || *f == L't' || *f == L'z')
|
||||
++f;
|
||||
|
||||
{
|
||||
unsigned wchar_t conversion = *f;
|
||||
if (! ok[conversion])
|
||||
|
@ -606,7 +583,6 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion
|
|||
append_format (stdout_buffer, L"%lc", *f);
|
||||
}
|
||||
}
|
||||
|
||||
return save_argc - argc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue