BLI_string: add BLI_snprintf_rlen
authorCampbell Barton <ideasman42@gmail.com>
Tue, 21 Apr 2015 19:37:22 +0000 (05:37 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 21 Apr 2015 19:37:22 +0000 (05:37 +1000)
use when the length of the destination string is needed.

13 files changed:
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/unit.c
source/blender/blenlib/BLI_string.h
source/blender/blenlib/intern/string.c
source/blender/blenlib/intern/timecode.c
source/blender/editors/interface/interface.c
source/blender/editors/screen/area.c
source/blender/editors/space_nla/nla_draw.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_walk.c

index 535dcd6ba4da9d8acc25545caf05fa04c7dd5424..f370570750f3370378d0c2a9ab99829e3998287f 100644 (file)
@@ -4640,7 +4640,7 @@ static size_t sequencer_rna_path_prefix(char str[SEQ_RNAPATH_MAXSTR], const char
        char name_esc[SEQ_NAME_MAXSTR * 2];
 
        BLI_strescape(name_esc, name, sizeof(name_esc));
-       return BLI_snprintf(str, SEQ_RNAPATH_MAXSTR, "sequence_editor.sequences_all[\"%s\"]", name_esc);
+       return BLI_snprintf_rlen(str, SEQ_RNAPATH_MAXSTR, "sequence_editor.sequences_all[\"%s\"]", name_esc);
 }
 
 /* XXX - hackish function needed for transforming strips! TODO - have some better solution */
index 5a2c77b56198f374ce4c653286078d0f1197633d..0d83695d2f1066a6d7340d15086ac7ea773dcd24 100644 (file)
@@ -370,12 +370,7 @@ static size_t unit_as_string(char *str, int len_max, double value, int prec, bUn
        value_conv = value / unit->scalar;
 
        /* Convert to a string */
-       {
-               len = BLI_snprintf(str, len_max, "%.*f", prec, value_conv);
-
-               if (len >= len_max)
-                       len = len_max;
-       }
+       len = BLI_snprintf_rlen(str, len_max, "%.*f", prec, value_conv);
 
        /* Add unit prefix and strip zeros */
 
index c4853e37398bb5b77e4a64a8f9a1f778fbe8101f..e6c1cc8b4b616aeda675e29fdfa46ed6465ddcfb 100644 (file)
@@ -59,8 +59,10 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict
 char *BLI_replacestrN(const char *__restrict str, const char *__restrict substr_old, const char *__restrict substr_new) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC;
 
 size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...) ATTR_NONNULL(1, 3) ATTR_PRINTF_FORMAT(3, 4);
+size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...) ATTR_NONNULL(1, 3) ATTR_PRINTF_FORMAT(3, 4);
 
 size_t BLI_vsnprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, va_list arg) ATTR_PRINTF_FORMAT(3, 0);
+size_t BLI_vsnprintf_rlen(char *__restrict buffer, size_t maxncpy, const char *__restrict format, va_list arg) ATTR_PRINTF_FORMAT(3, 0);
 
 char *BLI_sprintfN(const char *__restrict format, ...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1, 2);
 
index cc5a90dbc39e01b86f4e82e6dcf1eda5e56f221b..e41e52a7c6e59f7d7c340a206bf54a7855b7aae5 100644 (file)
@@ -230,6 +230,30 @@ size_t BLI_vsnprintf(char *__restrict buffer, size_t maxncpy, const char *__rest
        return n;
 }
 
+/**
+ * A version of #BLI_vsnprintf that returns ``strlen(buffer)``
+ */
+size_t BLI_vsnprintf_rlen(char *__restrict buffer, size_t maxncpy, const char *__restrict format, va_list arg)
+{
+       size_t n;
+
+       BLI_assert(buffer != NULL);
+       BLI_assert(maxncpy > 0);
+       BLI_assert(format != NULL);
+
+       n = (size_t)vsnprintf(buffer, maxncpy, format, arg);
+
+       if (n != -1 && n < maxncpy) {
+               /* pass */
+       }
+       else {
+               n = maxncpy - 1;
+       }
+       buffer[n] = '\0';
+
+       return n;
+}
+
 /**
  * Portable replacement for #snprintf
  */
