Blender V4.3
string.c File Reference
#include <ctype.h>
#include <inttypes.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Macros

#define CASE_PAIR(value_src, value_dst)
 

Functions

String Duplicate/Copy
char * BLI_strdupn (const char *str, const size_t len)
 
char * BLI_strdup (const char *str)
 
char * BLI_strdup_null (const char *str)
 
char * BLI_strdupcat (const char *__restrict str1, const char *__restrict str2)
 
char * BLI_strncpy (char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy)
 
char * BLI_strncpy_ensure_pad (char *__restrict dst, const char *__restrict src, const char pad, size_t dst_maxncpy)
 
size_t BLI_strncpy_rlen (char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy)
 
String Append
char * BLI_strncat (char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy)
 
String Printing
size_t BLI_vsnprintf (char *__restrict dst, size_t dst_maxncpy, const char *__restrict format, va_list arg)
 
size_t BLI_vsnprintf_rlen (char *__restrict dst, size_t dst_maxncpy, const char *__restrict format, va_list arg)
 
size_t BLI_snprintf (char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...)
 
size_t BLI_snprintf_rlen (char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...)
 
char * BLI_sprintfN_with_buffer (char *fixed_buf, size_t fixed_buf_size, size_t *result_len, const char *__restrict format,...)
 
char * BLI_vsprintfN_with_buffer (char *fixed_buf, size_t fixed_buf_size, size_t *result_len, const char *__restrict format, va_list args)
 
char * BLI_sprintfN (const char *__restrict format,...)
 
char * BLI_vsprintfN (const char *__restrict format, va_list args)
 
String Escape/Un-Escape
size_t BLI_str_escape (char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy)
 
BLI_INLINE bool str_unescape_pair (char c_next, char *r_out)
 
size_t BLI_str_unescape_ex (char *__restrict dst, const char *__restrict src, const size_t src_maxncpy, const size_t dst_maxncpy, bool *r_is_complete)
 
size_t BLI_str_unescape (char *__restrict dst, const char *__restrict src, const size_t src_maxncpy)
 
const char * BLI_str_escape_find_quote (const char *str)
 
String Quote/Un-Quote
bool BLI_str_quoted_substr_range (const char *__restrict str, const char *__restrict prefix, int *__restrict r_start, int *__restrict r_end)
 
bool BLI_str_quoted_substr (const char *__restrict str, const char *__restrict prefix, char *result, size_t result_maxncpy)
 
String Comparison/Matching
int BLI_strcaseeq (const char *a, const char *b)
 
char * BLI_strcasestr (const char *s, const char *find)
 
int BLI_string_max_possible_word_count (const int str_len)
 
bool BLI_string_has_word_prefix (const char *haystack, const char *needle, size_t needle_len)
 
bool BLI_string_all_words_matched (const char *name, const char *str, int(*words)[2], const int words_len)
 
char * BLI_strncasestr (const char *s, const char *find, size_t len)
 
int BLI_strcasecmp (const char *s1, const char *s2)
 
int BLI_strncasecmp (const char *s1, const char *s2, size_t len)
 
static int left_number_strcmp (const char *s1, const char *s2, int *tiebreaker)
 
int BLI_strcasecmp_natural (const char *s1, const char *s2)
 
int BLI_strcmp_ignore_pad (const char *str1, const char *str2, const char pad)
 
String Comparison at Start/End
int BLI_str_index_in_array_n (const char *__restrict str, const char **__restrict str_array, const int str_array_len)
 
int BLI_str_index_in_array (const char *__restrict str, const char **__restrict str_array)
 
bool BLI_str_startswith (const char *__restrict str, const char *__restrict start)
 
bool BLI_strn_endswith (const char *__restrict str, const char *__restrict end, size_t str_len)
 
bool BLI_str_endswith (const char *__restrict str, const char *__restrict end)
 
String Length
size_t BLI_strnlen (const char *str, const size_t maxlen)
 
String Scanning
const char * BLI_strchr_or_end (const char *str, const char ch)
 
String Case Conversion
char BLI_tolower_ascii (const char c)
 
char BLI_toupper_ascii (const char c)
 
void BLI_str_tolower_ascii (char *str, const size_t len)
 
void BLI_str_toupper_ascii (char *str, const size_t len)
 
String Stripping
void BLI_str_rstrip (char *str)
 
int BLI_str_rstrip_float_zero (char *str, const char pad)
 
int BLI_str_rstrip_digits (char *str)
 
String Split (Partition)
size_t BLI_str_partition (const char *str, const char delim[], const char **sep, const char **suf)
 
size_t BLI_str_rpartition (const char *str, const char delim[], const char **sep, const char **suf)
 
