wtv: Avoid needlessly calling gmtime twice with the same argument

Signed-off-by: Martin Storsjö <martin@martin.st>
lavf: Check the return value of strftime

If the buffer provided to strftime is too small, the buffer contents
are indeterminate - it does not guarantee actually null terminating
the buffer.

Signed-off-by: Martin Storsjö <martin@martin.st>
lavu: Provide fallbacks for gmtime_r and localtime_r

This allows writing most code as if they always are is available.

These are ok to use from other libraries even though it's not a
public header, since they only provide an inline declaration, and
doesn't add an actual dependency on lavu internals. (This can be
considered more a build system compatibility fallback than a
libavutil feature.)

Signed-off-by: Martin Storsjö <martin@martin.st>
Use gmtime_r instead of gmtime and localtime_r instead of localtime

gmtime isn't thread safe in general. In msvcrt (which lacks gmtime_r),
the buffer used by gmtime is thread specific though.

One call to localtime is left in avconv_opt.c, where thread safety
shouldn't matter (instead of making avconv depend on the libavutil
internal header).

Signed-off-by: Martin Storsjö <martin@martin.st>
drawtext: Remove the ifdef for localtime_r

If it isn't available in the system, we've got a fallback to
the normal localtime function, so normal code can assume it is
available as long as time_internal.h is included.

Signed-off-by: Martin Storsjö <martin@martin.st>
lavf: Implement ff_brktimegm using gmtime_r

While a standalone implementation is nice, we already depend on
gmtime and gmtime_r in a number of places.

Signed-off-by: Martin Storsjö <martin@martin.st>
Merge commit '851ace79a307bea54b44bd6f7ecd3b7861c28ec6'

* commit '851ace79a307bea54b44bd6f7ecd3b7861c28ec6':
  wtv: Avoid needlessly calling gmtime twice with the same argument

Conflicts:
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '9dcf2397219ca796f0fafce2a703770d6fd09920'

* commit '9dcf2397219ca796f0fafce2a703770d6fd09920':
  lavf: Check the return value of strftime

Conflicts:
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '3f8f1c6ff24ee858eb5b0bf47ef6d4605299a87e'

* commit '3f8f1c6ff24ee858eb5b0bf47ef6d4605299a87e':
  lavu: Provide fallbacks for gmtime_r and localtime_r

Conflicts:
	configure

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '82ee7d0dda0fec8cdb670f4e844bf5c2927ad9de'

* commit '82ee7d0dda0fec8cdb670f4e844bf5c2927ad9de':
  Use gmtime_r instead of gmtime and localtime_r instead of localtime

Conflicts:
	libavformat/mov.c
	libavformat/mxfenc.c
	libavformat/wtvdec.c
	libavutil/parseutils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '6b9b42cc5576e1819ad1e29d98940066fd14b2d6'

* commit '6b9b42cc5576e1819ad1e29d98940066fd14b2d6':
  drawtext: Remove the ifdef for localtime_r

Conflicts:
	libavfilter/vf_drawtext.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit 'ed6dad3737bf7bb2d5e9fa9511dfdb44806010e8'

* commit 'ed6dad3737bf7bb2d5e9fa9511dfdb44806010e8':
  lavf: Implement ff_brktimegm using gmtime_r

Merged-by: Michael Niedermayer <michaelni@gmx.at>
avformat/mlvdec: Check the return code from strftime()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
avformat/matroskadec: Check the return code from strftime()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
ffmpeg_opt: Check the return code from strftime()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>