lib/expr’s printf implementation supports a "%t" format code to print a time. If
no format is provided for this, it would fallback to a default of "%?%K".
While working on #1998, one of my intermediate refactorings moved this string
literal into the actual call to strftime. At this point the compiler politely
interjected that neither "%?" nor "%K" are format strings understood by
strftime. So it seems this results in an invalid call to strftime.
To deal with this, we now throw an error when this function is called with no
format string instead of making an invalid strftime call.
- `edgepaint` accepts more standard `--` prefixed command line arguments and
rejects invalid options #1971
- improved detection of Lefty dependencies in the Autotools build system
+- libexpr rejects printing the time (`%t`) if no format is provided
### Fixed
case 'T':
if ((tm = *(Sflong_t*)vp) == -1)
tm = time(NULL);
- if (!txt)
- txt = "%?%K";
- s = fmtbuf(TIME_LEN);
- stm = localtime(&tm);
- strftime(s, TIME_LEN, txt, stm);
- *(char **)vp = s;
+ if (!txt) {
+ exerror("printf: no time format provided");
+ } else {
+ s = fmtbuf(TIME_LEN);
+ stm = localtime(&tm);
+ strftime(s, TIME_LEN, txt, stm);
+ *(char **)vp = s;
+ }
dp->fmt = 's';
dp->size = -1;
break;