size_t BLI_str_partition_ex (const char *str, const char *end, const char delim[], const char **sep, const char **suf, const bool from_right)
 
int BLI_string_find_split_words (const char *str, const size_t str_maxlen, const char delim, int r_words[][2], int words_max)
 
bool BLI_string_elem_split_by_delim (const char *haystack, const char delim, const char *needle)
 
String Formatting (Numeric)
static size_t BLI_str_format_int_grouped_ex (char *src, char *dst, int num_len)
 
size_t BLI_str_format_int_grouped (char dst[BLI_STR_FORMAT_INT32_GROUPED_SIZE], int num)
 
size_t BLI_str_format_uint64_grouped (char dst[BLI_STR_FORMAT_UINT64_GROUPED_SIZE], uint64_t num)
 
void BLI_str_format_byte_unit (char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE], long long int bytes, const bool base_10)
 
void BLI_str_format_byte_unit_compact (char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_COMPACT_SIZE], long long int bytes, const bool base_10)
 
void BLI_str_format_decimal_unit (char dst[BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE], int number_to_format)
 
void BLI_str_format_integer_unit (char dst[BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE], const int number_to_format)
 

Macro Definition Documentation

◆ CASE_PAIR

#define CASE_PAIR ( value_src,
value_dst )
Value:
case value_src: { \
*r_out = value_dst; \
return true; \
}

Referenced by blender::gpu::reversed(), and str_unescape_pair().

Function Documentation

◆ BLI_snprintf()

size_t BLI_snprintf ( char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
... )

◆ BLI_snprintf_rlen()

size_t BLI_snprintf_rlen ( char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
... )

Definition at line 218 of file string.c.

References BLI_string_debug_size, and BLI_vsnprintf_rlen().

Referenced by BLI_str_format_byte_unit().

◆ BLI_sprintfN()

char * BLI_sprintfN ( const char *__restrict format,
... )

Definition at line 300 of file string.c.

References BLI_vsprintfN_with_buffer(), MEM_mallocN, and result.

◆ BLI_sprintfN_with_buffer()

char * BLI_sprintfN_with_buffer ( char * fixed_buf,
size_t fixed_buf_size,
size_t * result_len,
const char *__restrict format,
... )

Definition at line 235 of file string.c.

References BLI_assert, MEM_callocN, MEM_mallocN, result, UNLIKELY, and UNUSED_VARS_NDEBUG.

◆ BLI_str_endswith()

bool BLI_str_endswith ( const char *__restrict str,
const char *__restrict end )

Definition at line 897 of file string.c.

References BLI_strn_endswith(), and str.

◆ BLI_str_escape()

size_t BLI_str_escape ( char *__restrict dst,
const char *__restrict src,
const size_t dst_maxncpy )

Definition at line 339 of file string.c.

References BLI_assert, BLI_string_debug_size, ELEM, len, and UNLIKELY.

◆ BLI_str_escape_find_quote()

const char * BLI_str_escape_find_quote ( const char * str)

Find the first un-escaped quote in the string (to find the end of the string).

Parameters
strTypically this is the first character in a quoted string. Where the character before *str would be ".
Returns
The pointer to the first un-escaped quote.

Definition at line 434 of file string.c.

References NULL, and str.

Referenced by action_flip_pchan_rna_paths(), BLI_str_quoted_substr_range(), and rna_path_token_in_brackets().

◆ BLI_str_format_byte_unit()

void BLI_str_format_byte_unit ( char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE],
long long int bytes,
bool base_10 )

Format a size in bytes using binary units. 1000 -> 1 KB Number of decimal places grows with the used unit (e.g. 1.5 MB, 1.55 GB, 1.545 TB).

Parameters
dstThe resulting string. Dimension of 14 to support largest possible value for bytes (#LLONG_MAX).
bytesNumber to format.
base_10Calculate using base 10 (GB, MB, ...) or 2 (GiB, MiB, ...).

Definition at line 1192 of file string.c.

References ARRAY_SIZE, BLI_snprintf_rlen(), BLI_STATIC_ASSERT, BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE, BLI_str_rstrip_float_zero(), BLI_string_debug_size, BLI_strncpy(), double(), fabs(), len, and MAX2.

Referenced by BKE_ptcache_update_info(), BLI_filelist_entry_size_to_string(), ED_info_statusbar_string_ex(), blender::nodes::get_bake_state_string(), blender::HashTableStats::print(), TEST(), and blender::internal::vector_print_stats().

◆ BLI_str_format_byte_unit_compact()

void BLI_str_format_byte_unit_compact ( char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_COMPACT_SIZE],
long long int bytes,
bool base_10 )

Format a size in bytes using binary units in compact (max 4 chars) format.

It shows a lower bound instead of rounding the number.

