diff options
-rw-r--r-- | source/blender/blenlib/intern/string.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 15 |
2 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 2f1ddf294ce..c4ed44f0cdb 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -129,7 +129,6 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen) while(len < maxlen) { switch(*src) { case '\0': - *dst= '\0'; break; case '\\': case '"': @@ -144,7 +143,6 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen) } else { /* not enough space to escape */ - *dst= '\0'; break; } /* intentionally pass through */ @@ -156,6 +154,8 @@ size_t BLI_strescape(char *dst, const char *src, const size_t maxlen) len++; } + *dst= '\0'; + return len; } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 88447f6dd77..bc6e17a689d 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2106,7 +2106,7 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fi if(length+1 < fixedlen) buf= fixedbuf; else - buf= MEM_callocN(sizeof(char)*(length+1), "RNA_string_get_alloc"); + buf= MEM_mallocN(sizeof(char)*(length+1), "RNA_string_get_alloc"); RNA_property_string_get(ptr, prop, buf); @@ -4271,11 +4271,18 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop) break; case PROP_STRING: { - /* string arrays dont exist */ + char *buf_esc; char *buf; - buf = RNA_property_string_get_alloc(ptr, prop, NULL, -1); - BLI_dynstr_appendf(dynstr, "\"%s\"", buf); + int length; + + length= RNA_property_string_length(ptr, prop); + buf= MEM_mallocN(sizeof(char)*(length+1), "RNA_property_as_string"); + buf_esc= MEM_mallocN(sizeof(char)*(length*2+1), "RNA_property_as_string esc"); + RNA_property_string_get(ptr, prop, buf); + BLI_strescape(buf_esc, buf, length*2); MEM_freeN(buf); + BLI_dynstr_appendf(dynstr, "\"%s\"", buf_esc); + MEM_freeN(buf_esc); break; } case PROP_ENUM: |