diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-29 10:25:22 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-29 10:25:22 +0400 |
commit | 1777a69818610d4ed8a93f661a45219d97e7f6c5 (patch) | |
tree | bbfb0b35629e94ffd727f4a8b98fbf6cbebdaa36 /source/blender/blenlib/intern/string.c | |
parent | ab41583bc2be591c0af921b243158e43a94505d7 (diff) |
misc minor edits.
- pass string size to BLI_timestr() to avoid possible buffer overrun.
- quiet warning for mingw.
- include guards for windows utf conversion funcs.
- fix for mistage in edge-angle-selection check.
- some style cleanup.
Diffstat (limited to 'source/blender/blenlib/intern/string.c')
-rw-r--r-- | source/blender/blenlib/intern/string.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 906a3095f91..ba914944733 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -490,22 +490,20 @@ int BLI_natstrcmp(const char *s1, const char *s2) return 0; } -void BLI_timestr(double _time, char *str) +void BLI_timestr(double _time, char *str, size_t maxlen) { /* format 00:00:00.00 (hr:min:sec) string has to be 12 long */ int hr = ( (int) _time) / (60 * 60); int min = (((int) _time) / 60 ) % 60; - int sec = ( (int) (_time)) % 60; + int sec = ( (int) _time) % 60; int hun = ( (int) (_time * 100.0)) % 100; - + if (hr) { - sprintf(str, "%.2d:%.2d:%.2d.%.2d", hr, min, sec, hun); + BLI_snprintf(str, maxlen, "%.2d:%.2d:%.2d.%.2d", hr, min, sec, hun); } else { - sprintf(str, "%.2d:%.2d.%.2d", min, sec, hun); + BLI_snprintf(str, maxlen, "%.2d:%.2d.%.2d", min, sec, hun); } - - str[11] = 0; } /* determine the length of a fixed-size string */ |