fix for creating movie paths with non utf8 names.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 16 Nov 2010 08:53:55 +0000 (08:53 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 16 Nov 2010 08:53:55 +0000 (08:53 +0000)
button test if non utf8 chars are allowed was inverted.

source/blender/blenlib/intern/path_util.c
source/blender/editors/interface/interface_handlers.c

index a496e6c..b6d4d70 100644 (file)
@@ -615,9 +615,18 @@ int BLI_path_frame_range(char *path, int sta, int end, int digits)
 
        if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
                char tmp[FILE_MAX], format[64];
+#if 0  // neat but breaks on non ascii strings.
                sprintf(format, "%%.%ds%%.%dd_%%.%dd%%s", ch_sta, ch_end-ch_sta, ch_end-ch_sta); /* example result: "%.12s%.5d-%.5d%s" */
                sprintf(tmp, format, path, sta, end, path+ch_end);
                strcpy(path, tmp);
+#else
+               char *tmp_pt;
+               BLI_snprintf(format, sizeof(format), "%%.%dd-%%.%dd%%s", digits, digits);
+               memcpy(tmp, path, ch_sta * sizeof(char));
+               tmp_pt = &tmp[ch_sta];
+               tmp_pt += BLI_snprintf(tmp_pt, sizeof(tmp)-ch_sta, format, sta, end, &path[ch_end]);
+               memcpy(path, tmp, (int)(tmp_pt - tmp) + 1);
+#endif
                return 1;
        }
        return 0;
index 95a80df..b6db799 100644 (file)
@@ -1589,7 +1589,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
 static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
 {
        if(but) {
-               if(ui_is_utf8_but(but)) {
+               if(!ui_is_utf8_but(but)) {
                        int strip= BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr));
                        /* not a file?, strip non utf-8 chars */
                        if(strip) {