@@ -249,6 +273,25 @@ size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict
        return n;
 }
 
+/**
+ * A version of #BLI_snprintf that returns ``strlen(dst)``
+ */
+size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...)
+{
+       size_t n;
+       va_list arg;
+
+#ifdef DEBUG_STRSIZE
+       memset(dst, 0xff, sizeof(*dst) * maxncpy);
+#endif
+
+       va_start(arg, format);
+       n = BLI_vsnprintf_rlen(dst, maxncpy, format, arg);
+       va_end(arg);
+
+       return n;
+}
+
 /**
  * Print formatted string into a newly #MEM_mallocN'd string
  * and return it.
index 0c8834008b6fa83d0354167092e5563d50a6b1f2..7b98d7830eeda49dcabec77027e2e478751fbd41 100644 (file)
@@ -113,22 +113,22 @@ size_t BLI_timecode_string_from_time(
                        if (power <= 0) {
                                /* include "frames" in display */
                                if (hours) {
-                                       rlen = BLI_snprintf(str, maxncpy, "%s%02d:%02d:%02d+%02d", neg, hours, minutes, seconds, frames);
+                                       rlen = BLI_snprintf_rlen(str, maxncpy, "%s%02d:%02d:%02d+%02d", neg, hours, minutes, seconds, frames);
                                }
                                else if (minutes) {
-                                       rlen = BLI_snprintf(str, maxncpy, "%s%02d:%02d+%02d", neg, minutes, seconds, frames);
+                                       rlen = BLI_snprintf_rlen(str, maxncpy, "%s%02d:%02d+%02d", neg, minutes, seconds, frames);
                                }
                                else {
-                                       rlen = BLI_snprintf(str, maxncpy, "%s%d+%02d", neg, seconds, frames);
+                                       rlen = BLI_snprintf_rlen(str, maxncpy, "%s%d+%02d", neg, seconds, frames);
                                }
                        }
                        else {
                                /* don't include 'frames' in display */
                                if (hours) {
-                                       rlen = BLI_snprintf(str, maxncpy, "%s%02d:%02d:%02d", neg, hours, minutes, seconds);
+                                       rlen = BLI_snprintf_rlen(str, maxncpy, "%s%02d:%02d:%02d", neg, hours, minutes, seconds);
                                }
                                else {
-                                       rlen = BLI_snprintf(str, maxncpy, "%s%02d:%02d", neg, minutes, seconds);
+                                       rlen = BLI_snprintf_rlen(str, maxncpy, "%s%02d:%02d", neg, minutes, seconds);
                                }
                        }
                        break;
