fix for creating movie paths with non utf8 names.

button test if non utf8 chars are allowed was inverted.
This commit is contained in:
Campbell Barton 2010-11-16 08:53:55 +00:00
parent f48f8d3bbc
commit 7f96852176
2 changed files with 10 additions and 1 deletions

@ -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 */ if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
char tmp[FILE_MAX], format[64]; 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(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); sprintf(tmp, format, path, sta, end, path+ch_end);
strcpy(path, tmp); 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 1;
} }
return 0; return 0;

@ -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) static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
{ {
if(but) { 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)); int strip= BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr));
/* not a file?, strip non utf-8 chars */ /* not a file?, strip non utf-8 chars */
if(strip) { if(strip) {