case 'l': iv = va_arg(*args, long); break;
case 'V': iv = va_arg(*args, IV); break;
default: iv = va_arg(*args, int); break;
+ case 'q':
#ifdef HAS_QUAD
- case 'q': iv = va_arg(*args, Quad_t); break;
+ iv = va_arg(*args, Quad_t); break;
+#else
+ goto unknown;
#endif
}
}
case 'l': iv = (long)tiv; break;
case 'V':
default: iv = tiv; break;
+ case 'q':
#ifdef HAS_QUAD
- case 'q': iv = (Quad_t)tiv; break;
+ iv = (Quad_t)tiv; break;
+#else
+ goto unknown;
#endif
}
}
case 'l': uv = va_arg(*args, unsigned long); break;
case 'V': uv = va_arg(*args, UV); break;
default: uv = va_arg(*args, unsigned); break;
+ case 'q':
#ifdef HAS_QUAD
- case 'q': uv = va_arg(*args, Uquad_t); break;
+ uv = va_arg(*args, Uquad_t); break;
+#else
+ goto unknown;
#endif
}
}
case 'l': uv = (unsigned long)tuv; break;
case 'V':
default: uv = tuv; break;
+ case 'q':
#ifdef HAS_QUAD
- case 'q': uv = (Uquad_t)tuv; break;
+ uv = (Uquad_t)tuv; break;
+#else
+ goto unknown;
#endif
}
}
default: *(va_arg(*args, int*)) = i; break;
case 'l': *(va_arg(*args, long*)) = i; break;
case 'V': *(va_arg(*args, IV*)) = i; break;
+ case 'q':
#ifdef HAS_QUAD
- case 'q': *(va_arg(*args, Quad_t*)) = i; break;
+ *(va_arg(*args, Quad_t*)) = i; break;
+#else
+ goto unknown;
#endif
}
}
require './test.pl';
}
-plan tests => 1295;
+plan tests => 1319;
+
+use strict;
+use Config;
is(
sprintf("%.40g ",0.01),
eval { my $f = sprintf("%f", $n); };
is $@, "", "sprintf(\"%f\", $n)";
}
+
+# test %ll formats with and without HAS_QUAD
+eval { my $q = pack "q", 0 };
+my $Q = $@ eq '';
+
+my @tests = (
+ [ '%lld' => '%d', [qw( 4294967296 -100000000000000 )] ],
+ [ '%lli' => '%i', [qw( 4294967296 -100000000000000 )] ],
+ [ '%llu' => '%u', [qw( 4294967296 100000000000000 )] ],
+ [ '%Ld' => '%d', [qw( 4294967296 -100000000000000 )] ],
+ [ '%Li' => '%i', [qw( 4294967296 -100000000000000 )] ],
+ [ '%Lu' => '%u', [qw( 4294967296 100000000000000 )] ],
+);
+
+for my $t (@tests) {
+ my($fmt, $conv) = @$t;
+ for my $num (@{$t->[2]}) {
+ my $w; local $SIG{__WARN__} = sub { $w = shift };
+ is(sprintf($fmt, $num), $Q ? $num : $fmt, "quad: $fmt -> $num");
+ like($w, $Q ? '' : qr/Invalid conversion in sprintf: "$conv"/, "warning: $fmt");
+ }
+}
+