@@ -137,10 +137,10 @@ size_t BLI_timecode_string_from_time(
                {
                        /* reduced SMPTE format that always shows minutes, seconds, frames. Hours only shown as needed. */
                        if (hours) {
-                               rlen = BLI_snprintf(str, maxncpy, "%s%02d:%02d:%02d:%02d", neg, hours, minutes, seconds, frames);
+                               rlen = BLI_snprintf_rlen(str, maxncpy, "%s%02d:%02d:%02d:%02d", neg, hours, minutes, seconds, frames);
                        }
                        else {
-                               rlen = BLI_snprintf(str, maxncpy, "%s%02d:%02d:%02d", neg, minutes, seconds, frames);
+                               rlen = BLI_snprintf_rlen(str, maxncpy, "%s%02d:%02d:%02d", neg, minutes, seconds, frames);
                        }
                        break;
                }
@@ -156,10 +156,10 @@ size_t BLI_timecode_string_from_time(
                        const int s_pad = ms_dp + 3;
 
                        if (hours) {
-                               rlen = BLI_snprintf(str, maxncpy, "%s%02d:%02d:%0*.*f", neg, hours, minutes, s_pad, ms_dp, time);
+                               rlen = BLI_snprintf_rlen(str, maxncpy, "%s%02d:%02d:%0*.*f", neg, hours, minutes, s_pad, ms_dp, time);
                        }
                        else {
-                               rlen = BLI_snprintf(str, maxncpy, "%s%02d:%0*.*f", neg, minutes, s_pad,  ms_dp, time);
+                               rlen = BLI_snprintf_rlen(str, maxncpy, "%s%02d:%0*.*f", neg, minutes, s_pad,  ms_dp, time);
                        }
                        break;
                }
@@ -168,10 +168,10 @@ size_t BLI_timecode_string_from_time(
                        /* only show the original seconds display */
                        /* round to whole numbers if power is >= 1 (i.e. scale is coarse) */
                        if (power <= 0) {
-                               rlen = BLI_snprintf(str, maxncpy, "%.*f", 1 - power, time_seconds);
+                               rlen = BLI_snprintf_rlen(str, maxncpy, "%.*f", 1 - power, time_seconds);
                        }
                        else {
-                               rlen = BLI_snprintf(str, maxncpy, "%d", iroundf(time_seconds));
+                               rlen = BLI_snprintf_rlen(str, maxncpy, "%d", iroundf(time_seconds));
                        }
                        break;
                }
@@ -179,7 +179,7 @@ size_t BLI_timecode_string_from_time(
                default:
                {
                        /* full SMPTE format */
-                       rlen = BLI_snprintf(str, maxncpy, "%s%02d:%02d:%02d:%02d", neg, hours, minutes, seconds, frames);
+                       rlen = BLI_snprintf_rlen(str, maxncpy, "%s%02d:%02d:%02d:%02d", neg, hours, minutes, seconds, frames);
                        break;
                }
        }
@@ -208,10 +208,10 @@ size_t BLI_timecode_string_from_time_simple(
 
        /* round to whole numbers if power is >= 1 (i.e. scale is coarse) */
        if (power <= 0) {
-               rlen = BLI_snprintf(str, maxncpy, "%.*f", 1 - power, time_seconds);
+               rlen = BLI_snprintf_rlen(str, maxncpy, "%.*f", 1 - power, time_seconds);
        }
        else {
-               rlen = BLI_snprintf(str, maxncpy, "%d", iroundf(time_seconds));
+               rlen = BLI_snprintf_rlen(str, maxncpy, "%d", iroundf(time_seconds));
        }
 
        return rlen;
index 1e738668f9d7bc1eeb7000647eeef0142f441ebd..5c548d3afd53c35486dd7ee3b582b3ea10626ca6 100644 (file)
@@ -2765,11 +2765,11 @@ void ui_but_update(uiBut *but)
                                        }
                                        else {
                                                const int prec = ui_but_calc_float_precision(but, value);
-                                               slen += BLI_snprintf(but->drawstr + slen, sizeof(but->drawstr) - slen, "%.*f", prec, value);
+                                               slen += BLI_snprintf_rlen(but->drawstr + slen, sizeof(but->drawstr) - slen, "%.*f", prec, value);
                                        }
                                }
                                else {
-                                       slen += BLI_snprintf(but->drawstr + slen, sizeof(but->drawstr) - slen, "%d", (int)value);
+                                       slen += BLI_snprintf_rlen(but->drawstr + slen, sizeof(but->drawstr) - slen, "%d", (int)value);
                                }
 
                                if (but->rnaprop) {
index 4b0d1d02198d6b62722052b161d1281585c81212..c6de4e5df88c5eb9e3338ccbf3dbc31b14fae2a4 100644 (file)
@@ -2065,8 +2065,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
                        /* first line */
                        if (i == 0) {
                                bool do_newline = false;
-                               BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]);
-                               len = strlen(temp_str);
+                               len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]);
                                if (metadata_is_valid(ibuf, temp_str, 0, len)) {
                                        BLF_position(fontid, rect.xmin + (0.2f * U.widget_unit),
                                                     rect.ymax - factor * (1.5f * U.widget_unit - UI_UNIT_Y), 0.0f);
@@ -2074,8 +2073,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
                                        do_newline = true;
                                }
 
