1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # tests of integer overflow for field width and precision arguments
16 INT_MAX=$(getconf INT_MAX)
17 TOOBIG=$(( $INT_MAX * 10 ))
19 printf '[%*s]\n' "${TOOBIG}"
20 printf '[%*s]\n' "${TOOBIG}" X
22 printf -v VAR '[%*s]' "${TOOBIG}"
25 printf -v VAR '[%*s]' "${TOOBIG}" X
29 TOOBIG=9223372036854775825
31 printf '[%*s]\n' "${TOOBIG}"
32 printf '[%*s]\n' "${TOOBIG}" X
34 printf -v VAR '[%*s]' "${TOOBIG}"
37 printf -v VAR '[%*s]' "${TOOBIG}" X
41 TOOBIG=$(( $INT_MAX * 10 ))
43 printf '[%.*s]\n' "${TOOBIG}"
44 printf '[%.*s]\n' "${TOOBIG}" X
46 printf -v VAR '[%.*s]' "${TOOBIG}"
49 printf -v VAR '[%.*s]' "${TOOBIG}" X
53 TOOBIG=9223372036854775825
55 printf '[%.*s]\n' "${TOOBIG}"
56 printf '[%.*s]\n' "${TOOBIG}" X
58 printf -v VAR '[%.*s]' "${TOOBIG}"
61 printf -v VAR '[%.*s]' "${TOOBIG}" X
65 # out of range inline precisions
67 # can't test %s, too many varying implementations
68 #printf "%.${TOOBIG}s\n" XY
69 printf -v VAR "%.${TOOBIG}s\n" XY
71 printf "%.${TOOBIG}Q\n" XY