From 169dd2a2b4f794bc1dcfafdd6051d947b5d14507 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 13 May 2023 17:38:48 +1000 Subject: [PATCH] Use UTF8 copy function to ensure valid UTF8 output --- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/anim_sys.c | 4 +-- source/blender/blenkernel/intern/attribute.cc | 7 +----- source/blender/blenkernel/intern/boids.c | 2 +- .../blender/blenkernel/intern/customdata.cc | 7 +++--- .../blender/blenkernel/intern/dynamicpaint.cc | 2 +- .../blender/blenkernel/intern/fcurve_driver.c | 3 ++- .../blenkernel/intern/gpencil_legacy.c | 2 +- .../intern/gpencil_modifier_legacy.c | 2 +- source/blender/blenkernel/intern/key.cc | 2 +- source/blender/blenkernel/intern/layer.cc | 9 ++----- source/blender/blenkernel/intern/lib_id.c | 2 +- source/blender/blenkernel/intern/modifier.cc | 3 ++- source/blender/blenkernel/intern/node.cc | 3 ++- source/blender/blenkernel/intern/shader_fx.c | 2 +- .../blenloader/intern/versioning_userdef.c | 3 ++- .../editors/animation/anim_channels_defines.c | 8 +++--- source/blender/editors/interface/interface.cc | 4 +-- source/blender/editors/object/object_add.cc | 3 ++- source/blender/editors/space_info/info_ops.c | 2 +- .../blender/editors/space_info/info_stats.cc | 25 ++++++++++--------- .../blender/editors/space_node/node_edit.cc | 4 ++- .../editors/space_node/node_templates.cc | 9 ++++--- .../editors/transform/transform_generics.c | 2 +- .../intern/MOD_gpencil_legacy_dash.c | 3 ++- .../intern/MOD_gpencil_legacy_time.c | 3 ++- .../composite/nodes/node_composite_mask.cc | 9 +++---- .../nodes/node_composite_moviedistortion.cc | 6 +++-- .../function/nodes/node_fn_boolean_math.cc | 3 ++- .../nodes/function/nodes/node_fn_compare.cc | 3 ++- .../function/nodes/node_fn_float_to_int.cc | 3 ++- source/blender/nodes/intern/node_util.cc | 9 ++++--- .../nodes/shader/nodes/node_shader_mix.cc | 2 +- 33 files changed, 79 insertions(+), 74 deletions(-) diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 8f4f54a1b6c..4a554d4add5 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -422,7 +422,7 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[]) /* make it selected, with default name */ agrp->flag = AGRP_SELECTED; - STRNCPY(agrp->name, name[0] ? name : DATA_("Group")); + STRNCPY_UTF8(agrp->name, name[0] ? name : DATA_("Group")); /* add to action, and validate */ BLI_addtail(&act->groups, agrp); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 81f812f5b2c..5464ea37736 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -131,8 +131,8 @@ KeyingSet *BKE_keyingset_add( /* allocate new KeyingSet */ ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet"); - STRNCPY(ks->idname, (idname) ? idname : (name) ? name : DATA_("KeyingSet")); - STRNCPY(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set")); + STRNCPY_UTF8(ks->idname, (idname) ? idname : (name) ? name : DATA_("KeyingSet")); + STRNCPY_UTF8(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set")); ks->flag = flag; ks->keyingflag = keyingflag; diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 2167ba9a7e3..51a55e46075 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -258,12 +258,7 @@ bool BKE_id_attribute_calc_unique_name(ID *id, const char *name, char *outname) /* Set default name if none specified. * NOTE: We only call IFACE_() if needed to avoid locale lookup overhead. */ - if (!name || name[0] == '\0') { - BLI_strncpy(outname, IFACE_("Attribute"), name_maxncpy); - } - else { - BLI_strncpy_utf8(outname, name, name_maxncpy); - } + BLI_strncpy_utf8(outname, (name && name[0]) ? name : IFACE_("Attribute"), name_maxncpy); const char *defname = ""; /* Dummy argument, never used as `name` is never zero length. */ return BLI_uniquename_cb(unique_name_cb, &data, defname, '.', outname, name_maxncpy); diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index a8724c7b110..a5b41f11661 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1617,7 +1617,7 @@ BoidRule *boid_new_rule(int type) rule->type = type; rule->flag |= BOIDRULE_IN_AIR | BOIDRULE_ON_LAND; - STRNCPY(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name)); + STRNCPY_UTF8(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name)); return rule; } diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index cacfe1a97eb..2e188eae1a0 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -30,6 +30,7 @@ #include "BLI_span.hh" #include "BLI_string.h" #include "BLI_string_ref.hh" +#include "BLI_string_utf8.h" #include "BLI_string_utils.h" #include "BLI_utildefines.h" @@ -4413,7 +4414,7 @@ void CustomData_set_layer_unique_name(CustomData *data, const int index) /* Set default name if none specified. Note we only call DATA_() when * needed to avoid overhead of locale lookups in the depsgraph. */ if (nlayer->name[0] == '\0') { - STRNCPY(nlayer->name, DATA_(typeInfo->defaultname)); + STRNCPY_UTF8(nlayer->name, DATA_(typeInfo->defaultname)); } const char *defname = ""; /* Dummy argument, never used as `name` is never zero length. */ @@ -4437,10 +4438,10 @@ void CustomData_validate_layer_name(const CustomData *data, * deleted, so assign the active layer to name */ index = CustomData_get_active_layer_index(data, type); - BLI_strncpy(outname, data->layers[index].name, MAX_CUSTOMDATA_LAYER_NAME); + BLI_strncpy_utf8(outname, data->layers[index].name, MAX_CUSTOMDATA_LAYER_NAME); } else { - BLI_strncpy(outname, name, MAX_CUSTOMDATA_LAYER_NAME); + BLI_strncpy_utf8(outname, name, MAX_CUSTOMDATA_LAYER_NAME); } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.cc b/source/blender/blenkernel/intern/dynamicpaint.cc index 44f139494af..c48a161cfa6 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.cc +++ b/source/blender/blenkernel/intern/dynamicpaint.cc @@ -405,7 +405,7 @@ static bool surface_duplicateNameExists(void *arg, const char *name) void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, const char *basename) { char name[64]; - STRNCPY(name, basename); /* in case basename is surface->name use a copy */ + STRNCPY_UTF8(name, basename); /* in case basename is surface->name use a copy */ BLI_uniquename_cb( surface_duplicateNameExists, surface, name, '.', surface->name, sizeof(surface->name)); } diff --git a/source/blender/blenkernel/intern/fcurve_driver.c b/source/blender/blenkernel/intern/fcurve_driver.c index d7705dc7e81..9b944ddce23 100644 --- a/source/blender/blenkernel/intern/fcurve_driver.c +++ b/source/blender/blenkernel/intern/fcurve_driver.c @@ -16,6 +16,7 @@ #include "BLI_expr_pylike_eval.h" #include "BLI_listbase.h" #include "BLI_math.h" +#include "BLI_string_utf8.h" #include "BLI_string_utils.h" #include "BLI_threads.h" #include "BLI_utildefines.h" @@ -955,7 +956,7 @@ DriverVar *driver_add_new_variable(ChannelDriver *driver) BLI_addtail(&driver->variables, dvar); /* Give the variable a 'unique' name. */ - strcpy(dvar->name, CTX_DATA_(BLT_I18NCONTEXT_ID_ACTION, "var")); + STRNCPY_UTF8(dvar->name, CTX_DATA_(BLT_I18NCONTEXT_ID_ACTION, "var")); BLI_uniquename(&driver->variables, dvar, CTX_DATA_(BLT_I18NCONTEXT_ID_ACTION, "var"), diff --git a/source/blender/blenkernel/intern/gpencil_legacy.c b/source/blender/blenkernel/intern/gpencil_legacy.c index 4ccd572a18f..a9c788d1cdb 100644 --- a/source/blender/blenkernel/intern/gpencil_legacy.c +++ b/source/blender/blenkernel/intern/gpencil_legacy.c @@ -675,7 +675,7 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, } /* auto-name */ - STRNCPY(gpl->info, DATA_(name)); + STRNCPY_UTF8(gpl->info, DATA_(name)); BLI_uniquename(&gpd->layers, gpl, (gpd->flag & GP_DATA_ANNOTATIONS) ? DATA_("Note") : DATA_("GP_Layer"), diff --git a/source/blender/blenkernel/intern/gpencil_modifier_legacy.c b/source/blender/blenkernel/intern/gpencil_modifier_legacy.c index 8c791eb4cc4..e94dc9e89b0 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier_legacy.c +++ b/source/blender/blenkernel/intern/gpencil_modifier_legacy.c @@ -356,7 +356,7 @@ GpencilModifierData *BKE_gpencil_modifier_new(int type) GpencilModifierData *md = MEM_callocN(mti->struct_size, mti->struct_name); /* NOTE: this name must be made unique later. */ - STRNCPY(md->name, DATA_(mti->name)); + STRNCPY_UTF8(md->name, DATA_(mti->name)); md->type = type; md->mode = eGpencilModifierMode_Realtime | eGpencilModifierMode_Render; diff --git a/source/blender/blenkernel/intern/key.cc b/source/blender/blenkernel/intern/key.cc index 167f44f4d18..cd9369a3e9a 100644 --- a/source/blender/blenkernel/intern/key.cc +++ b/source/blender/blenkernel/intern/key.cc @@ -1845,7 +1845,7 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name) } else { if (tot == 1) { - STRNCPY(kb->name, DATA_("Basis")); + STRNCPY_UTF8(kb->name, DATA_("Basis")); } else { SNPRINTF(kb->name, DATA_("Key %d"), tot - 1); diff --git a/source/blender/blenkernel/intern/layer.cc b/source/blender/blenkernel/intern/layer.cc index 19eb2d3ff47..b14b97a1c30 100644 --- a/source/blender/blenkernel/intern/layer.cc +++ b/source/blender/blenkernel/intern/layer.cc @@ -2522,7 +2522,7 @@ ViewLayerAOV *BKE_view_layer_add_aov(ViewLayer *view_layer) ViewLayerAOV *aov; aov = MEM_cnew(__func__); aov->type = AOV_TYPE_COLOR; - STRNCPY(aov->name, DATA_("AOV")); + STRNCPY_UTF8(aov->name, DATA_("AOV")); BLI_addtail(&view_layer->aovs, aov); viewlayer_aov_active_set(view_layer, aov); viewlayer_aov_make_name_unique(view_layer); @@ -2642,12 +2642,7 @@ ViewLayerLightgroup *BKE_view_layer_add_lightgroup(ViewLayer *view_layer, const { ViewLayerLightgroup *lightgroup; lightgroup = MEM_cnew(__func__); - if (name && name[0]) { - STRNCPY(lightgroup->name, name); - } - else { - STRNCPY(lightgroup->name, DATA_("Lightgroup")); - } + STRNCPY_UTF8(lightgroup->name, (name && name[0]) ? name : DATA_("Lightgroup")); BLI_addtail(&view_layer->lightgroups, lightgroup); viewlayer_lightgroup_active_set(view_layer, lightgroup); viewlayer_lightgroup_make_name_unique(view_layer, lightgroup); diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index ffaea9a9c42..458cc32cc0e 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -1603,7 +1603,7 @@ bool BKE_id_new_name_validate( if (name[0] == '\0') { /* Disallow empty names. */ - STRNCPY(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name)))); + STRNCPY_UTF8(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name)))); } else { /* disallow non utf8 chars, diff --git a/source/blender/blenkernel/intern/modifier.cc b/source/blender/blenkernel/intern/modifier.cc index 3b277f869f0..7acc2325c77 100644 --- a/source/blender/blenkernel/intern/modifier.cc +++ b/source/blender/blenkernel/intern/modifier.cc @@ -37,6 +37,7 @@ #include "BLI_path_util.h" #include "BLI_session_uuid.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_string_utils.h" #include "BLI_utildefines.h" @@ -137,7 +138,7 @@ static ModifierData *modifier_allocate_and_init(ModifierType type) ModifierData *md = static_cast(MEM_callocN(mti->structSize, mti->structName)); /* NOTE: this name must be made unique later. */ - STRNCPY(md->name, DATA_(mti->name)); + STRNCPY_UTF8(md->name, DATA_(mti->name)); md->type = type; md->mode = eModifierMode_Realtime | eModifierMode_Render; diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 44af925ec60..384018a1e86 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -40,6 +40,7 @@ #include "BLI_set.hh" #include "BLI_stack.hh" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_string_utils.h" #include "BLI_threads.h" #include "BLI_utildefines.h" @@ -1159,7 +1160,7 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node) * Data have their own translation option! * This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler * than adding "do_translate" flags to this func (and labelfunc() as well). */ - STRNCPY(node->name, DATA_(ntype->ui_name)); + STRNCPY_UTF8(node->name, DATA_(ntype->ui_name)); nodeUniqueName(ntree, node); /* Generally sockets should be added after the initialization, because the set of sockets might diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c index 26cc5f86194..6e52c31fac6 100644 --- a/source/blender/blenkernel/intern/shader_fx.c +++ b/source/blender/blenkernel/intern/shader_fx.c @@ -65,7 +65,7 @@ ShaderFxData *BKE_shaderfx_new(int type) ShaderFxData *fx = MEM_callocN(fxi->struct_size, fxi->struct_name); /* NOTE: this name must be made unique later. */ - STRNCPY(fx->name, DATA_(fxi->name)); + STRNCPY_UTF8(fx->name, DATA_(fxi->name)); fx->type = type; fx->mode = eShaderFxMode_Realtime | eShaderFxMode_Render; diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 0765c417718..d59b990414f 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -11,6 +11,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_utildefines.h" #include "DNA_anim_types.h" @@ -812,7 +813,7 @@ void blo_do_versions_userdef(UserDef *userdef) "Versioning user script path"); STRNCPY(script_dir->dir_path, userdef->pythondir_legacy); - STRNCPY(script_dir->name, DATA_("Untitled")); + STRNCPY_UTF8(script_dir->name, DATA_("Untitled")); BLI_addhead(&userdef->script_directories, script_dir); } } diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 1935e5ade82..5c0b6cee136 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -368,7 +368,7 @@ static void acf_generic_idblock_name(bAnimListElem *ale, char *name) /* just copy the name... */ if (id && name) { - BLI_strncpy(name, id->name + 2, ANIM_CHAN_NAME_SIZE); + BLI_strncpy_utf8(name, id->name + 2, ANIM_CHAN_NAME_SIZE); } } @@ -476,7 +476,7 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name) { if (name) { - BLI_strncpy(name, IFACE_("Summary"), ANIM_CHAN_NAME_SIZE); + BLI_strncpy_utf8(name, IFACE_("Summary"), ANIM_CHAN_NAME_SIZE); } } @@ -1178,7 +1178,7 @@ static void acf_nla_controls_backdrop(bAnimContext *ac, /* name for nla controls expander entries */ static void acf_nla_controls_name(bAnimListElem *UNUSED(ale), char *name) { - BLI_strncpy(name, IFACE_("NLA Strip Controls"), ANIM_CHAN_NAME_SIZE); + BLI_strncpy_utf8(name, IFACE_("NLA Strip Controls"), ANIM_CHAN_NAME_SIZE); } /* check if some setting exists for this channel */ @@ -1393,7 +1393,7 @@ static int acf_filldrivers_icon(bAnimListElem *UNUSED(ale)) static void acf_filldrivers_name(bAnimListElem *UNUSED(ale), char *name) { - BLI_strncpy(name, IFACE_("Drivers"), ANIM_CHAN_NAME_SIZE); + BLI_strncpy_utf8(name, IFACE_("Drivers"), ANIM_CHAN_NAME_SIZE); } /* check if some setting exists for this channel */ diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index ed82b08a629..a54b1318bb8 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -3937,11 +3937,11 @@ static void ui_but_update_ex(uiBut *but, const bool validate) (void)str; /* UNUSED */ } else { - STRNCPY(but->drawstr, IFACE_("Press a key")); + STRNCPY_UTF8(but->drawstr, IFACE_("Press a key")); } } else { - STRNCPY(but->drawstr, but->str); + STRNCPY_UTF8(but->drawstr, but->str); } break; diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 7ccea4f1d24..aa4a9b23474 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -36,6 +36,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_utildefines.h" #include "BLI_vector.hh" @@ -2021,7 +2022,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) BKE_nlatrack_add_strip(nlt, strip, is_liboverride); /* Auto-name the strip, and give the track an interesting name. */ - STRNCPY(nlt->name, DATA_("SoundTrack")); + STRNCPY_UTF8(nlt->name, DATA_("SoundTrack")); BKE_nlastrip_validate_name(adt, strip); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index d20975de302..5a8efc4bf01 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -249,7 +249,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( } if (count == 1) { - STRNCPY(title, IFACE_("Unpack 1 File")); + STRNCPY_UTF8(title, IFACE_("Unpack 1 File")); } else { SNPRINTF(title, IFACE_("Unpack %d Files"), count); diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index b9510699c88..19dbd60820f 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -25,6 +25,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_timecode.h" #include "BLI_utildefines.h" @@ -748,18 +749,18 @@ void ED_info_draw_stats( }; char labels[MAX_LABELS_COUNT][64]; - STRNCPY(labels[OBJ], IFACE_("Objects")); - STRNCPY(labels[VERTS], IFACE_("Vertices")); - STRNCPY(labels[EDGES], IFACE_("Edges")); - STRNCPY(labels[FACES], IFACE_("Faces")); - STRNCPY(labels[TRIS], IFACE_("Triangles")); - STRNCPY(labels[JOINTS], IFACE_("Joints")); - STRNCPY(labels[BONES], IFACE_("Bones")); - STRNCPY(labels[LAYERS], IFACE_("Layers")); - STRNCPY(labels[FRAMES], IFACE_("Frames")); - STRNCPY(labels[STROKES], IFACE_("Strokes")); - STRNCPY(labels[POINTS], IFACE_("Points")); - STRNCPY(labels[LIGHTS], IFACE_("Lights")); + STRNCPY_UTF8(labels[OBJ], IFACE_("Objects")); + STRNCPY_UTF8(labels[VERTS], IFACE_("Vertices")); + STRNCPY_UTF8(labels[EDGES], IFACE_("Edges")); + STRNCPY_UTF8(labels[FACES], IFACE_("Faces")); + STRNCPY_UTF8(labels[TRIS], IFACE_("Triangles")); + STRNCPY_UTF8(labels[JOINTS], IFACE_("Joints")); + STRNCPY_UTF8(labels[BONES], IFACE_("Bones")); + STRNCPY_UTF8(labels[LAYERS], IFACE_("Layers")); + STRNCPY_UTF8(labels[FRAMES], IFACE_("Frames")); + STRNCPY_UTF8(labels[STROKES], IFACE_("Strokes")); + STRNCPY_UTF8(labels[POINTS], IFACE_("Points")); + STRNCPY_UTF8(labels[LIGHTS], IFACE_("Lights")); int longest_label = 0; int i; diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 9f83339b716..878a69bd69a 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -31,6 +31,8 @@ #include "BKE_workspace.h" #include "BLI_set.hh" +#include "BLI_string_utf8.h" + #include "BLT_translation.h" #include "DEG_depsgraph.h" @@ -507,7 +509,7 @@ void ED_node_shader_default(const bContext *C, ID *id) ma->nodetree = ntreeCopyTree(bmain, ma_default->nodetree); ma->nodetree->owner_id = &ma->id; for (bNode *node_iter : ma->nodetree->all_nodes()) { - STRNCPY(node_iter->name, DATA_(node_iter->name)); + STRNCPY_UTF8(node_iter->name, DATA_(node_iter->name)); nodeUniqueName(ma->nodetree, node_iter); } diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index 77dbd17d385..42afb4ae794 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -16,6 +16,7 @@ #include "BLI_array.h" #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_vector.hh" #include "BLT_translation.h" @@ -474,14 +475,14 @@ static void ui_node_sock_name(const bNodeTree *ntree, name, UI_MAX_NAME_STR, "%s | %s", IFACE_(node_name), IFACE_(sock->link->fromsock->name)); } else { - BLI_strncpy(name, IFACE_(node_name), UI_MAX_NAME_STR); + BLI_strncpy_utf8(name, IFACE_(node_name), UI_MAX_NAME_STR); } } else if (sock->type == SOCK_SHADER) { - BLI_strncpy(name, IFACE_("None"), UI_MAX_NAME_STR); + BLI_strncpy_utf8(name, IFACE_("None"), UI_MAX_NAME_STR); } else { - BLI_strncpy(name, IFACE_("Default"), UI_MAX_NAME_STR); + BLI_strncpy_utf8(name, IFACE_("Default"), UI_MAX_NAME_STR); } } @@ -604,7 +605,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) icon = ICON_BLANK1; } else { - STRNCPY(name, IFACE_(item.node_name)); + STRNCPY_UTF8(name, IFACE_(item.node_name)); icon = ICON_NONE; } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index a90865f14d3..70806896743 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1327,7 +1327,7 @@ void calculatePropRatio(TransInfo *t) } if (pet_id) { - STRNCPY(t->proptext, IFACE_(pet_id)); + STRNCPY_UTF8(t->proptext, IFACE_(pet_id)); } } else { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c index fdcaa2384d9..e286175b145 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c @@ -11,6 +11,7 @@ #include "BLI_listbase.h" #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -57,7 +58,7 @@ static void initData(GpencilModifierData *md) DashGpencilModifierSegment *ds = DNA_struct_default_alloc(DashGpencilModifierSegment); ds->dmd = dmd; - STRNCPY(ds->name, DATA_("Segment")); + STRNCPY_UTF8(ds->name, DATA_("Segment")); dmd->segments = ds; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c index 4039c1692a0..26d34985a26 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c @@ -14,6 +14,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_utildefines.h" #include "BLT_translation.h" @@ -58,7 +59,7 @@ static void initData(GpencilModifierData *md) MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(TimeGpencilModifierData), modifier); TimeGpencilModifierSegment *ds = DNA_struct_default_alloc(TimeGpencilModifierSegment); ds->gpmd = gpmd; - STRNCPY(ds->name, DATA_("Segment")); + STRNCPY_UTF8(ds->name, DATA_("Segment")); gpmd->segments = ds; } diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.cc b/source/blender/nodes/composite/nodes/node_composite_mask.cc index fca6a6d3a5a..82c50dc59f8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_mask.cc @@ -7,6 +7,8 @@ #include "BLT_translation.h" +#include "BLI_string_utf8.h" + #include "DNA_mask_types.h" #include "UI_interface.h" @@ -44,12 +46,7 @@ static void node_mask_label(const bNodeTree * /*ntree*/, char *label, int label_maxncpy) { - if (node->id != nullptr) { - BLI_strncpy(label, node->id->name + 2, label_maxncpy); - } - else { - BLI_strncpy(label, IFACE_("Mask"), label_maxncpy); - } + BLI_strncpy_utf8(label, node->id ? node->id->name + 2 : IFACE_("Mask"), label_maxncpy); } static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr) diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc index 93cf6b14e09..8ccaaf455b7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc @@ -7,6 +7,8 @@ #include "BLT_translation.h" +#include "BLI_string_utf8.h" + #include "BKE_context.h" #include "BKE_lib_id.h" #include "BKE_tracking.h" @@ -31,10 +33,10 @@ static void cmp_node_moviedistortion_declare(NodeDeclarationBuilder &b) static void label(const bNodeTree * /*ntree*/, const bNode *node, char *label, int label_maxncpy) { if (node->custom1 == 0) { - BLI_strncpy(label, IFACE_("Undistortion"), label_maxncpy); + BLI_strncpy_utf8(label, IFACE_("Undistortion"), label_maxncpy); } else { - BLI_strncpy(label, IFACE_("Distortion"), label_maxncpy); + BLI_strncpy_utf8(label, IFACE_("Distortion"), label_maxncpy); } } diff --git a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc index 31133339799..74f551fa84a 100644 --- a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc +++ b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc @@ -2,6 +2,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "RNA_enum_types.h" @@ -44,7 +45,7 @@ static void node_label(const bNodeTree * /*tree*/, if (!enum_label) { name = "Unknown"; } - BLI_strncpy(label, IFACE_(name), label_maxncpy); + BLI_strncpy_utf8(label, IFACE_(name), label_maxncpy); } static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) diff --git a/source/blender/nodes/function/nodes/node_fn_compare.cc b/source/blender/nodes/function/nodes/node_fn_compare.cc index 01d3118a08e..91433446837 100644 --- a/source/blender/nodes/function/nodes/node_fn_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_compare.cc @@ -5,6 +5,7 @@ #include "BLI_listbase.h" #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "UI_interface.h" #include "UI_resources.h" @@ -184,7 +185,7 @@ static void node_label(const bNodeTree * /*tree*/, if (!enum_label) { name = "Unknown"; } - BLI_strncpy(label, IFACE_(name), label_maxncpy); + BLI_strncpy_utf8(label, IFACE_(name), label_maxncpy); } static float component_average(float3 a) diff --git a/source/blender/nodes/function/nodes/node_fn_float_to_int.cc b/source/blender/nodes/function/nodes/node_fn_float_to_int.cc index b1508135297..54c9644feff 100644 --- a/source/blender/nodes/function/nodes/node_fn_float_to_int.cc +++ b/source/blender/nodes/function/nodes/node_fn_float_to_int.cc @@ -4,6 +4,7 @@ #include "BLI_noise.hh" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "RNA_enum_types.h" @@ -36,7 +37,7 @@ static void node_label(const bNodeTree * /*tree*/, if (!enum_label) { name = "Unknown"; } - BLI_strncpy(label, IFACE_(name), label_maxncpy); + BLI_strncpy_utf8(label, IFACE_(name), label_maxncpy); } static const mf::MultiFunction *get_multi_function(const bNode &bnode) diff --git a/source/blender/nodes/intern/node_util.cc b/source/blender/nodes/intern/node_util.cc index 1072714c8be..b0268b5e986 100644 --- a/source/blender/nodes/intern/node_util.cc +++ b/source/blender/nodes/intern/node_util.cc @@ -13,6 +13,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_utildefines.h" #include "BLT_translation.h" @@ -185,7 +186,7 @@ void node_blend_label(const bNodeTree * /*ntree*/, if (!enum_label) { name = "Unknown"; } - BLI_strncpy(label, IFACE_(name), label_maxncpy); + BLI_strncpy_utf8(label, IFACE_(name), label_maxncpy); } void node_image_label(const bNodeTree * /*ntree*/, @@ -208,7 +209,7 @@ void node_math_label(const bNodeTree * /*ntree*/, if (!enum_label) { name = "Unknown"; } - BLI_strncpy(label, CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, name), label_maxncpy); + BLI_strncpy_utf8(label, CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, name), label_maxncpy); } void node_vector_math_label(const bNodeTree * /*ntree*/, @@ -221,7 +222,7 @@ void node_vector_math_label(const bNodeTree * /*ntree*/, if (!enum_label) { name = "Unknown"; } - BLI_strncpy(label, IFACE_(name), label_maxncpy); + BLI_strncpy_utf8(label, IFACE_(name), label_maxncpy); } void node_filter_label(const bNodeTree * /*ntree*/, @@ -234,7 +235,7 @@ void node_filter_label(const bNodeTree * /*ntree*/, if (!enum_label) { name = "Unknown"; } - BLI_strncpy(label, IFACE_(name), label_maxncpy); + BLI_strncpy_utf8(label, IFACE_(name), label_maxncpy); } void node_combsep_color_label(const ListBase *sockets, NodeCombSepColorMode mode) diff --git a/source/blender/nodes/shader/nodes/node_shader_mix.cc b/source/blender/nodes/shader/nodes/node_shader_mix.cc index d0251747ee9..5235475adad 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix.cc @@ -86,7 +86,7 @@ static void sh_node_mix_label(const bNodeTree * /*ntree*/, if (!enum_label) { name = "Unknown"; } - BLI_strncpy(label, IFACE_(name), label_maxncpy); + BLI_strncpy_utf8(label, IFACE_(name), label_maxncpy); } }