-                               BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]);
-                               len = strlen(temp_str);
+                               len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]);
                                if (metadata_is_valid(ibuf, temp_str, 1, len)) {
                                        line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
                                        BLF_position(fontid, rect.xmax - line_width - (0.2f * U.widget_unit),
@@ -2088,8 +2086,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
                                        ofs_y += (height + (0.2f * U.widget_unit));
                        }
                        else if (i == 1) {
-                               BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
-                               len = strlen(temp_str);
+                               len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
                                if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
                                        BLF_position(fontid, rect.xmin + (0.2f * U.widget_unit),
                                                     rect.ymax - factor * (1.5f * U.widget_unit - UI_UNIT_Y) - ofs_y, 0.0f);
@@ -2098,8 +2095,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
                                }
                        }
                        else {
-                               BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
-                               len = strlen(temp_str);
+                               len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
                                if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
                                        BLF_position(fontid, rect.xmax + (0.2f * U.widget_unit),
                                                     rect.ymax - factor * (1.5f * U.widget_unit - UI_UNIT_Y) - ofs_y, 0.0f);
@@ -2112,8 +2108,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
        else {
                int ofs_x = 0;
                for (i = 5; i < 10; i++) {
-                       BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]);
-                       len = strlen(temp_str);
+                       len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]);
                        if (metadata_is_valid(ibuf, temp_str, i, len)) {
                                const int line_height = height;
                                BLF_position(fontid, rect.xmin + (0.2f * U.widget_unit) + ofs_x,
index 52156a2394ec9edcde3ae47f8d556d93984b5dd5..4d37fcc9276c2b0659fef8f5a90bcf5fe025cdd2 100644 (file)
@@ -433,7 +433,7 @@ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, i
        
        /* just print the name and the range */
        if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
-               str_len = BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index);
+               str_len = BLI_snprintf_rlen(str, sizeof(str), "%d) Temp-Meta", index);
        }
        else {
                str_len = BLI_strncpy_rlen(str, strip->name, sizeof(str));
@@ -490,11 +490,11 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V
         *        while also preserving some accuracy, since we do use floats
         */
        /* start frame */
-       numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start);
+       numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.1f", strip->start);
        UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, numstr_len, col);
        
        /* end frame */
-       numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end);
+       numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.1f", strip->end);
        UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, numstr_len, col);
 }
 
index 62cb0bc73cd27e629d257a515da22cab374d0aa4..de90c417bdde62b3c2c2e13ea3595e725e69c57f 100644 (file)
@@ -203,12 +203,10 @@ void ED_node_tree_path_get_fixedbuf(SpaceNode *snode, char *value, int max_lengt
        value[0] = '\0';
        for (path = snode->treepath.first, i = 0; path; path = path->next, ++i) {
                if (i == 0) {
-                       BLI_strncpy(value, path->node_name, max_length);
-                       size = strlen(path->node_name);
+                       size = BLI_strncpy_rlen(value, path->node_name, max_length);
                }
                else {
-                       BLI_snprintf(value, max_length, "/%s", path->node_name);
-                       size = strlen(path->node_name) + 1;
+                       size = BLI_snprintf_rlen(value, max_length, "/%s", path->node_name);
                }
                max_length -= size;
                if (max_length <= 0)
index f07be97ff9f484110df3bf622f66de51168697b0..abe2e866a752a9ca76d6ebcfbc1054525bf6c75c 100644 (file)
@@ -425,12 +425,12 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla
                size_t numstr_len;
 
                if (direction == SEQ_LEFTHANDLE) {
-                       numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", seq->startdisp);
+                       numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", seq->startdisp);
                        x1 = rx1;
                        y1 -= 0.45f;
                }
                else {
-                       numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1);
+                       numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", seq->enddisp - 1);
                        x1 = x2 - handsize_clamped * 0.75f;
                        y1 = y2 + 0.05f;
                }
index f53fd967daa72e86fe537c2178e711dd05e0657c..24b814da44d88b42ca941cd57bb826e140e61fab 100644 (file)
@@ -3372,7 +3372,7 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
                                                                            unit->system, B_UNIT_LENGTH, do_split, false);
                                        }
                                        else {
-                                               numstr_len = BLI_snprintf(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2));
+                                               numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2));
                                        }
 
                                        view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col);
@@ -3449,7 +3449,7 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
 
                                                angle = angle_normalized_v3v3(no_a, no_b);
 
-                                               numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
+                                               numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
 
                                                view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col);
                                        }
@@ -3474,7 +3474,7 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
                                3, unit->system, B_UNIT_AREA, do_split, false);                      \
                }                                                                                \
                else {                                                                           \
-                       numstr_len = BLI_snprintf(numstr, sizeof(numstr), conv_float, area);         \
+                       numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, area);    \
                }                                                                                \
                view3d_cached_text_draw_add(vmid, numstr, numstr_len, 0, txt_flag, col);         \
        } (void)0