1 -> 1B 15 -> 15B 155 -> 155B 1555 -> 1K 15555 -> 15K 155555 -> .1M 1555555 -> 1M 15555555 -> 15M 155555555 -> .1G 1000000000 -> 1G ...

Parameters
dstThe resulting string. Dimension of 5 to support largest possible value for bytes (#LLONG_MAX).
bytesNumber to format.
base_10Calculate using base 10 (GB, MB, ...) or 2 (GiB, MiB, ...).

Definition at line 1222 of file string.c.

References ARRAY_SIZE, BLI_snprintf(), BLI_STR_FORMAT_INT64_BYTE_UNIT_COMPACT_SIZE, BLI_string_debug_size, fabsf, float, floorf, and int.

Referenced by BLI_filelist_entry_size_to_string().

◆ BLI_str_format_decimal_unit()

void BLI_str_format_decimal_unit ( char dst[BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE],
int number_to_format )

Format a count to up to 6 places (plus \0 terminator) string using long number names abbreviations. Used to produce a compact representation of large numbers.

1 -> 1 15 -> 15 155 -> 155 1555 -> 1.6K 15555 -> 15.6K 155555 -> 156K 1555555 -> 1.6M 15555555 -> 15.6M 155555555 -> 156M 1000000000 -> 1B ...

Length of 7 is the maximum of the resulting string, for example, -15.5K\0.

Definition at line 1255 of file string.c.

References ARRAY_SIZE, BLI_snprintf(), BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE, BLI_string_debug_size, fabsf, and float.

Referenced by blender::ed::spreadsheet::draw_count(), and TEST().

◆ BLI_str_format_int_grouped()

size_t BLI_str_format_int_grouped ( char dst[BLI_STR_FORMAT_INT32_GROUPED_SIZE],
int num )

Format integers with decimal grouping. 1000 -> 1,000

Parameters
dstThe resulting string.
numNumber to format.
Returns
The length of dst

Definition at line 1168 of file string.c.

References BLI_STR_FORMAT_INT32_GROUPED_SIZE, BLI_str_format_int_grouped_ex(), BLI_string_debug_size, int, SNPRINTF, and UNUSED_VARS_NDEBUG.

Referenced by BKE_ptcache_update_info(), blender::ed::space_node::create_inspection_string_for_geometry_info(), blender::ed::spreadsheet::spreadsheet_footer_region_draw(), and TEST().

◆ BLI_str_format_int_grouped_ex()

static size_t BLI_str_format_int_grouped_ex ( char * src,
char * dst,
int num_len )
static

Definition at line 1144 of file string.c.

Referenced by BLI_str_format_int_grouped(), and BLI_str_format_uint64_grouped().

◆ BLI_str_format_integer_unit()

void BLI_str_format_integer_unit ( char dst[BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE],
int number_to_format )

Format a count to up to 3 places (plus minus sign, plus '\0' terminator) string using long number names abbreviations. Used to produce a compact representation of large numbers as integers.

It shows a lower bound instead of rounding the number.

1 -> 1 15 -> 15 155 -> 155 1555 -> 1K 15555 -> 15K 155555 -> .1M 1555555 -> 1M 15555555 -> 15M 155555555 -> .1B 1000000000 -> 1B ...

Length of 5 is the maximum of the resulting string, for example, -15K\0.

Definition at line 1279 of file string.c.

References abs(), ARRAY_SIZE, BLI_snprintf(), BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE, BLI_string_debug_size, fabsf, float, floorf, and int.

Referenced by blender::ed::outliner::outliner_draw_userbuts(), TEST(), UI_icon_text_overlay_init_from_count(), and uiTemplateStatusInfo().

◆ BLI_str_format_uint64_grouped()

size_t BLI_str_format_uint64_grouped ( char dst[BLI_STR_FORMAT_UINT64_GROUPED_SIZE],
uint64_t num )

Format uint64_t with decimal grouping. 1000 -> 1,000

Parameters
dstThe resulting string.
numNumber to format.
Returns
The length of dst.

Definition at line 1180 of file string.c.

References BLI_str_format_int_grouped_ex(), BLI_STR_FORMAT_UINT64_GROUPED_SIZE, BLI_string_debug_size, int, PRIu64, SNPRINTF, and UNUSED_VARS_NDEBUG.

Referenced by file_draw_tooltip_custom_func(), and TEST().

◆ BLI_str_index_in_array()

int BLI_str_index_in_array ( const char *__restrict str,
const char **__restrict str_array )

Definition at line 857 of file string.c.

References str, and STREQ.

◆ BLI_str_index_in_array_n()

int BLI_str_index_in_array_n ( const char *__restrict str,
const char **__restrict str_array,
int str_array_len )

Return index of a string in a string array.

Parameters
strThe string to find.
str_arrayArray of strings.
str_array_lenThe length of the array, or -1 for a NULL-terminated array.
Returns
The index of str in str_array or -1.

Definition at line 842 of file string.c.

References str, and STREQ.

◆ BLI_str_partition()

size_t BLI_str_partition ( const char * str,
const char delim[],
const char ** sep,
const char ** suf )

Definition at line 1025 of file string.c.

References BLI_str_partition_ex(), NULL, and str.

◆ BLI_str_partition_ex()

size_t BLI_str_partition_ex ( const char * str,
const char * end,
const char delim[],
const char ** sep,
const char ** suf,
const bool from_right )

Definition at line 1035 of file string.c.

References BLI_assert, NULL, and str.

Referenced by BLI_str_partition(), and BLI_str_rpartition().

◆ BLI_str_quoted_substr()

bool BLI_str_quoted_substr ( const char *__restrict str,
const char *__restrict prefix,
char * result,
size_t result_maxncpy )

Fills result with text within "" that appear after some the contents of prefix. i.e. for string pose["apples"] with prefix pose[, it will return apples.

Parameters
stris the entire string to chop.
prefixis the part of the string to step over.
resultThe buffer to fill.
result_maxncpyThe maximum size of the buffer (including nil terminator).
Returns
True if the prefix was found and the entire quoted string was copied into result.

Assume that the strings returned must be freed afterwards, and that the inputs will contain data we want.

Definition at line 517 of file string.c.

References BLI_str_quoted_substr_range(), BLI_str_unescape_ex(), BLI_string_debug_size, and str.

Referenced by animchan_sync_fcurve_scene(), blender::bke::BKE_action_find_fcurves_with_bones(), can_delete_fcurve(), can_delete_key(), copy_animedit_keys(), blender::animrig::fcurve_matches_collection_path(), BCAnimationCurve::get_animation_name(), getname_anim_fcurve(), pose_select_same_keyingset(), and skip_fcurve_selected_data().

◆ BLI_str_quoted_substr_range()

bool BLI_str_quoted_substr_range ( const char *__restrict str,
const char *__restrict prefix,
int *__restrict r_start,
int *__restrict r_end )

Definition at line 452 of file string.c.

References BLI_assert_msg, BLI_str_escape_find_quote(), int, NULL, str, and UNLIKELY.

Referenced by BLI_str_quoted_substr().

◆ BLI_str_rpartition()

size_t BLI_str_rpartition ( const char * str,
const char delim[],
const char ** sep,
const char ** suf )

Definition at line 1030 of file string.c.

References BLI_str_partition_ex(), NULL, and str.

◆ BLI_str_rstrip()

void BLI_str_rstrip ( char * str)

Strip white-space from end of the string.

Definition at line 976 of file string.c.

References str.

Referenced by ED_area_status_text(), and fsmenu_xdg_user_dirs_parse().

◆ BLI_str_rstrip_digits()

int BLI_str_rstrip_digits ( char * str)

Strip trailing digits.

  • ABC123 -> ABC
Parameters
str
Returns
The number of digits stripped.

Definition at line 1008 of file string.c.

References int, and str.

Referenced by wm_save_as_mainfile_exec().

◆ BLI_str_rstrip_float_zero()

int BLI_str_rstrip_float_zero ( char * str,
char pad )

Strip trailing zeros from a float, eg:

  • 0.0000 -> 0.0
  • 2.0010 -> 2.001
Parameters
str
pad
Returns
The number of zeros stripped.

Definition at line 988 of file string.c.

References pad, and str.

Referenced by ANIM_add_driver(), BLI_str_format_byte_unit(), ui_but_copy_numeric_value(), and ui_textedit_begin().

◆ BLI_str_startswith()

bool BLI_str_startswith ( const char *__restrict str,
const char *__restrict start )

Definition at line 870 of file string.c.

References str.

◆ BLI_str_tolower_ascii()

void BLI_str_tolower_ascii ( char * str,
size_t len )

◆ BLI_str_toupper_ascii()

void BLI_str_toupper_ascii ( char * str,
const size_t len )

Definition at line 961 of file string.c.

References BLI_toupper_ascii(), len, and str.

Referenced by WM_operator_bl_idname().

◆ BLI_str_unescape()

size_t BLI_str_unescape ( char *__restrict dst,
const char *__restrict src,
const size_t src_maxncpy )

Definition at line 418 of file string.c.

References BLI_string_debug_size, len, str_unescape_pair(), and UNLIKELY.

◆ BLI_str_unescape_ex()

size_t BLI_str_unescape_ex ( char *__restrict dst,
const char *__restrict src,
const size_t src_maxncpy,
const size_t dst_maxncpy,
bool * r_is_complete )

Definition at line 390 of file string.c.

References BLI_string_debug_size, len, str_unescape_pair(), and UNLIKELY.

Referenced by BLI_str_quoted_substr().

◆ BLI_strcasecmp()

int BLI_strcasecmp ( const char * s1,
const char * s2 )

Definition at line 633 of file string.c.

Referenced by BLI_strcaseeq().

◆ BLI_strcasecmp_natural()

int BLI_strcasecmp_natural ( const char * s1,
const char * s2 )

Definition at line 729 of file string.c.

References ELEM, and left_number_strcmp().

◆ BLI_strcaseeq()

int BLI_strcaseeq ( const char * a,
const char * b )

Definition at line 543 of file string.c.

References b, and BLI_strcasecmp().

◆ BLI_strcasestr()

char * BLI_strcasestr ( const char * s,
const char * find )

Definition at line 548 of file string.c.

References BLI_strncasecmp(), len, and NULL.

◆ BLI_strchr_or_end()

const char * BLI_strchr_or_end ( const char * str,
char ch )

A version of strchr that returns the end of the string (point to \0) if the character is not found.

Useful for stepping over newlines up until the last line.

Definition at line 927 of file string.c.

References ELEM, and str.

Referenced by BLI_string_elem_split_by_delim(), console_paste_exec(), DRW_draw_region_engine_info(), blender::bke::file_handler_add(), and ui_but_tip_len_only_first_line().

◆ BLI_strcmp_ignore_pad()

int BLI_strcmp_ignore_pad ( const char * str1,
const char * str2,
const char pad )

Definition at line 796 of file string.c.

References pad, and ret.

◆ BLI_strdup()

char * BLI_strdup ( const char * str)

Duplicates the C-string str into a newly mallocN'd string and returns it.

Parameters
strThe string to be duplicated
Return values
Returnsthe duplicated string

Definition at line 40 of file string.c.

References BLI_strdupn(), and str.

Referenced by action_create(), action_set_create(), actkeys_paste_get_description(), add_driver_with_target(), blender::add_missing_data_block_mappings(), alloc_driver_fcurve(), ANIM_copy_as_driver(), animsys_blend_in_fcurves(), blender::bke::asset_weak_reference_for_user_library(), BKE_appdir_app_templates(), BKE_asset_catalog_path_list_add_path(), BKE_asset_catalog_path_list_duplicate(), BKE_bpath_foreach_path_allocated_process(), BKE_collection_new_name_get(), BKE_id_attributes_active_color_set(), BKE_id_attributes_default_color_set(), BKE_id_to_unique_string_key(), BKE_keyingset_add_path(), BKE_lib_override_library_property_get(), BKE_lib_override_library_property_operation_get(), BKE_lib_override_library_property_rna_path_change(), BKE_mesh_legacy_attribute_flags_to_strings(), BKE_modifier_set_error(), BKE_modifier_set_warning(), BKE_object_sync_to_original(), BKE_packedfile_unpack_to_file(), BKE_paint_canvas_key_get(), BKE_paint_copy(), BKE_panel_layout_panel_state_ensure(), BKE_previewimg_cached_ensure(), BKE_previewimg_cached_thumbnail_read(), BKE_render_result_stamp_data(), bke_view_layer_verify_aov_cb(), BKE_viewer_path_elem_copy(), blf_dir_metrics_search(), blf_font_new_impl(), bli_builddir(), BLI_cpu_brand_string(), BLI_string_replaceN(), BLO_blendhandle_get_datablock_names(), BLO_blendhandle_get_linkable_groups(), BLT_lang_init(), BLT_lang_locale_explode(), BMO_op_vinitf(), build_pict_list_from_image_sequence(), copy_attribute_names(), blender::copy_data(), current_relpath_append(), curves_copy_data(), blender::bke::curves_copy_parameters(), data_transfer_mesh_attributes_transfer_active_color_string(), data_transfer_mesh_attributes_transfer_default_color_string(), ED_armature_join_objects_exec(), ED_fsmenu_entry_set_path(), ED_image_save_all_modified_info(), fcurves_to_pchan_links_get(), file_browse_invoke(), file_execute(), fileentry_uiname(), filelist_file_create_entry(), filelist_readjob_recursive_dir_add_items(), folderlist_pushdir(), fsmenu_insert_entry(), fsmenu_xdg_user_dirs_parse(), ghost_event_proc(), icu_to_fcurves(), blender::nodes::id_property_create_from_socket(), blender::nodes::id_property_int_update_enum_items(), IDP_ui_data_copy(), idprop_ui_data_update_base(), idprop_ui_data_update_string(), IMB_anim_index_rebuild_context(), IMB_thumb_path_lock(), blender::gpu::GPUPlatformGlobal::init(), blender::ed::object::bake_simulation::initialize_modifier_bake_directory_if_necessary(), blender::bke::node_interface::item_types::item_copy(), blender::ed::greasepencil::join_object_with_active(), legacy_socket_move_to_interface(), lib_override_library_property_copy(), lib_override_library_property_operation_copy(), AnimationImporter::modify_fcurve(), blender::nodes::node_geo_bake_cc::node_init(), blender::nodes::node_geo_foreach_geometry_element_cc::output_node::node_init(), blender::nodes::node_geo_repeat_cc::repeat_output_node::node_init(), blender::nodes::node_geo_simulation_cc::sim_output_node::node_init(), blender::bke::node_register_alias(), blender::ed::object::object_curves_empty_hair_add_exec(), panel_list_copy(), path_destination_ensure_filename(), pyrna_struct_anim_args_parse_ex(), RE_engine_set_error_message(), read_text_corpus(), run_string_handle_error(), blender::nodes::socket_items::set_item_name_and_make_unique(), blender::ed::object::shade_auto_smooth_exec(), blender::ed::spreadsheet::spreadsheet_column_assign_runtime_data(), blender::ed::spreadsheet::spreadsheet_column_copy(), blender::ed::spreadsheet::spreadsheet_column_id_copy(), str_ghash_tests(), str_map_tests(), blender::ed::curves::surface_set::surface_set_exec(), blender::bke::tests::TEST_F(), blender::bke::tests::TEST_F(), blender::bke::tests::TEST_F(), blender::bke::tests::TEST_F(), blender::bke::tests::TEST_F(), text_convert_whitespace_exec(), text_copy_data(), text_save_as_exec(), toolsystem_brush_type_binding_update(), blender::bke::greasepencil::TreeNode::TreeNode(), try_parse_enum_item(), ui_apply_but_TEX(), ui_but_convert_to_unit_alt_name(), ui_but_rna_menu_convert_to_menu_type(), ui_but_rna_menu_convert_to_panel_type(), ui_but_string_get_dynamic(), ui_def_but_rna__menu(), UI_list_filter_and_sort_items(), ui_searchbox_apply(), ui_tooltip_data_from_tool(), uiItemFullOMenuHold_ptr(), uiTemplateRecentFiles(), blender::bke::bake::unpack_geometry_nodes_bake(), UNUSED_FUNCTION_WITH_RETURN_TYPE(), blender::nodes::update_input_properties_from_node_tree(), blender::nodes::update_output_properties_from_node_tree(), version_copy_socket(), version_idproperty_move_data_string(), version_idproperty_ui_data(), version_liboverride_rnacollections_insertion_object(), version_liboverride_rnacollections_insertion_object_constraints(), blender::ed::viewer_path::viewer_path_for_geometry_node(), blender::draw::volume_grid_cache_get(), wm_clipboard_text_set_impl(), wm_history_file_new(), wm_history_file_read(), and wm_save_as_mainfile_get_description().

◆ BLI_strdup_null()

char * BLI_strdup_null ( const char * str)

Duplicates the C-string str into a newly mallocN'd string and returns it.

Parameters
strThe string to be duplicated, can be null
Return values
Returnsthe duplicated string or null if str is null

Definition at line 45 of file string.c.

References BLI_strdupn(), NULL, and str.

Referenced by blender::ed::object::bake_simulation::bake_geometry_nodes_startjob(), blender::bke::forward_compat::construct_interface_as_legacy_sockets(), blender::copy_data(), blender::nodes::BakeItemsAccessor::copy_item(), blender::nodes::CaptureAttributeItemsAccessor::copy_item(), blender::nodes::ForeachGeometryElementGenerationItemsAccessor::copy_item(), blender::nodes::ForeachGeometryElementInputItemsAccessor::copy_item(), blender::nodes::ForeachGeometryElementMainItemsAccessor::copy_item(), blender::nodes::MenuSwitchItemsAccessor::copy_item(), blender::nodes::RepeatItemsAccessor::copy_item(), blender::nodes::SimulationItemsAccessor::copy_item(), blender::ed::greasepencil::grease_pencil_layer_parent_set(), blender::nodes::id_property_int_update_enum_items(), IDP_ui_data_copy(), blender::bke::node_interface::item_types::item_copy(), blender::bke::greasepencil::LayerMask::LayerMask(), blender::bke::greasepencil::LayerMask::LayerMask(), blender::bke::node_tree_asset_on_clear_asset(), blender::bke::node_tree_asset_on_mark_asset(), blender::bke::ntree_copy_data(), blender::bke::bake::pack_files_from_directory(), blender::bke::greasepencil::Layer::set_parent_bone_name(), blender::bke::greasepencil::Layer::set_view_layer_name(), blender::bke::greasepencil::TreeNode::TreeNode(), try_parse_enum_item(), UI_but_placeholder_set(), and version_copy_socket().

◆ BLI_strdupcat()

char * BLI_strdupcat ( const char *__restrict str1,
const char *__restrict str2 )

Definition at line 50 of file string.c.

References MEM_mallocN, and str.

◆ BLI_strdupn()

char * BLI_strdupn ( const char * str,
size_t len )

Duplicates the first len bytes of the C-string str into a newly mallocN'd string and returns it. str is assumed to be at least len bytes long.

Parameters
strThe string to be duplicated
lenThe number of bytes to duplicate
Return values
Returnsthe duplicated string

Definition at line 29 of file string.c.

References BLI_assert_msg, BLI_strnlen(), len, MEM_mallocN, and str.

Referenced by blender::ed::space_node::animation_basepath_change_new(), BKE_fcurve_rnapath_set(), BKE_nlastrip_validate_fcurves(), BLI_file_read_as_lines(), BLI_path_make_safe_filename_ex(), BLI_strdup(), BLI_strdup_null(), block_create__close_file_dialog(), BLT_lang_locale_explode(), BLT_lang_set(), console_lb_add__internal(), console_lb_add_str__internal(), blender::animrig::create_fcurve_for_channel(), do_versions_after_linking_280(), blender::animrig::tests::ActionFCurveMoveTest::fcurve_create(), blender::bke::greasepencil::convert::AnimDataConvertor::fcurves_convert(), fileentry_uiname(), ibJpegImageFromCinfo(), blender::ed::asset::index::init_indexer_entry_from_value(), blender::bke::node_interface::make_panel(), blender::bke::node_interface::make_socket(), memiter_words10k_test(), blender::bke::mesh_ensure_default_color_attribute_on_add(), blender::asset_system::utils::normalize_path(), pyop_poll_message_get_fn(), blender::ed::asset::shelf::settings_set_active_catalog(), TEST(), text_autocomplete_build(), text_convert_whitespace_exec(), text_copy_data(), txt_insert_buf(), ui_but_string_get_dynamic(), ui_number_from_string_factor(), ui_number_from_string_percentage(), UI_panel_drawname_set(), ui_textedit_begin(), and WM_msg_subscribe_rna_params().

◆ BLI_string_all_words_matched()

bool BLI_string_all_words_matched ( const char * name,
const char * str,
int(*) words[2],
const int words_len )

Definition at line 586 of file string.c.

References BLI_string_has_word_prefix(), and str.

◆ BLI_string_elem_split_by_delim()

bool BLI_string_elem_split_by_delim ( const char * haystack,
const char delim,
const char * needle )

Definition at line 1120 of file string.c.

References BLI_strchr_or_end().

◆ BLI_string_find_split_words()

int BLI_string_find_split_words ( const char * str,
const size_t str_maxlen,
const char delim,
int r_words[][2],
int words_max )

Definition at line 1085 of file string.c.

References int, and str.

◆ BLI_string_has_word_prefix()

bool BLI_string_has_word_prefix ( const char * haystack,
const char * needle,
size_t needle_len )

◆ BLI_string_max_possible_word_count()

int BLI_string_max_possible_word_count ( const int str_len)

Definition at line 569 of file string.c.

Referenced by name_matches_dopesheet_filter(), operator_search_update_fn(), and TEST().

◆ BLI_strn_endswith()

bool BLI_strn_endswith ( const char *__restrict str,
const char *__restrict end,
size_t str_len )

Definition at line 881 of file string.c.

References str.

Referenced by BLI_str_endswith().

◆ BLI_strncasecmp()

int BLI_strncasecmp ( const char * s1,
const char * s2,
size_t len )

Definition at line 656 of file string.c.

References len.

Referenced by BLI_strcasestr(), and BLI_strncasestr().

◆ BLI_strncasestr()

char * BLI_strncasestr ( const char * s,
const char * find,
size_t len )

Definition at line 602 of file string.c.

References BLI_strncasecmp(), len, and NULL.

Referenced by BLI_string_has_word_prefix().

◆ BLI_strncat()

char * BLI_strncat ( char *__restrict dst,
const char *__restrict src,
const size_t dst_maxncpy )

Definition at line 136 of file string.c.

References BLI_string_debug_size, BLI_strncpy(), BLI_strnlen(), and len.

◆ BLI_strncpy()

char * BLI_strncpy ( char *__restrict dst,
const char *__restrict src,
const size_t dst_maxncpy )

Definition at line 67 of file string.c.

References BLI_assert, BLI_string_debug_size, and BLI_strnlen().

Referenced by BLI_str_format_byte_unit(), and BLI_strncat().

◆ BLI_strncpy_ensure_pad()

char * BLI_strncpy_ensure_pad ( char *__restrict dst,
const char *__restrict src,
const char pad,
size_t dst_maxncpy )

Definition at line 79 of file string.c.

References BLI_assert, BLI_string_debug_size, BLI_strnlen(), and pad.

◆ BLI_strncpy_rlen()

size_t BLI_strncpy_rlen ( char *__restrict dst,
const char *__restrict src,
const size_t dst_maxncpy )

Definition at line 118 of file string.c.

References BLI_assert, BLI_string_debug_size, and BLI_strnlen().

◆ BLI_strnlen()

size_t BLI_strnlen ( const char * str,
size_t maxlen )

Determine the length of a fixed-size string.

Returns
The string length that doesn't exceed maxlen. The equivalent of min(strlen(str), maxlen) that prevents a buffer overflow when str isn't null terminated before maxlen.

Definition at line 909 of file string.c.

References len, and str.

Referenced by blender::bke::cryptomatte::CryptomatteLayer::add_ID(), blender::compositor::add_meta_data_for_input(), blender::realtime_compositor::FileOutput::add_pass(), BKE_cryptomatte_entries_to_matte_id(), BKE_preferences_extension_repo_module_is_valid(), blf_dir_metrics_search(), blf_font_width_to_rstrlen(), blf_str_offset_from_cursor_position(), BLI_current_working_dir(), BLI_dynstr_nappend(), BLI_path_rel(), BLI_path_slash_native(), BLI_strdupn(), BLI_string_flip_side_name(), BLI_string_split_prefix(), BLI_string_split_suffix(), BLI_strncat(), BLI_strncpy(), BLI_strncpy_ensure_pad(), BLI_strncpy_rlen(), blender::compositor::combined_layer_pass_name(), ED_buttons_search_string_length(), eyedropper_cryptomatte_sample_renderlayer_fl(), eyedropper_cryptomatte_sample_view3d_fl(), GPUCodegen::generate_cryptomatte(), blender::compositor::RenderLayersProg::get_meta_data(), blender::io::usd::get_relative_path(), ibJpegImageFromCinfo(), IDP_AssignStringMaxSize(), IDP_NewStringMaxSize(), blender::compositor::ConvertColorSpaceOperation::init_execution(), blender::ed::asset::index::init_user_data(), blender::bke::greasepencil::convert::legacy_gpencil_to_grease_pencil(), blender::compositor::prefix_from_node(), blender::eevee::Cryptomatte::register_id(), blender::io::usd::USDTransformWriter::should_apply_root_xform(), TEST(), WM_xr_actionmap_binding_ensure_unique(), WM_xr_actionmap_ensure_unique(), and WM_xr_actionmap_item_ensure_unique().

◆ BLI_tolower_ascii()

char BLI_tolower_ascii ( const char c)

Definition at line 942 of file string.c.

Referenced by BLI_str_tolower_ascii().

◆ BLI_toupper_ascii()

char BLI_toupper_ascii ( const char c)

◆ BLI_vsnprintf()

size_t BLI_vsnprintf ( char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
va_list arg )

Definition at line 153 of file string.c.

References BLI_assert, BLI_string_debug_size, and NULL.

Referenced by BLI_snprintf().

◆ BLI_vsnprintf_rlen()

size_t BLI_vsnprintf_rlen ( char *__restrict dst,
size_t dst_maxncpy,
const char *__restrict format,
va_list arg )

Definition at line 178 of file string.c.

References BLI_assert, BLI_string_debug_size, and NULL.

Referenced by BLI_snprintf_rlen().

◆ BLI_vsprintfN()

char * BLI_vsprintfN ( const char *__restrict format,
va_list args )

Definition at line 318 of file string.c.

References BLI_vsprintfN_with_buffer(), MEM_mallocN, and result.

◆ BLI_vsprintfN_with_buffer()

char * BLI_vsprintfN_with_buffer ( char * fixed_buf,
size_t fixed_buf_size,
size_t * result_len,
const char *__restrict format,
va_list args )

Definition at line 267 of file string.c.

References BLI_assert, MEM_callocN, MEM_mallocN, result, UNLIKELY, and UNUSED_VARS_NDEBUG.

Referenced by BLI_sprintfN(), and BLI_vsprintfN().

◆ left_number_strcmp()

static int left_number_strcmp ( const char * s1,
const char * s2,
int * tiebreaker )
static

Definition at line 680 of file string.c.

References int.

Referenced by BLI_strcasecmp_natural().

◆ str_unescape_pair()

BLI_INLINE bool str_unescape_pair ( char c_next,
char * r_out )

Definition at line 369 of file string.c.

References CASE_PAIR.

Referenced by BLI_str_unescape(), and BLI_str_unescape_ex().