Cleanup: all params of BLI_str partition funcs can be const...

This commit is contained in:
Bastien Montagne 2015-06-27 11:00:47 +02:00
parent ecb6a6df52
commit e170d6be7f
12 changed files with 35 additions and 35 deletions

@ -160,7 +160,7 @@ void BKE_scene_multiview_filepath_get(struct SceneRenderView *srv, const
void BKE_scene_multiview_view_filepath_get(const struct RenderData *rd, const char *filepath, const char *view, char *r_filepath);
const char *BKE_scene_multiview_view_suffix_get(const struct RenderData *rd, const char *viewname);
const char *BKE_scene_multiview_view_id_suffix_get(const struct RenderData *rd, const size_t view_id);
void BKE_scene_multiview_view_prefix_get(struct Scene *scene, const char *name, char *rprefix, char **rext);
void BKE_scene_multiview_view_prefix_get(struct Scene *scene, const char *name, char *rprefix, const char **rext);
void BKE_scene_multiview_videos_dimensions_get(const struct RenderData *rd, const size_t width, const size_t height, size_t *r_width, size_t *r_height);
size_t BKE_scene_multiview_num_videos_get(const struct RenderData *rd);

@ -4595,7 +4595,7 @@ static void image_update_views_format(Image *ima, ImageUser *iuser)
/* R_IMF_VIEWS_INDIVIDUAL */
char prefix[FILE_MAX] = {'\0'};
char *name = ima->name;
char *ext = NULL;
const char *ext = NULL;
BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext);

