Commit 4e834cf
fmt: handle negative width/prec when supplied as an argument
Negative width arguments now left align the way a minus-width in the
format string aligns. The minus in the format string overrides the sign
of the argument as in C.
Precision behavior is modified to include an error if the argument is
negative. This differs from a negative precision in a format string
which just terminates the format.
Additional checks for large magnitude widths and precisions are added to
make the runtime behavior (failure, but with different error messages),
more consistent between format string specified width/precision and
argument specified width/precision.
Fixes golang#11376
Change-Id: I8c7ed21088e9c18128a45d4c487c5ab9fafd13ef
Reviewed-on: https://go-review.googlesource.com/11405
Reviewed-by: Rob Pike <[email protected]>
Run-TryBot: Rob Pike <[email protected]>1 parent 2bcdb5a commit 4e834cf
2 files changed
Lines changed: 36 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
835 | 839 | | |
836 | 840 | | |
837 | 841 | | |
| |||
1158 | 1162 | | |
1159 | 1163 | | |
1160 | 1164 | | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
1161 | 1168 | | |
1162 | 1169 | | |
1163 | 1170 | | |
1164 | | - | |
1165 | 1171 | | |
1166 | 1172 | | |
1167 | 1173 | | |
| 1174 | + | |
| 1175 | + | |
1168 | 1176 | | |
| 1177 | + | |
| 1178 | + | |
1169 | 1179 | | |
1170 | 1180 | | |
1171 | 1181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
288 | 295 | | |
289 | 296 | | |
290 | 297 | | |
291 | 298 | | |
292 | 299 | | |
293 | 300 | | |
294 | | - | |
295 | | - | |
296 | | - | |
| 301 | + | |
297 | 302 | | |
298 | 303 | | |
299 | 304 | | |
| |||
1025 | 1030 | | |
1026 | 1031 | | |
1027 | 1032 | | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
1028 | 1037 | | |
1029 | 1038 | | |
1030 | 1039 | | |
| |||
1119 | 1128 | | |
1120 | 1129 | | |
1121 | 1130 | | |
| 1131 | + | |
1122 | 1132 | | |
1123 | 1133 | | |
1124 | 1134 | | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1125 | 1142 | | |
1126 | 1143 | | |
1127 | 1144 | | |
| |||
1140 | 1157 | | |
1141 | 1158 | | |
1142 | 1159 | | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
1143 | 1165 | | |
1144 | 1166 | | |
1145 | 1167 | | |
| |||
0 commit comments