|
39 | 39 | // overload will have a dummy parameter whose type indicates whether or not it
|
40 | 40 | // should be preferred. Any other parameters required for SFINAE should have
|
41 | 41 | // default values provided.
|
42 |
| - |
43 |
| -// outside anonymous namespace, function reused |
44 |
| -void CopyBufferAndPad( |
45 |
| - char *dest, std::size_t destChars, const char *buffer, std::size_t len) { |
46 |
| - auto copyLen{std::min(len, destChars)}; |
47 |
| - std::memcpy(dest, buffer, copyLen); |
48 |
| - for (auto i{copyLen}; i < destChars; ++i) { |
49 |
| - dest[i] = ' '; |
50 |
| - } |
51 |
| -} |
52 |
| - |
53 | 42 | namespace {
|
54 | 43 | // Types for the dummy parameter indicating the priority of a given overload.
|
55 | 44 | // We will invoke our helper with an integer literal argument, so the overload
|
@@ -290,22 +279,29 @@ static void GetDateAndTime(Fortran::runtime::Terminator &terminator, char *date,
|
290 | 279 |
|
291 | 280 | static constexpr std::size_t buffSize{16};
|
292 | 281 | char buffer[buffSize];
|
293 |
| - |
| 282 | + auto copyBufferAndPad{ |
| 283 | + [&](char *dest, std::size_t destChars, std::size_t len) { |
| 284 | + auto copyLen{std::min(len, destChars)}; |
| 285 | + std::memcpy(dest, buffer, copyLen); |
| 286 | + for (auto i{copyLen}; i < destChars; ++i) { |
| 287 | + dest[i] = ' '; |
| 288 | + } |
| 289 | + }}; |
294 | 290 | if (date) {
|
295 | 291 | auto len = std::strftime(buffer, buffSize, "%Y%m%d", &localTime);
|
296 |
| - CopyBufferAndPad(date, dateChars, buffer, len); |
| 292 | + copyBufferAndPad(date, dateChars, len); |
297 | 293 | }
|
298 | 294 | if (time) {
|
299 | 295 | auto len{std::snprintf(buffer, buffSize, "%02d%02d%02d.%03jd",
|
300 | 296 | localTime.tm_hour, localTime.tm_min, localTime.tm_sec, ms)};
|
301 |
| - CopyBufferAndPad(time, timeChars, buffer, len); |
| 297 | + copyBufferAndPad(time, timeChars, len); |
302 | 298 | }
|
303 | 299 | if (zone) {
|
304 | 300 | // Note: this may leave the buffer empty on many platforms. Classic flang
|
305 | 301 | // has a much more complex way of doing this (see __io_timezone in classic
|
306 | 302 | // flang).
|
307 | 303 | auto len{std::strftime(buffer, buffSize, "%z", &localTime)};
|
308 |
| - CopyBufferAndPad(zone, zoneChars, buffer, len); |
| 304 | + copyBufferAndPad(zone, zoneChars, len); |
309 | 305 | }
|
310 | 306 | if (values) {
|
311 | 307 | auto typeCode{values->type().GetCategoryAndKind()};
|
|
0 commit comments