diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-04-16 17:10:08 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-04-16 17:10:08 +0400 |
commit | f47ab4f0aedf2445bffab2094986884a418a976f (patch) | |
tree | feb0de1eb8f9d32d3ffebd14f03b0a1a64424fc0 /source/blender/blenlib | |
parent | 23af7214d3721862eae9f4601791ee0602740f50 (diff) |
2.5:
* Added extra parameter to generic unique name finding function BLI_uniquename() for specifying the delimeter between non-unique parts of the name and digits.
* Driver target variables now get unique names by default.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_util.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/util.c | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_util.h b/source/blender/blenlib/BLI_util.h index 9f0c3504ef8..30c9fc353b3 100644 --- a/source/blender/blenlib/BLI_util.h +++ b/source/blender/blenlib/BLI_util.h @@ -51,7 +51,7 @@ void BLI_split_dirfile(char *string, char *dir, char *file); void BLI_split_dirfile_basic(const char *string, char *dir, char *file); void BLI_join_dirfile(char *string, const char *dir, const char *file); int BLI_testextensie(const char *str, const char *ext); -void BLI_uniquename(struct ListBase *list, void *vlink, char defname[], short name_offs, short len); +void BLI_uniquename(struct ListBase *list, void *vlink, char defname[], char delim, short name_offs, short len); void BLI_newname(char * name, int add); int BLI_stringdec(char *string, char *kop, char *start, unsigned short *numlen); void BLI_stringenc(char *string, char *kop, char *start, unsigned short numlen, int pic); diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index 040b2d4027c..88f5038e19f 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -224,8 +224,9 @@ void BLI_newname(char *name, int add) * name_offs: should be calculated using offsetof(structname, membername) macro from stddef.h * len: maximum length of string (to prevent overflows, etc.) * defname: the name that should be used by default if none is specified already + * delim: the character which acts as a delimeter between parts of the name */ -void BLI_uniquename(ListBase *list, void *vlink, char defname[], short name_offs, short len) +void BLI_uniquename(ListBase *list, void *vlink, char defname[], char delim, short name_offs, short len) { Link *link; char tempname[128]; @@ -261,12 +262,12 @@ void BLI_uniquename(ListBase *list, void *vlink, char defname[], short name_offs return; /* Strip off the suffix */ - dot = strchr(GIVE_STRADDR(vlink, name_offs), '.'); + dot = strchr(GIVE_STRADDR(vlink, name_offs), delim); if (dot) *dot=0; for (number = 1; number <= 999; number++) { - BLI_snprintf(tempname, 128, "%s.%03d", GIVE_STRADDR(vlink, name_offs), number); + BLI_snprintf(tempname, 128, "%s%c%03d", GIVE_STRADDR(vlink, name_offs), delim, number); exists = 0; for (link= list->first; link; link= link->next) { |