Revision: 28394
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28394
Author:   campbellbarton
Date:     2010-04-24 01:01:50 +0200 (Sat, 24 Apr 2010)

Log Message:
-----------
string number decoding didnt check for win32 slash & minor adjustments to some 
other path funcs (no functional change).

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_path_util.h
    trunk/blender/source/blender/blenlib/intern/path_util.c
    trunk/blender/source/blender/imbuf/intern/anim.c

Modified: trunk/blender/source/blender/blenlib/BLI_path_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_path_util.h        2010-04-23 
22:48:26 UTC (rev 28393)
+++ trunk/blender/source/blender/blenlib/BLI_path_util.h        2010-04-23 
23:01:50 UTC (rev 28394)
@@ -63,8 +63,8 @@
 int BLI_testextensie(const char *str, const char *ext);
 void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], 
char delim, short name_offs, short len);
 void BLI_newname(char * name, int add);
-int BLI_stringdec(char *string, char *head, char *start, unsigned short 
*numlen);
-void BLI_stringenc(char *string, char *head, char *start, unsigned short 
numlen, int pic);
+int BLI_stringdec(const char *string, char *head, char *start, unsigned short 
*numlen);
+void BLI_stringenc(char *string, const char *head, const char *tail, unsigned 
short numlen, int pic);
 void BLI_splitdirstring(char *di,char *fi);
 
 /* make sure path separators conform to system one */

Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c     2010-04-23 
22:48:26 UTC (rev 28393)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c     2010-04-23 
23:01:50 UTC (rev 28394)
@@ -80,7 +80,7 @@
 
 /* implementation */
 
-int BLI_stringdec(char *string, char *head, char *start, unsigned short 
*numlen)
+int BLI_stringdec(const char *string, char *head, char *tail, unsigned short 
*numlen)
 {
        unsigned short len, len2, lenlslash = 0, nums = 0, nume = 0;
        short i, found = 0;
@@ -108,7 +108,7 @@
                }
        }
        if (found){
-               if (start) strcpy(start,&string[nume+1]);
+               if (tail) strcpy(tail, &string[nume+1]);
                if (head) {
                        strcpy(head,string);
                        head[nums]=0;
@@ -116,22 +116,22 @@
                if (numlen) *numlen = nume-nums+1;
                return ((int)atoi(&(string[nums])));
        }
-       if (start) strcpy(start, string + len);
+       if (tail) strcpy(tail, string + len);
        if (head) {
                strncpy(head, string, len);
-               head[len] = 0;
+               head[len] = '\0';
        }
        if (numlen) *numlen=0;
        return 0;
 }
 
 
-void BLI_stringenc(char *string, char *head, char *start, unsigned short 
numlen, int pic)
+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, start);
+       sprintf(string, fmtstr, head, pic, tail);
 }
 
 
@@ -1109,10 +1109,7 @@
        return (retval);
 }
 
-/*
- * This is a simple version of BLI_split_dirfile that has the following 
advantages...
- * 
- * Converts "/foo/bar.txt" to "/foo/" and "bar.txt"
+/* Converts "/foo/bar.txt" to "/foo/" and "bar.txt"
  * - wont change 'string'
  * - wont create any directories
  * - dosnt use CWD, or deal with relative paths.
@@ -1120,14 +1117,12 @@
  * */
 void BLI_split_dirfile(const char *string, char *dir, char *file)
 {
-       int lslash=0, i = 0;
-       for (i=0; string[i]!='\0'; i++) {
-               if (string[i]=='\\' || string[i]=='/')
-                       lslash = i+1;
-       }
+       char *lslash_str = BLI_last_slash(string);
+       int lslash= lslash_str ? (int)(lslash_str - string) + 1 : 0;
+
        if (dir) {
                if (lslash) {
-                       BLI_strncpy( dir, string, lslash+1); /* +1 to include 
the slash and the last char */
+                       BLI_strncpy( dir, string, lslash + 1); /* +1 to include 
the slash and the last char */
                } else {
                        dir[0] = '\0';
                }

Modified: trunk/blender/source/blender/imbuf/intern/anim.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/anim.c    2010-04-23 22:48:26 UTC 
(rev 28393)
+++ trunk/blender/source/blender/imbuf/intern/anim.c    2010-04-23 23:01:50 UTC 
(rev 28394)
@@ -225,7 +225,13 @@
 
 #endif
 
-static int an_stringdec(char *string, char* kop, char *staart,unsigned short 
*numlen) {
+#if defined(_WIN32)
+# define PATHSEPERATOR '\\'
+#else
+# define PATHSEPERATOR '/'
+#endif
+
+static int an_stringdec(const char *string, char* head, char *tail, unsigned 
short *numlen) {
        unsigned short len,nume,nums=0;
        short i,found=FALSE;
 
@@ -233,7 +239,7 @@
        nume = len;
 
        for(i=len-1;i>=0;i--){
-               if (string[i]=='/') break;
+               if (string[i]==PATHSEPERATOR) break;
                if (isdigit(string[i])) {
                        if (found){
                                nums=i;
@@ -247,21 +253,21 @@
                }
        }
        if (found){
-               strcpy(staart,&string[nume+1]);
-               strcpy(kop,string);
-               kop[nums]=0;
+               strcpy(tail ,&string[nume+1]);
+               strcpy(head, string);
+               head[nums]= '\0';
                *numlen=nume-nums+1;
                return ((int)atoi(&(string[nums])));
        }
-       staart[0]=0;
-       strcpy(kop,string);
+       tail[0]= '\0';
+       strcpy(head, string);
        *numlen=0;
-       return (1);
+       return TRUE;
 }
 
 
-static void an_stringenc(char *string, char *head, char *start, unsigned short 
numlen, int pic) {
-       BLI_stringenc(string, head, start, numlen, pic);
+static void an_stringenc(char *string, const char *head, const char *tail, 
unsigned short numlen, int pic) {
+       BLI_stringenc(string, head, tail, numlen, pic);
 }
 
 static void free_anim_avi (struct anim *anim) {


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to