if (format)
{
bool need_quoting_style = false;
- for (char const *p = format; (p = strchr (p, '%')); ++p)
+ for (char const *p = format; (p = strchr (p, '%'));
+ p += (p[1] == '%') + 1)
{
- if (p[1] == 'N' && (p == format || p[-1] != '%'))
+ if (p[1] == 'N')
{
need_quoting_style = true;
break;
# Check the behavior with invalid values of QUOTING_STYLE.
for style in '' 'abcdef'; do
- QUOTING_STYLE="$style" stat -c%N \' > out 2> err || fail=1
+ QUOTING_STYLE="$style" stat -c%%%N \' > out 2> err || fail=1
cat <<\EOF > exp-out || framework_failure_
-"'"
+%"'"
EOF
cat <<EOF > exp-err || framework_failure_
stat: ignoring invalid value of environment variable QUOTING_STYLE: '$style'
compare exp-err err || fail=1
# coreutils-9.10 and earlier would unnecessarily check QUOTING_STYLE in
# these cases.
- for format in '%%N' 'abc%%Ndef' 'abc%%Ndef%%N'; do
+ for format in '%%N' 'abc%%Ndef' 'abc%%Ndef%%N' '%%%%N'; do
QUOTING_STYLE="$style" stat -c"$format" \' > out 2> err || fail=1
printf "$format\n" > exp-out || framework_failure_
compare exp-out out || fail=1