@@ -3592,7 +3592,7 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe
 
                                                angle = angle_v3v3v3(v1, v2, v3);
 
-                                               numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
+                                               numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.3f", is_rad ? angle : RAD2DEGF(angle));
                                                interp_v3_v3v3(fvec, vmid, v2_local, 0.8f);
                                                view3d_cached_text_draw_add(fvec, numstr, numstr_len, 0, txt_flag, col);
                                        }
@@ -3623,7 +3623,7 @@ static void draw_em_indices(BMEditMesh *em)
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
                BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
                        if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
-                               numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", i);
+                               numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
                                view3d_cached_text_draw_add(v->co, numstr, numstr_len, 0, txt_flag, col);
                        }
                        i++;
@@ -3635,7 +3635,7 @@ static void draw_em_indices(BMEditMesh *em)
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
                BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
                        if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
-                               numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", i);
+                               numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
                                mid_v3_v3v3(pos, e->v1->co, e->v2->co);
                                view3d_cached_text_draw_add(pos, numstr, numstr_len, 0, txt_flag, col);
                        }
@@ -3649,7 +3649,7 @@ static void draw_em_indices(BMEditMesh *em)
                BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
                        if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
                                BM_face_calc_center_mean(f, pos);
-                               numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", i);
+                               numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
                                view3d_cached_text_draw_add(pos, numstr, numstr_len, 0, txt_flag, col);
                        }
                        i++;
@@ -5397,15 +5397,15 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
                                                if (part->draw & PART_DRAW_NUM) {
                                                        if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
-                                                               numstr_len = BLI_snprintf(val_pos, sizeof(numstr), "%d:%.2f", a, pa_health);
+                                                               numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%d:%.2f", a, pa_health);
                                                        }
                                                        else {
-                                                               numstr_len = BLI_snprintf(val_pos, sizeof(numstr), "%d", a);
+                                                               numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%d", a);
                                                        }
                                                }
                                                else {
                                                        if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
-                                                               numstr_len = BLI_snprintf(val_pos, sizeof(numstr), "%.2f", pa_health);
+                                                               numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%.2f", pa_health);
                                                        }
                                                }
 
@@ -5646,7 +5646,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
                        for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
                                float vec_txt[3];
-                               numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%i", a);
+                               numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%i", a);
                                /* use worldspace because object matrix is already applied */
                                mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co);
                                view3d_cached_text_draw_add(vec_txt, numstr, numstr_len,
index a3dfd62ba6b99b10633752072f05f607fdbb01d2..469a7e63903aeb8f8a11efc5e9e6a7f34c916a18 100644 (file)
@@ -296,10 +296,10 @@ static void fly_update_header(bContext *C, FlyInfo *fly)
                                                   "Ctrl: free look, "
                                                   "X: Upright x axis (%s), "
                                                   "Z: Upright z axis (%s), "
-                                               "(+/- | Wheel): speed"),
+                                                  "(+/- | Wheel): speed"),
 
            WM_bool_as_string(fly->xlock != FLY_AXISLOCK_STATE_OFF),
-               WM_bool_as_string(fly->zlock != FLY_AXISLOCK_STATE_OFF));
+           WM_bool_as_string(fly->zlock != FLY_AXISLOCK_STATE_OFF));
 
        ED_area_headerprint(CTX_wm_area(C), header);
 #undef HEADER_LENGTH
index 11756e4fecac780ead0c8a830cb4cf282459df30..fb98f8b91a704bf733ce58a3a8e953133dff01d9 100644 (file)
@@ -344,7 +344,7 @@ static void walk_update_header(bContext *C, WalkInfo *walk)
        char header[HEADER_LENGTH];
 
        BLI_snprintf(header, HEADER_LENGTH, IFACE_("LMB/Return: confirm, Esc/RMB: cancel, "
-                                               "Tab: gravity (%s), "
+                                                  "Tab: gravity (%s), "
                                                   "WASD: move around, "
                                                   "Shift: fast, Alt: slow, "
                                                   "QE: up and down, MMB/Space: teleport, V: jump, "