code cleanup: use '%.*d' with string formatting for variable length number.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 10 Mar 2013 11:02:21 +0000 (11:02 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 10 Mar 2013 11:02:21 +0000 (11:02 +0000)
source/blender/blenlib/intern/path_util.c

index 7237f7d..c3bc35a 100644 (file)
@@ -147,10 +147,7 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu
  */
 void BLI_stringenc(char *string, const char *head, const char *tail, unsigned short numlen, int pic)
 {
-       char fmtstr[16] = "";
-       if (pic < 0) pic = 0;
-       sprintf(fmtstr, "%%s%%.%dd%%s", numlen);
-       sprintf(string, fmtstr, head, pic, tail);
+       sprintf(string, "%s%.*d%s", head, numlen, MAX2(0, pic), tail);
 }
 
 /**