[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46726] trunk/blender/source/blender/ blenloader/intern/readfile.c: readfile.c Style Cleanup: Whitespace, while - > for, etc.
Joshua Leung
aligorith at gmail.com
Thu May 17 14:59:34 CEST 2012
Revision: 46726
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46726
Author: aligorith
Date: 2012-05-17 12:59:34 +0000 (Thu, 17 May 2012)
Log Message:
-----------
readfile.c Style Cleanup: Whitespace, while -> for, etc.
(3rd time lucky!)
Modified Paths:
--------------
trunk/blender/source/blender/blenloader/intern/readfile.c
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2012-05-17 12:49:33 UTC (rev 46725)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2012-05-17 12:59:34 UTC (rev 46726)
@@ -147,9 +147,6 @@
#include "NOD_socket.h"
-//XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes
-//XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie
-//XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo
#include "BLO_readfile.h"
#include "BLO_undofile.h"
@@ -263,18 +260,18 @@
static void BKE_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...)
{
char fixed_buf[1024]; /* should be long enough */
-
+
va_list args;
-
+
va_start(args, format);
vsnprintf(fixed_buf, sizeof(fixed_buf), format, args);
va_end(args);
-
+
fixed_buf[sizeof(fixed_buf) - 1] = '\0';
-
+
BKE_report(reports, type, fixed_buf);
-
- if (G.background==0) {
+
+ if (G.background == 0) {
printf("%s\n", fixed_buf);
}
}
@@ -283,8 +280,8 @@
{
OldNewMap *onm= MEM_callocN(sizeof(*onm), "OldNewMap");
- onm->entriessize= 1024;
- onm->entries= MEM_mallocN(sizeof(*onm->entries)*onm->entriessize, "OldNewMap.entries");
+ onm->entriessize = 1024;
+ onm->entries = MEM_mallocN(sizeof(*onm->entries)*onm->entriessize, "OldNewMap.entries");
return onm;
}
@@ -293,8 +290,8 @@
{
const struct OldNew *x1=v1, *x2=v2;
- if ( x1->old > x2->old) return 1;
- else if ( x1->old < x2->old) return -1;
+ if (x1->old > x2->old) return 1;
+ else if (x1->old < x2->old) return -1;
return 0;
}
@@ -302,31 +299,31 @@
static void oldnewmap_sort(FileData *fd)
{
qsort(fd->libmap->entries, fd->libmap->nentries, sizeof(OldNew), verg_oldnewmap);
- fd->libmap->sorted= 1;
+ fd->libmap->sorted = 1;
}
/* nr is zero for data, and ID code for libdata */
static void oldnewmap_insert(OldNewMap *onm, void *oldaddr, void *newaddr, int nr)
{
OldNew *entry;
-
+
if (oldaddr==NULL || newaddr==NULL) return;
- if (onm->nentries==onm->entriessize) {
- int osize= onm->entriessize;
- OldNew *oentries= onm->entries;
-
- onm->entriessize*= 2;
- onm->entries= MEM_mallocN(sizeof(*onm->entries)*onm->entriessize, "OldNewMap.entries");
-
+ if (onm->nentries == onm->entriessize) {
+ int osize = onm->entriessize;
+ OldNew *oentries = onm->entries;
+
+ onm->entriessize *= 2;
+ onm->entries = MEM_mallocN(sizeof(*onm->entries)*onm->entriessize, "OldNewMap.entries");
+
memcpy(onm->entries, oentries, sizeof(*oentries)*osize);
MEM_freeN(oentries);
}
- entry= &onm->entries[onm->nentries++];
- entry->old= oldaddr;
- entry->newp= newaddr;
- entry->nr= nr;
+ entry = &onm->entries[onm->nentries++];
+ entry->old = oldaddr;
+ entry->newp = newaddr;
+ entry->nr = nr;
}
void blo_do_versions_oldnewmap_insert(OldNewMap *onm, void *oldaddr, void *newaddr, int nr)
@@ -337,29 +334,29 @@
static void *oldnewmap_lookup_and_inc(OldNewMap *onm, void *addr)
{
int i;
-
- if (addr==NULL) return NULL;
-
- if (onm->lasthit<onm->nentries-1) {
- OldNew *entry= &onm->entries[++onm->lasthit];
-
- if (entry->old==addr) {
+
+ if (addr == NULL) return NULL;
+
+ if (onm->lasthit < onm->nentries-1) {
+ OldNew *entry = &onm->entries[++onm->lasthit];
+
+ if (entry->old == addr) {
entry->nr++;
return entry->newp;
}
}
-
- for (i=0; i<onm->nentries; i++) {
- OldNew *entry= &onm->entries[i];
-
- if (entry->old==addr) {
- onm->lasthit= i;
-
+
+ for (i = 0; i < onm->nentries; i++) {
+ OldNew *entry = &onm->entries[i];
+
+ if (entry->old == addr) {
+ onm->lasthit = i;
+
entry->nr++;
return entry->newp;
}
}
-
+
return NULL;
}
@@ -368,17 +365,17 @@
{
int i;
- if (addr==NULL) return NULL;
+ if (addr == NULL) return NULL;
/* lasthit works fine for non-libdata, linking there is done in same sequence as writing */
if (onm->sorted) {
OldNew entry_s, *entry;
- entry_s.old= addr;
+ entry_s.old = addr;
- entry= bsearch(&entry_s, onm->entries, onm->nentries, sizeof(OldNew), verg_oldnewmap);
+ entry = bsearch(&entry_s, onm->entries, onm->nentries, sizeof(OldNew), verg_oldnewmap);
if (entry) {
- ID *id= entry->newp;
+ ID *id = entry->newp;
if (id && (!lib || id->lib)) {
return entry->newp;
@@ -386,12 +383,12 @@
}
}
- for (i=0; i<onm->nentries; i++) {
- OldNew *entry= &onm->entries[i];
-
- if (entry->old==addr) {
- ID *id= entry->newp;
-
+ for (i = 0; i < onm->nentries; i++) {
+ OldNew *entry = &onm->entries[i];
+
+ if (entry->old == addr) {
+ ID *id = entry->newp;
+
if (id && (!lib || id->lib)) {
return entry->newp;
}
@@ -405,19 +402,19 @@
{
int i;
- for (i=0; i<onm->nentries; i++) {
- OldNew *entry= &onm->entries[i];
- if (entry->nr==0) {
+ for (i = 0; i < onm->nentries; i++) {
+ OldNew *entry = &onm->entries[i];
+ if (entry->nr == 0) {
MEM_freeN(entry->newp);
- entry->newp= NULL;
+ entry->newp = NULL;
}
}
}
static void oldnewmap_clear(OldNewMap *onm)
{
- onm->nentries= 0;
- onm->lasthit= 0;
+ onm->nentries = 0;
+ onm->lasthit = 0;
}
static void oldnewmap_free(OldNewMap *onm)
@@ -436,9 +433,9 @@
{
ListBase *lbarray[MAX_LIBARRAY], *fromarray[MAX_LIBARRAY];
int a;
-
+
set_listbasepointers(mainvar, lbarray);
- a= set_listbasepointers(from, fromarray);
+ a = set_listbasepointers(from, fromarray);
while (a--) {
BLI_movelisttolist(lbarray[a], fromarray[a]);
}
@@ -448,9 +445,8 @@
{
Main *tojoin, *mainl;
-
- mainl= mainlist->first;
- while ((tojoin= mainl->next)) {
+ mainl = mainlist->first;
+ while ((tojoin = mainl->next)) {
add_main_to_main(mainl, tojoin);
BLI_remlink(mainlist, tojoin);
MEM_freeN(tojoin);
@@ -462,24 +458,24 @@
ListBase *lbn;
ID *id, *idnext;
Main *mainvar;
-
- id= lb->first;
+
+ id = lb->first;
while (id) {
- idnext= id->next;
+ idnext = id->next;
if (id->lib) {
- mainvar= first;
+ mainvar = first;
while (mainvar) {
- if (mainvar->curlib==id->lib) {
+ if (mainvar->curlib == id->lib) {
lbn= which_libbase(mainvar, GS(id->name));
BLI_remlink(lb, id);
BLI_addtail(lbn, id);
break;
}
- mainvar= mainvar->next;
+ mainvar = mainvar->next;
}
- if (mainvar==NULL) printf("error split_libdata\n");
+ if (mainvar == NULL) printf("error split_libdata\n");
}
- id= idnext;
+ id = idnext;
}
}
@@ -488,20 +484,20 @@
ListBase *lbarray[MAX_LIBARRAY];
Library *lib;
int i;
-
- mainlist->first= mainlist->last= main;
- main->next= NULL;
-
- if (main->library.first==NULL)
+
+ mainlist->first = mainlist->last = main;
+ main->next = NULL;
+
+ if (main->library.first == NULL)
return;
- for (lib= main->library.first; lib; lib= lib->id.next) {
- Main *libmain= MEM_callocN(sizeof(Main), "libmain");
- libmain->curlib= lib;
+ for (lib = main->library.first; lib; lib = lib->id.next) {
+ Main *libmain = MEM_callocN(sizeof(Main), "libmain");
+ libmain->curlib = lib;
BLI_addtail(mainlist, libmain);
}
-
- i= set_listbasepointers(main, lbarray);
+
+ i = set_listbasepointers(main, lbarray);
while (i--)
split_libdata(lbarray[i], main->next);
}
@@ -521,7 +517,7 @@
BHead *bhead;
for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
- if (bhead->code==GLOB) {
+ if (bhead->code == GLOB) {
FileGlobal *fg= read_struct(fd, bhead, "Global");
if (fg) {
main->subversionfile= fg->subversion;
@@ -529,7 +525,7 @@
main->minsubversionfile= fg->minsubversion;
MEM_freeN(fg);
}
- else if (bhead->code==ENDB)
+ else if (bhead->code == ENDB)
break;
}
}
@@ -546,24 +542,24 @@
cleanup_path(relabase, name1);
// printf("blo_find_main: original in %s\n", name);
// printf("blo_find_main: converted to %s\n", name1);
-
- for (m= mainlist->first; m; m= m->next) {
- char *libname= (m->curlib)?m->curlib->filepath:m->name;
+
+ for (m = mainlist->first; m; m = m->next) {
+ char *libname = (m->curlib) ? m->curlib->filepath : m->name;
if (BLI_path_cmp(name1, libname) == 0) {
if (G.debug & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
return m;
}
}
-
- m= MEM_callocN(sizeof(Main), "find_main");
+
+ m = MEM_callocN(sizeof(Main), "find_main");
BLI_addtail(mainlist, m);
-
- lib= BKE_libblock_alloc(&m->library, ID_LI, "lib");
+
+ lib = BKE_libblock_alloc(&m->library, ID_LI, "lib");
BLI_strncpy(lib->name, filepath, sizeof(lib->name));
BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
- m->curlib= lib;
+ m->curlib = lib;
read_file_version(fd, m);
@@ -577,8 +573,8 @@
static void switch_endian_bh4(BHead4 *bhead)
{
/* the ID_.. codes */
- if ((bhead->code & 0xFFFF)==0) bhead->code >>=16;
-
+ if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16;
+
if (bhead->code != ENDB) {
SWITCH_INT(bhead->len);
SWITCH_INT(bhead->SDNAnr);
@@ -589,8 +585,8 @@
static void switch_endian_bh8(BHead8 *bhead)
{
/* the ID_.. codes */
- if ((bhead->code & 0xFFFF)==0) bhead->code >>=16;
-
+ if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16;
+
if (bhead->code != ENDB) {
SWITCH_INT(bhead->len);
SWITCH_INT(bhead->SDNAnr);
@@ -607,37 +603,37 @@
long long old;
#endif
- bhead4->code= bhead8->code;
- bhead4->len= bhead8->len;
+ bhead4->code = bhead8->code;
+ bhead4->len = bhead8->len;
if (bhead4->code != ENDB) {
-
- //perform a endian swap on 64bit pointers, otherwise the pointer might map to zero
- //0x0000000000000000000012345678 would become 0x12345678000000000000000000000000
+ /* perform a endian swap on 64bit pointers, otherwise the pointer might map to zero
+ * 0x0000000000000000000012345678 would become 0x12345678000000000000000000000000
+ */
if (do_endian_swap) {
SWITCH_LONGINT(bhead8->old);
}
-
+
/* this patch is to avoid a long long being read from not-eight aligned positions
* is necessary on any modern 64bit architecture) */
memcpy(&old, &bhead8->old, 8);
bhead4->old = (int) (old >> 3);
-
- bhead4->SDNAnr= bhead8->SDNAnr;
- bhead4->nr= bhead8->nr;
+
+ bhead4->SDNAnr = bhead8->SDNAnr;
+ bhead4->nr = bhead8->nr;
}
}
static void bh8_from_bh4(BHead *bhead, BHead4 *bhead4)
{
BHead8 *bhead8 = (BHead8 *) bhead;
-
- bhead8->code= bhead4->code;
- bhead8->len= bhead4->len;
-
+
+ bhead8->code = bhead4->code;
+ bhead8->len = bhead4->len;
+
if (bhead8->code != ENDB) {
- bhead8->old= bhead4->old;
- bhead8->SDNAnr= bhead4->SDNAnr;
+ bhead8->old = bhead4->old;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list