Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-24 08:18:28 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-24 08:18:28 +0400
commit0503a4f7a6fa2aba573ff4f8d4c6d7f387894952 (patch)
tree26fa3836cd19536e6445ef4aad8fcecece1614f3 /source/blender/blenkernel/intern
parent618d4d1a6e4a3df8399549fa80846cdeacb7299c (diff)
parent2bd9519e39f7c383005fd531f4c7dd92cce246ad (diff)
svn merge ^/trunk/blender -r41100:41150
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/BME_conversions.c1
-rw-r--r--source/blender/blenkernel/intern/BME_eulers.c1
-rw-r--r--source/blender/blenkernel/intern/BME_mesh.c2
-rw-r--r--source/blender/blenkernel/intern/BME_structure.c1
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c3
-rw-r--r--source/blender/blenkernel/intern/font.c140
-rw-r--r--source/blender/blenkernel/intern/image.c8
-rw-r--r--source/blender/blenkernel/intern/modifier.c7
-rw-r--r--source/blender/blenkernel/intern/nla.c3
-rw-r--r--source/blender/blenkernel/intern/node.c54
-rw-r--r--source/blender/blenkernel/intern/packedFile.c53
-rw-r--r--source/blender/blenkernel/intern/particle_system.c1
-rw-r--r--source/blender/blenkernel/intern/pointcache.c10
-rw-r--r--source/blender/blenkernel/intern/property.c6
-rw-r--r--source/blender/blenkernel/intern/sequencer.c14
-rw-r--r--source/blender/blenkernel/intern/smoke.c3
-rw-r--r--source/blender/blenkernel/intern/softbody.c1
-rw-r--r--source/blender/blenkernel/intern/sound.c4
-rw-r--r--source/blender/blenkernel/intern/texture.c2
19 files changed, 97 insertions, 217 deletions
diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c
index e5a5818e0e8..9552678628a 100644
--- a/source/blender/blenkernel/intern/BME_conversions.c
+++ b/source/blender/blenkernel/intern/BME_conversions.c
@@ -45,6 +45,7 @@
#include "DNA_scene_types.h"
#include "BLI_edgehash.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_mesh.h"
diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c
index d7cff7cfe27..1baf34236ef 100644
--- a/source/blender/blenkernel/intern/BME_eulers.c
+++ b/source/blender/blenkernel/intern/BME_eulers.c
@@ -39,6 +39,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "bmesh_private.h"
diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c
index fd38fae13cf..e15a46b407e 100644
--- a/source/blender/blenkernel/intern/BME_mesh.c
+++ b/source/blender/blenkernel/intern/BME_mesh.c
@@ -38,7 +38,7 @@
*/
-
+#include "BLI_listbase.h"
#include "MEM_guardedalloc.h"
#include "BKE_bmesh.h"
#include "bmesh_private.h"
diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c
index 2a16f8f18ff..e36f40c5a54 100644
--- a/source/blender/blenkernel/intern/BME_structure.c
+++ b/source/blender/blenkernel/intern/BME_structure.c
@@ -41,6 +41,7 @@
#include <limits.h>
#include "MEM_guardedalloc.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_bmesh.h"
/**
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 80a40c0a3a3..d3c5942b685 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -38,6 +38,7 @@
#include "BLI_winstuff.h"
#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
#include "BLI_ghash.h"
#include "DNA_anim_types.h"
@@ -1962,7 +1963,7 @@ static void dag_tag_renderlayers(Scene *sce, unsigned int lay)
if(node->id==(ID *)sce) {
SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1);
if(srl && (srl->lay & lay_changed))
- NodeTagChanged(sce->nodetree, node);
+ nodeUpdate(sce->nodetree, node);
}
}
}
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 9c01b35b91a..068e70bbb50 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -64,142 +64,6 @@
static ListBase ttfdata= {NULL, NULL};
-/* UTF-8 <-> wchar transformations */
-size_t chtoutf8(const unsigned long c, char o[4])
-{
- // Variables and initialization
-/* memset(o, 0, 4); */
-
- // Create the utf-8 string
- if (c < 0x80) {
- o[0] = (char) c;
- return 1;
- }
- else if (c < 0x800) {
- o[0] = (0xC0 | (c>>6));
- o[1] = (0x80 | (c & 0x3f));
- return 2;
- }
- else if (c < 0x10000) {
- o[0] = (0xe0 | (c >> 12));
- o[1] = (0x80 | (c >>6 & 0x3f));
- o[2] = (0x80 | (c & 0x3f));
- return 3;
- }
- else if (c < 0x200000) {
- o[0] = (0xf0 | (c>>18));
- o[1] = (0x80 | (c >>12 & 0x3f));
- o[2] = (0x80 | (c >> 6 & 0x3f));
- o[3] = (0x80 | (c & 0x3f));
- return 4;
- }
-
- /* should we assert here? */
- return 0;
-}
-
-void wcs2utf8s(char *dst, const wchar_t *src)
-{
- while(*src) {
- dst += chtoutf8(*src++, dst);
- }
-
- *dst= '\0';
-}
-
-size_t wcsleninu8(wchar_t *src)
-{
- char ch_dummy[4];
- size_t len = 0;
-
- while(*src) {
- len += chtoutf8(*src++, ch_dummy);
- }
-
- return len;
-}
-
-static size_t utf8slen(const char *strc)
-{
- int len=0;
-
- while(*strc) {
- if ((*strc & 0xe0) == 0xc0) {
- if((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00)
- strc++;
- } else if ((*strc & 0xf0) == 0xe0) {
- if((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00)
- strc += 2;
- } else if ((*strc & 0xf8) == 0xf0) {
- if((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00)
- strc += 3;
- }
-
- strc++;
- len++;
- }
-
- return len;
-}
-
-
-/* Converts Unicode to wchar
-
-According to RFC 3629 "UTF-8, a transformation format of ISO 10646"
-(http://tools.ietf.org/html/rfc3629), the valid UTF-8 encoding are:
-
- Char. number range | UTF-8 octet sequence
- (hexadecimal) | (binary)
- --------------------+---------------------------------------------
- 0000 0000-0000 007F | 0xxxxxxx
- 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
- 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
- 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-
-If the encoding incidated by the first character is incorrect (because the
-1 to 3 following characters do not match 10xxxxxx), the output is a '?' and
-only a single input character is consumed.
-
-*/
-
-size_t utf8towchar(wchar_t *w, const char *c)
-{
- int len=0;
-
- if(w==NULL || c==NULL) return(0);
-
- while(*c) {
- if ((*c & 0xe0) == 0xc0) {
- if((c[1] & 0x80) && (c[1] & 0x40) == 0x00) {
- *w=((c[0] &0x1f)<<6) | (c[1]&0x3f);
- c++;
- } else {
- *w = '?';
- }
- } else if ((*c & 0xf0) == 0xe0) {
- if((c[1] & c[2] & 0x80) && ((c[1] | c[2]) & 0x40) == 0x00) {
- *w=((c[0] & 0x0f)<<12) | ((c[1]&0x3f)<<6) | (c[2]&0x3f);
- c += 2;
- } else {
- *w = '?';
- }
- } else if ((*c & 0xf8) == 0xf0) {
- if((c[1] & c[2] & c[3] & 0x80) && ((c[1] | c[2] | c[3]) & 0x40) == 0x00) {
- *w=((c[0] & 0x07)<<18) | ((c[1]&0x1f)<<12) | ((c[2]&0x3f)<<6) | (c[3]&0x3f);
- c += 3;
- } else {
- *w = '?';
- }
- } else
- *w=(c[0] & 0x7f);
-
- c++;
- w++;
- len++;
- }
- return len;
-}
-
/* The vfont code */
void free_vfont(struct VFont *vf)
{
@@ -691,10 +555,10 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m
if(vfont == NULL) return NULL;
// Create unicode string
- utf8len = utf8slen(cu->str);
+ utf8len = BLI_strlen_utf8(cu->str);
mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
- utf8towchar(mem, cu->str);
+ BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1);
// Count the wchar_t string length
slen = wcslen(mem);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index cf8f96c143a..37982e7fec9 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -906,8 +906,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
if (scene->r.stamp & R_STAMP_MARKER) {
char *name = scene_find_last_marker_name(scene, CFRA);
-
- if (name) strcpy(text, name);
+
+ if (name) BLI_strncpy(text, name, sizeof(text));
else strcpy(text, "<none>");
BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text);
@@ -980,7 +980,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
if (scene->r.stamp & R_STAMP_SEQSTRIP) {
Sequence *seq= seq_foreground_frame_get(scene, scene->r.cfra);
- if (seq) strcpy(text, seq->name+2);
+ if (seq) BLI_strncpy(text, seq->name+2, sizeof(text));
else strcpy(text, "<none>");
BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text);
@@ -1514,7 +1514,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
Scene *scene;
for(scene= G.main->scene.first; scene; scene= scene->id.next) {
if(scene->nodetree) {
- NodeTagIDChanged(scene->nodetree, &ima->id);
+ nodeUpdateID(scene->nodetree, &ima->id);
}
}
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 9de75a49998..edddcb4a6b2 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -52,6 +52,9 @@
#include "DNA_meshdata_types.h"
#include "BLI_utildefines.h"
+#include "BLI_path_util.h"
+#include "BLI_listbase.h"
+#include "BLI_string.h"
#include "BKE_bmesh.h"
#include "BKE_cloth.h"
@@ -86,8 +89,8 @@ ModifierData *modifier_new(int type)
ModifierTypeInfo *mti = modifierType_getInfo(type);
ModifierData *md = MEM_callocN(mti->structSize, mti->structName);
- // FIXME: we need to make the name always be unique somehow...
- strcpy(md->name, mti->name);
+ /* note, this name must be made unique later */
+ BLI_strncpy(md->name, mti->name, sizeof(md->name));
md->type = type;
md->mode = eModifierMode_Realtime
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 97347d85deb..15513675c7a 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -42,6 +42,9 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
+#include "BLI_path_util.h"
+#include "BLI_listbase.h"
+#include "BLI_string.h"
#include "BLI_ghash.h"
#include "DNA_anim_types.h"
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index f0be3c99f13..cb1f52a6265 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -184,7 +184,7 @@ bNodeSocket *nodeAddSocket(bNodeTree *ntree, bNode *node, int in_out, const char
else if (in_out==SOCK_OUT)
BLI_addtail(&node->outputs, sock);
- ntree->update |= NTREE_UPDATE_NODES;
+ node->update |= NODE_UPDATE;
return sock;
}
@@ -197,7 +197,7 @@ bNodeSocket *nodeInsertSocket(bNodeTree *ntree, bNode *node, int in_out, bNodeSo
else if (in_out==SOCK_OUT)
BLI_insertlinkbefore(&node->outputs, next_sock, sock);
- ntree->update |= NTREE_UPDATE_NODES;
+ node->update |= NODE_UPDATE;
return sock;
}
@@ -221,7 +221,7 @@ void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock)
MEM_freeN(sock->default_value);
MEM_freeN(sock);
- ntree->update |= NTREE_UPDATE_NODES;
+ node->update |= NODE_UPDATE;
}
void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node)
@@ -246,7 +246,7 @@ void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node)
BLI_freelistN(&node->outputs);
- ntree->update |= NTREE_UPDATE_NODES;
+ node->update |= NODE_UPDATE;
}
/* finds a node based on its name */
@@ -374,7 +374,7 @@ void nodeMakeDynamicType(bNode *node)
/*node->typeinfo= MEM_dupallocN(ntype);*/
bNodeType *newtype= MEM_callocN(sizeof(bNodeType), "dynamic bNodeType");
*newtype= *ntype;
- strcpy(newtype->name, ntype->name);
+ BLI_strncpy(newtype->name, ntype->name, sizeof(newtype->name));
node->typeinfo= newtype;
}
}
@@ -823,7 +823,7 @@ void nodeUnlinkNode(bNodeTree *ntree, bNode *node)
if(link->fromnode==node) {
lb= &node->outputs;
if (link->tonode)
- NodeTagChanged(ntree, link->tonode);
+ link->tonode->update |= NODE_UPDATE;
}
else if(link->tonode==node)
lb= &node->inputs;
@@ -1495,18 +1495,19 @@ void ntreeUpdateTree(bNodeTree *ntree)
/* update individual nodes */
for (n=0; n < totnodes; ++n) {
node = deplist[n];
- if (ntreetype->update_node)
- ntreetype->update_node(ntree, node);
- else if (node->typeinfo->updatefunc)
- node->typeinfo->updatefunc(ntree, node);
+
+ /* node tree update tags override individual node update flags */
+ if ((node->update & NODE_UPDATE) || (ntree->update & NTREE_UPDATE)) {
+ if (ntreetype->update_node)
+ ntreetype->update_node(ntree, node);
+ else if (node->typeinfo->updatefunc)
+ node->typeinfo->updatefunc(ntree, node);
+ }
+ /* clear update flag */
+ node->update = 0;
}
MEM_freeN(deplist);
-
- /* ensures only a single output node is enabled, texnode allows multiple though */
- if(ntree->type!=NTREE_TEXTURE)
- ntreeSetOutput(ntree);
-
}
/* general tree updates */
@@ -1518,6 +1519,9 @@ void ntreeUpdateTree(bNodeTree *ntree)
if (ntreetype->update)
ntreetype->update(ntree);
else {
+ /* Trees can be associated with a specific node type (i.e. group nodes),
+ * in that case a tree update function may be defined by that node type.
+ */
bNodeType *ntype= node_get_type(ntree, ntree->nodetype);
if (ntype && ntype->updatetreefunc)
ntype->updatetreefunc(ntree);
@@ -1530,24 +1534,24 @@ void ntreeUpdateTree(bNodeTree *ntree)
ntree->update = 0;
}
-void NodeTagChanged(bNodeTree *ntree, bNode *node)
+void nodeUpdate(bNodeTree *ntree, bNode *node)
{
- bNodeTreeType *ntreetype = ntreeGetType(ntree->type);
+ bNodeTreeType *ntreetype= ntreeGetType(ntree->type);
- /* extra null pointer checks here because this is called when unlinking
- unknown nodes on file load, so typeinfo pointers may not be set */
- if (ntreetype && ntreetype->update_node)
+ if (ntreetype->update_node)
ntreetype->update_node(ntree, node);
- else if (node->typeinfo && node->typeinfo->updatefunc)
+ else if (node->typeinfo->updatefunc)
node->typeinfo->updatefunc(ntree, node);
+ /* clear update flag */
+ node->update = 0;
}
-int NodeTagIDChanged(bNodeTree *ntree, ID *id)
+int nodeUpdateID(bNodeTree *ntree, ID *id)
{
bNodeTreeType *ntreetype;
bNode *node;
int change = FALSE;
-
+
if(ELEM(NULL, id, ntree))
return change;
@@ -1558,6 +1562,8 @@ int NodeTagIDChanged(bNodeTree *ntree, ID *id)
if(node->id==id) {
change = TRUE;
ntreetype->update_node(ntree, node);
+ /* clear update flag */
+ node->update = 0;
}
}
}
@@ -1567,6 +1573,8 @@ int NodeTagIDChanged(bNodeTree *ntree, ID *id)
change = TRUE;
if (node->typeinfo->updatefunc)
node->typeinfo->updatefunc(ntree, node);
+ /* clear update flag */
+ node->update = 0;
}
}
}
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 2c8975e9cb4..0041cd33c14 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -182,7 +182,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
// convert relative filenames to absolute filenames
- strcpy(name, filename);
+ BLI_strncpy(name, filename, sizeof(name));
BLI_path_abs(name, basepath);
// open the file
@@ -240,7 +240,7 @@ void packAll(Main *bmain, ReportList *reports)
}
-/*
+#if 0
// attempt to create a function that generates an unique filename
// this will work when all funtions in fileops.c understand relative filenames...
@@ -249,6 +249,7 @@ static char *find_new_name(char *name)
{
char tempname[FILE_MAXDIR + FILE_MAXFILE];
char *newname;
+ size_t len;
if (fop_exists(name)) {
for (number = 1; number <= 999; number++) {
@@ -258,14 +259,12 @@ static char *find_new_name(char *name)
}
}
}
-
- newname = mallocN(strlen(tempname) + 1, "find_new_name");
- strcpy(newname, tempname);
-
- return(newname);
+ len= strlen(tempname) + 1;
+ newname = MEM_mallocN(len, "find_new_name");
+ memcpy(newname, tempname, len * sizeof(char));
+ return newname;
}
-
-*/
+#endif
int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, int guimode)
{
@@ -277,12 +276,12 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
if (guimode) {} //XXX waitcursor(1);
- strcpy(name, filename);
+ BLI_strncpy(name, filename, sizeof(name));
BLI_path_abs(name, G.main->name);
if (BLI_exists(name)) {
for (number = 1; number <= 999; number++) {
- sprintf(tempname, "%s.%03d_", name, number);
+ BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number);
if (! BLI_exists(tempname)) {
if (BLI_copy_fileops(name, tempname) == RET_OK) {
remove_tmp = TRUE;
@@ -342,7 +341,7 @@ int checkPackedFile(const char *filename, PackedFile *pf)
char buf[4096];
char name[FILE_MAXDIR + FILE_MAXFILE];
- strcpy(name, filename);
+ BLI_strncpy(name, filename, sizeof(name));
BLI_path_abs(name, G.main->name);
if (stat(name, &st)) {
@@ -392,9 +391,10 @@ there was an error or when the user desides to cancel the operation.
*/
-char *unpackFile(ReportList *reports, char *abs_name, char *local_name, PackedFile *pf, int how)
+char *unpackFile(ReportList *reports, const char *abs_name, const char *local_name, PackedFile *pf, int how)
{
- char *newname = NULL, *temp = NULL;
+ char *newname = NULL;
+ const char *temp = NULL;
// char newabs[FILE_MAXDIR + FILE_MAXFILE];
// char newlocal[FILE_MAXDIR + FILE_MAXFILE];
@@ -437,12 +437,11 @@ char *unpackFile(ReportList *reports, char *abs_name, char *local_name, PackedFi
}
if (temp) {
- newname = MEM_mallocN(strlen(temp) + 1, "unpack_file newname");
- strcpy(newname, temp);
+ newname= BLI_strdup(temp);
}
}
- return (newname);
+ return newname;
}
@@ -453,17 +452,17 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how)
int ret_value = RET_ERROR;
if (vfont != NULL) {
- strcpy(localname, vfont->name);
+ BLI_strncpy(localname, vfont->name, sizeof(localname));
BLI_splitdirstring(localname, fi);
- sprintf(localname, "//fonts/%s", fi);
+ BLI_snprintf(localname, sizeof(localname), "//fonts/%s", fi);
newname = unpackFile(reports, vfont->name, localname, vfont->packedfile, how);
if (newname != NULL) {
ret_value = RET_OK;
freePackedFile(vfont->packedfile);
vfont->packedfile = NULL;
- strcpy(vfont->name, newname);
+ BLI_strncpy(vfont->name, newname, sizeof(vfont->name));
MEM_freeN(newname);
}
}
@@ -478,13 +477,13 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how)
int ret_value = RET_ERROR;
if (sound != NULL) {
- strcpy(localname, sound->name);
+ BLI_strncpy(localname, sound->name, sizeof(localname));
BLI_splitdirstring(localname, fi);
- sprintf(localname, "//sounds/%s", fi);
+ BLI_snprintf(localname, sizeof(localname), "//sounds/%s", fi);
newname = unpackFile(reports, sound->name, localname, sound->packedfile, how);
if (newname != NULL) {
- strcpy(sound->name, newname);
+ BLI_strncpy(sound->name, newname, sizeof(sound->name));
MEM_freeN(newname);
freePackedFile(sound->packedfile);
@@ -506,16 +505,16 @@ int unpackImage(ReportList *reports, Image *ima, int how)
int ret_value = RET_ERROR;
if (ima != NULL) {
- strcpy(localname, ima->name);
+ BLI_strncpy(localname, ima->name, sizeof(localname));
BLI_splitdirstring(localname, fi);
- sprintf(localname, "//textures/%s", fi);
-
+ BLI_snprintf(localname, sizeof(localname), "//textures/%s", fi);
+
newname = unpackFile(reports, ima->name, localname, ima->packedfile, how);
if (newname != NULL) {
ret_value = RET_OK;
freePackedFile(ima->packedfile);
ima->packedfile = NULL;
- strcpy(ima->name, newname);
+ BLI_strncpy(ima->name, newname, sizeof(ima->name));
MEM_freeN(newname);
BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 54af061dedb..66850238284 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -69,7 +69,6 @@
#include "BLI_listbase.h"
#include "BLI_threads.h"
#include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */
-#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_edgehash.h"
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index bc5bc87b1fa..8e5452e2704 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2891,24 +2891,24 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to)
char ext[MAX_PTCACHE_PATH];
/* save old name */
- strcpy(old_name, pid->cache->name);
+ BLI_strncpy(old_name, pid->cache->name, sizeof(old_name));
/* get "from" filename */
- strcpy(pid->cache->name, from);
+ BLI_strncpy(pid->cache->name, from, sizeof(pid->cache->name));
len = ptcache_filename(pid, old_filename, 0, 0, 0); /* no path */
ptcache_path(pid, path);
dir = opendir(path);
if(dir==NULL) {
- strcpy(pid->cache->name, old_name);
+ BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name));
return;
}
BLI_snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index);
/* put new name into cache */
- strcpy(pid->cache->name, to);
+ BLI_strncpy(pid->cache->name, to, sizeof(pid->cache->name));
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
@@ -2963,7 +2963,7 @@ void BKE_ptcache_load_external(PTCacheID *pid)
if(cache->index >= 0)
BLI_snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, cache->index);
else
- strcpy(ext, PTCACHE_EXT);
+ BLI_strncpy(ext, PTCACHE_EXT, sizeof(ext));
while ((de = readdir(dir)) != NULL) {
if (strstr(de->d_name, ext)) { /* do we have the right extension?*/
diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c
index cdf2e39a4dd..e0e2876f79e 100644
--- a/source/blender/blenkernel/intern/property.c
+++ b/source/blender/blenkernel/intern/property.c
@@ -166,7 +166,7 @@ void unique_property(bProperty *first, bProperty *prop, int force)
int i= 0;
/* strip numbers */
- strcpy(base_name, prop->name);
+ BLI_strncpy(base_name, prop->name, sizeof(base_name));
for(i= strlen(base_name)-1; (i>=0 && isdigit(base_name[i])); i--) {
base_name[i]= '\0';
}
@@ -178,7 +178,7 @@ void unique_property(bProperty *first, bProperty *prop, int force)
strcat(new_name, num);
} while(get_property__internal(first, prop, new_name));
- strcpy(prop->name, new_name);
+ BLI_strncpy(prop->name, new_name, sizeof(prop->name));
}
}
}
@@ -257,7 +257,7 @@ void set_property(bProperty *prop, char *str)
*((float *)&prop->data)= (float)atof(str);
break;
case GPROP_STRING:
- strcpy(prop->poin, str);
+ strcpy(prop->poin, str); /* TODO - check size? */
break;
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 00534400cf1..a7c19130929 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -866,8 +866,8 @@ void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq)
SeqUniqueInfo sui;
char *dot;
sui.seq= seq;
- strcpy(sui.name_src, seq->name+2);
- strcpy(sui.name_dest, seq->name+2);
+ BLI_strncpy(sui.name_src, seq->name+2, sizeof(sui.name_src));
+ BLI_strncpy(sui.name_dest, seq->name+2, sizeof(sui.name_dest));
sui.count= 1;
sui.match= 1; /* assume the worst to start the loop */
@@ -887,7 +887,7 @@ void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq)
seqbase_recursive_apply(seqbasep, seqbase_unique_name_recursive_cb, &sui);
}
- strcpy(seq->name+2, sui.name_dest);
+ BLI_strncpy(seq->name+2, sui.name_dest, sizeof(seq->name)-2);
}
static const char *give_seqname_by_type(int type)
@@ -1204,7 +1204,7 @@ static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra,
sorry folks, please rebuild your proxies... */
if (seq->flag & (SEQ_USE_PROXY_CUSTOM_DIR|SEQ_USE_PROXY_CUSTOM_FILE)) {
- strcpy(dir, seq->strip->proxy->dir);
+ BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir));
} else if (seq->type == SEQ_IMAGE) {
BLI_snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir);
} else {
@@ -3360,9 +3360,9 @@ int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
SWAP(Sequence, *seq_a, *seq_b);
/* swap back names so animation fcurves dont get swapped */
- strcpy(name, seq_a->name+2);
- strcpy(seq_a->name+2, seq_b->name+2);
- strcpy(seq_b->name+2, name);
+ BLI_strncpy(name, seq_a->name+2, sizeof(name));
+ BLI_strncpy(seq_a->name+2, seq_b->name+2, sizeof(seq_b->name)-2);
+ BLI_strncpy(seq_b->name+2, name, sizeof(seq_b->name)-2);
/* swap back opacity, and overlay mode */
SWAP(int, seq_a->blend_mode, seq_b->blend_mode);
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 002a4b7ec5a..889db8eb035 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -812,13 +812,12 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
}
}
+#ifdef WITH_SMOKE
// forward decleration
static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct);
static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
-#ifdef WITH_SMOKE
-
static int get_lamp(Scene *scene, float *light)
{
Base *base_tmp = NULL;
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 65b4a21d0ee..8787ec07d9c 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -68,6 +68,7 @@ variables on the UI for now
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
#include "BLI_ghash.h"
#include "BLI_threads.h"
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 07df12d5468..02e381fe9b4 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -79,9 +79,9 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
char str[FILE_MAX];
char *path;
- int len;
+ size_t len;
- strcpy(str, filename);
+ BLI_strncpy(str, filename, sizeof(str));
path = /*bmain ? bmain->name :*/ G.main->name;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index d344f79bb6c..7d720aed62c 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -992,7 +992,7 @@ void autotexname(Tex *tex)
if(tex->type==TEX_IMAGE) {
ima= tex->ima;
if(ima) {
- strcpy(di, ima->name);
+ BLI_strncpy(di, ima->name, sizeof(di));
BLI_splitdirstring(di, fi);
strcpy(di, "I.");
strcat(di, fi);