@ -2428,11 +2428,11 @@ const char *BKE_scene_multiview_view_id_suffix_get(const RenderData *rd, const s
}
}
void BKE_scene_multiview_view_prefix_get(Scene *scene, const char *name, char *rprefix, char **rext)
void BKE_scene_multiview_view_prefix_get(Scene *scene, const char *name, char *rprefix, const char **rext)
{
SceneRenderView *srv;
size_t index_act;
char *suf_act;
const char *suf_act;
const char delims[] = {'.', '\0'};
rprefix[0] = '\0';

@ -854,7 +854,7 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, const bool lock_r
if (is_multiview && (seq->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
char prefix[FILE_MAX];
char *ext = NULL;
const char *ext = NULL;
size_t totfiles = seq_num_files(scene, seq->views_format, true);
int i = 0;
@ -1479,7 +1479,7 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
if (is_multiview && seq->views_format == R_IMF_VIEWS_INDIVIDUAL) {
size_t totfiles = seq_num_files(scene, seq->views_format, true);
char prefix[FILE_MAX];
char *ext = NULL;
const char *ext = NULL;
int i;
BKE_scene_multiview_view_prefix_get(scene, name, prefix, &ext);
@ -1773,7 +1773,7 @@ static bool seq_proxy_multiview_context_invalid(Sequence *seq, Scene *scene, con
if ((seq->type == SEQ_TYPE_IMAGE) && (seq->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
static char prefix[FILE_MAX];
static char *ext = NULL;
static const char *ext = NULL;
char str[FILE_MAX];
if (view_id == 0) {
@ -2739,7 +2739,7 @@ static ImBuf *seq_render_image_strip(const SeqRenderData *context, Sequence *seq
size_t totviews;
struct ImBuf **ibufs_arr;
char prefix[FILE_MAX];
char *ext = NULL;
const char *ext = NULL;
int i;
if (totfiles > 1) {
@ -5068,7 +5068,7 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad
if (is_multiview && (seq_load->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
char prefix[FILE_MAX];
char *ext = NULL;
const char *ext = NULL;
size_t j = 0;
BKE_scene_multiview_view_prefix_get(scene, path, prefix, &ext);

@ -90,10 +90,10 @@ int BLI_str_index_in_array(const char *__restrict str, const char **__restrict s
bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL();
bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t length) ATTR_NONNULL();
size_t BLI_str_partition(const char *str, const char delim[], char **sep, char **suf) ATTR_NONNULL();
size_t BLI_str_rpartition(const char *str, const char delim[], char **sep, char **suf) ATTR_NONNULL();
size_t BLI_str_partition(const char *str, const char delim[], const char **sep, const char **suf) ATTR_NONNULL();
size_t BLI_str_rpartition(const char *str, const char delim[], const char **sep, const char **suf) ATTR_NONNULL();
size_t BLI_str_partition_ex(
const char *str, const char *end, const char delim[], char **sep, char **suf, const bool from_right)
const char *str, const char *end, const char delim[], const char **sep, const char **suf, const bool from_right)
ATTR_NONNULL(1, 3, 4, 5);
#ifdef __cplusplus

@ -67,10 +67,10 @@ int BLI_wcswidth(const wchar_t *pwcs, size_t n) ATTR_NONNULL();
int BLI_str_utf8_char_width(const char *p) ATTR_NONNULL(); /* warning, can return -1 on bad chars */
int BLI_str_utf8_char_width_safe(const char *p) ATTR_NONNULL();
size_t BLI_str_partition_utf8(const char *str, const unsigned int delim[], char **sep, char **suf) ATTR_NONNULL();
size_t BLI_str_rpartition_utf8(const char *str, const unsigned int delim[], char **sep, char **suf) ATTR_NONNULL();
size_t BLI_str_partition_utf8(const char *str, const unsigned int delim[], const char **sep, const char **suf) ATTR_NONNULL();
size_t BLI_str_rpartition_utf8(const char *str, const unsigned int delim[], const char **sep, const char **suf) ATTR_NONNULL();
size_t BLI_str_partition_ex_utf8(
const char *str, const char *end, const unsigned int delim[], char **sep, char **suf, const bool from_right)
const char *str, const char *end, const unsigned int delim[], const char **sep, const char **suf, const bool from_right)
ATTR_NONNULL(1, 3, 4, 5);
#define BLI_UTF8_MAX 6 /* mem */

@ -854,7 +854,7 @@ bool BLI_str_endswith(const char *__restrict str, const char *end)
* \param suf Return value, set to next char after the first delimiter found (or NULL if none found).
* \return The length of the prefix (i.e. *sep - str).
*/
size_t BLI_str_partition(const char *str, const char delim[], char **sep, char **suf)
size_t BLI_str_partition(const char *str, const char delim[], const char **sep, const char **suf)
{
return BLI_str_partition_ex(str, NULL, delim, sep, suf, false);
}
@ -868,7 +868,7 @@ size_t BLI_str_partition(const char *str, const char delim[], char **sep, char *
* \param suf Return value, set to next char after the first delimiter found (or NULL if none found).
* \return The length of the prefix (i.e. *sep - str).
*/
size_t BLI_str_rpartition(const char *str, const char delim[], char **sep, char **suf)
size_t BLI_str_rpartition(const char *str, const char delim[], const char **sep, const char **suf)
{
return BLI_str_partition_ex(str, NULL, delim, sep, suf, true);
}
@ -885,7 +885,7 @@ size_t BLI_str_rpartition(const char *str, const char delim[], char **sep, char
* \return The length of the prefix (i.e. *sep - str).
*/
size_t BLI_str_partition_ex(
const char *str, const char *end, const char delim[], char **sep, char **suf, const bool from_right)
const char *str, const char *end, const char delim[], const char **sep, const char **suf, const bool from_right)
{
const char *d;
char *(*func)(const char *str, int c) = from_right ? strrchr : strchr;
@ -916,7 +916,7 @@ size_t BLI_str_partition_ex(
}
if (tmp && (from_right ? (*sep < tmp) : (!*sep || *sep > tmp))) {
*sep = (char *)tmp;
*sep = tmp;
}
}

@ -734,18 +734,18 @@ char *BLI_str_prev_char_utf8(const char *p)
}
/* end glib copy */
size_t BLI_str_partition_utf8(const char *str, const unsigned int delim[], char **sep, char **suf)
size_t BLI_str_partition_utf8(const char *str, const unsigned int delim[], const char **sep, const char **suf)
{
return BLI_str_partition_ex_utf8(str, NULL, delim, sep, suf, false);
}
size_t BLI_str_rpartition_utf8(const char *str, const unsigned int delim[], char **sep, char **suf)
size_t BLI_str_rpartition_utf8(const char *str, const unsigned int delim[], const char **sep, const char **suf)
{
return BLI_str_partition_ex_utf8(str, NULL, delim, sep, suf, true);
}
size_t BLI_str_partition_ex_utf8(
const char *str, const char *end, const unsigned int delim[], char **sep, char **suf, const bool from_right)
const char *str, const char *end, const unsigned int delim[], const char **sep, const char **suf, const bool from_right)
{
const unsigned int *d;
const size_t str_len = end ? (size_t)(end - str) : strlen(str);

@ -249,7 +249,7 @@ static bool node_select_grouped_name(SpaceNode *snode, bNode *node_act, const bo
bool changed = false;
const unsigned int delims[] = {'.', '-', '_', '\0'};
size_t pref_len_act, pref_len_curr;
char *sep, *suf_act, *suf_curr;
const char *sep, *suf_act, *suf_curr;
pref_len_act = BLI_str_partition_ex_utf8(node_act->name, NULL, delims, &sep, &suf_act, from_right);

@ -770,8 +770,8 @@ static const char *imb_exr_insert_view_name(const char *passname, const char *vi
static char retstr[EXR_PASS_MAXNAME];
const char delims[] = {'.', '\0'};
char *sep;
char *token;
const char *sep;
const char *token;
size_t len;
len = BLI_str_rpartition(passname, delims, &sep, &token);
@ -1419,9 +1419,9 @@ void IMB_exr_close(void *handle)
static int imb_exr_split_token(const char *str, const char *end, const char **token)
{
const char delims[] = {'.', '\0'};
char *sep;
const char *sep;
BLI_str_partition_ex(str, end, delims, &sep, (char **)token, true);
BLI_str_partition_ex(str, end, delims, &sep, token, true);
if (!sep) {
*token = str;

@ -460,8 +460,8 @@ static int passtype_from_name(const char *str)
static void set_pass_name(char *passname, int passtype, int channel, const char *view)
{
const char delims[] = {'.', '\0'};
char *sep;
char *token;
const char *sep;
const char *token;
size_t len;
const char *passtype_name = name_from_passtype(passtype, channel);

@ -36,7 +36,7 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n)
TEST(string, StrPartition)
{
const char delim[] = {'-', '.', '_', '~', '\\', '\0'};
char *sep, *suf;
const char *sep, *suf;
size_t pre_ln;
{
@ -95,7 +95,7 @@ TEST(string, StrPartition)
TEST(string, StrRPartition)
{
const char delim[] = {'-', '.', '_', '~', '\\', '\0'};
char *sep, *suf;
const char *sep, *suf;
size_t pre_ln;
{
@ -154,7 +154,7 @@ TEST(string, StrRPartition)
TEST(string, StrPartitionEx)
{
const char delim[] = {'-', '.', '_', '~', '\\', '\0'};
char *sep, *suf;
const char *sep, *suf;
size_t pre_ln;
/* Only considering 'from_right' cases here. */
@ -185,7 +185,7 @@ TEST(string, StrPartitionEx)
TEST(string, StrPartitionUtf8)
{
const unsigned int delim[] = {'-', '.', '_', 0x00F1 /* n tilde */, 0x262F /* ying-yang */, '\0'};
char *sep, *suf;
const char *sep, *suf;
size_t pre_ln;
{
@ -244,7 +244,7 @@ TEST(string, StrPartitionUtf8)
TEST(string, StrRPartitionUtf8)
{
const unsigned int delim[] = {'-', '.', '_', 0x00F1 /* n tilde */, 0x262F /* ying-yang */, '\0'};
char *sep, *suf;
const char *sep, *suf;
size_t pre_ln;
{
@ -303,7 +303,7 @@ TEST(string, StrRPartitionUtf8)
TEST(string, StrPartitionExUtf8)
{
const unsigned int delim[] = {'-', '.', '_', 0x00F1 /* n tilde */, 0x262F /* ying-yang */, '\0'};
char *sep, *suf;
const char *sep, *suf;
size_t pre_ln;
/* Only considering 'from_right' cases here. */