| 4120 | or zero if it cannot be calculated. */ |
| 4121 | |
| 4122 | static int |
| 4123 | long_time_expected_width (void) |
| 4124 | { |
| 4125 | static int width = -1; |
| 4126 | |
| 4127 | if (width < 0) |
| 4128 | { |
| 4129 | time_t epoch = 0; |
| 4130 | struct tm tm; |
| 4131 | char buf[TIME_STAMP_LEN_MAXIMUM + 1]; |
| 4132 | |
| 4133 | /* In case you're wondering if localtime_rz can fail with an input time_t |
| 4134 | value of 0, let's just say it's very unlikely, but not inconceivable. |
| 4135 | The TZ environment variable would have to specify a time zone that |
| 4136 | is 2**31-1900 years or more ahead of UTC. This could happen only on |
| 4137 | a 64-bit system that blindly accepts e.g., TZ=UTC+20000000000000. |
| 4138 | However, this is not possible with Solaris 10 or glibc-2.3.5, since |
| 4139 | their implementations limit the offset to 167:59 and 24:00, resp. */ |
| 4140 | if (localtime_rz (localtz, &epoch, &tm)) |
| 4141 | { |
| 4142 | ptrdiff_t len = align_nstrftime (buf, sizeof buf, false, |
| 4143 | &tm, localtz, 0); |
| 4144 | if (len > 0) |
| 4145 | width = mbsnwidth (buf, len, MBSWIDTH_FLAGS); |
| 4146 | } |
| 4147 | |
| 4148 | if (width < 0) |
| 4149 | width = 0; |
| 4150 | } |
| 4151 | |
| 4152 | return width; |
| 4153 | } |
| 4154 | |
| 4155 | /* Print the user or group name NAME, with numeric id ID, using a |
| 4156 | print width of WIDTH columns. */ |
no test coverage detected