|
From: <kin...@us...> - 2024-07-17 17:50:52
|
Revision: 7215
http://sourceforge.net/p/teem/code/7215
Author: kindlmann
Date: 2024-07-17 17:50:48 +0000 (Wed, 17 Jul 2024)
Log Message:
-----------
fixing uses of AIR_STRLEN_x plus clang-format
Modified Paths:
--------------
teem/trunk/Testing/nrrd/macros.c
teem/trunk/Testing/nrrd/tbspec.c
teem/trunk/Testing/nrrd/tload.c
teem/trunk/Testing/nrrd/tskip.c
Modified: teem/trunk/Testing/nrrd/macros.c
===================================================================
--- teem/trunk/Testing/nrrd/macros.c 2024-07-17 17:48:07 UTC (rev 7214)
+++ teem/trunk/Testing/nrrd/macros.c 2024-07-17 17:50:48 UTC (rev 7215)
@@ -33,15 +33,12 @@
int
main() {
- size_t II, *coord0, *ctmp0, *size0,
- coord1[1], ctmp1[1], size1[1],
- coord2[2], ctmp2[2], size2[2],
- coord3[3], ctmp3[3], size3[3],
- coord4[4], ctmp4[4], size4[4];
- char sbuff[NRRD_DIM_MAX*AIR_STRLEN_SMALL],
- scomp[NRRD_DIM_MAX*AIR_STRLEN_SMALL],
- sigab[NRRD_DIM_MAX*AIR_STRLEN_SMALL], /* index gen and back */
- swhat[NRRD_DIM_MAX*AIR_STRLEN_SMALL];
+ size_t II, *coord0, *ctmp0, *size0, coord1[1], ctmp1[1], size1[1], coord2[2], ctmp2[2],
+ size2[2], coord3[3], ctmp3[3], size3[3], coord4[4], ctmp4[4], size4[4];
+ char sbuff[NRRD_DIM_MAX * AIR_STRLEN_SMALL + 1],
+ scomp[NRRD_DIM_MAX * AIR_STRLEN_SMALL + 1],
+ sigab[NRRD_DIM_MAX * AIR_STRLEN_SMALL + 1], /* index gen and back */
+ swhat[NRRD_DIM_MAX * AIR_STRLEN_SMALL + 1];
unsigned int ii, jj, kk, ll;
/* This macro makes sure the given length-N coord##N vector is what it
@@ -49,24 +46,22 @@
airSprintVecSize_t. Also uses NRRD_INDEX_GEN and NRRD_COORD_GEN
to go from coord##N to a linear index II and back to ctmp##N,
and makes sure that that too matches "want" */
-#define CHECK(N, want) \
- airSprintVecSize_t(swhat, size##N, N); \
- airSprintVecSize_t(sbuff, coord##N, N); \
- if (strcmp(sbuff, want)) { \
- fprintf(stderr, "for %s: got %s but wanted %s\n", \
- swhat, sbuff, want); \
- return 1; \
- } \
- NRRD_INDEX_GEN(II, coord##N, size##N, N); \
- NRRD_COORD_GEN(ctmp##N, size##N, N, II); \
- airSprintVecSize_t(sigab, ctmp##N, N); \
- if (strcmp(sbuff, want)) { \
- fprintf(stderr, "for %s: NRRD_{INDEX,COORD}_GEN gave %s but want %s\n", \
- swhat, sbuff, want); \
- return 1; \
+#define CHECK(N, want) \
+ airSprintVecSize_t(swhat, size##N, N); \
+ airSprintVecSize_t(sbuff, coord##N, N); \
+ if (strcmp(sbuff, want)) { \
+ fprintf(stderr, "for %s: got %s but wanted %s\n", swhat, sbuff, want); \
+ return 1; \
+ } \
+ NRRD_INDEX_GEN(II, coord##N, size##N, N); \
+ NRRD_COORD_GEN(ctmp##N, size##N, N, II); \
+ airSprintVecSize_t(sigab, ctmp##N, N); \
+ if (strcmp(sbuff, want)) { \
+ fprintf(stderr, "for %s: NRRD_{INDEX,COORD}_GEN gave %s but want %s\n", swhat, \
+ sbuff, want); \
+ return 1; \
}
-
/* actually airTime will always be positive; this is just to thwart the
compiler thinking coord0 and size0 are necessarily NULL */
if (airTime() > -100) {
@@ -90,17 +85,17 @@
/* 11111111111111111111111111111111111111111111111 */
-#define RUN1 \
- coord1[0] = 0; \
- for (ii=0; ii<size1[0]; ii++) { \
- if (ii) { \
- /* don't increment on the very first time, otherwise do */ \
- NRRD_COORD_INCR(coord1, size1, 1, 0); \
- } \
- airSprintVecSize_t(sbuff, coord1, 1); \
- sprintf(scomp, "[%u]", ii); \
- CHECK(1, scomp); \
- } \
+#define RUN1 \
+ coord1[0] = 0; \
+ for (ii = 0; ii < size1[0]; ii++) { \
+ if (ii) { \
+ /* don't increment on the very first time, otherwise do */ \
+ NRRD_COORD_INCR(coord1, size1, 1, 0); \
+ } \
+ airSprintVecSize_t(sbuff, coord1, 1); \
+ sprintf(scomp, "[%u]", ii); \
+ CHECK(1, scomp); \
+ }
size1[0] = 1;
RUN1;
@@ -110,18 +105,18 @@
/* 22222222222222222222222222222222222222222222222 */
-#define RUN2 \
- coord2[0] = coord2[1] = 0; \
- for (jj=0; jj<size2[1]; jj++) { \
- for (ii=0; ii<size2[0]; ii++) { \
- if (ii || jj) { \
- /* don't increment on the very first time, otherwise do */ \
- NRRD_COORD_INCR(coord2, size2, 2, 0); \
- } \
- airSprintVecSize_t(sbuff, coord2, 2); \
- sprintf(scomp, "[%u,%u]", ii, jj); \
- CHECK(2, scomp); \
- } \
+#define RUN2 \
+ coord2[0] = coord2[1] = 0; \
+ for (jj = 0; jj < size2[1]; jj++) { \
+ for (ii = 0; ii < size2[0]; ii++) { \
+ if (ii || jj) { \
+ /* don't increment on the very first time, otherwise do */ \
+ NRRD_COORD_INCR(coord2, size2, 2, 0); \
+ } \
+ airSprintVecSize_t(sbuff, coord2, 2); \
+ sprintf(scomp, "[%u,%u]", ii, jj); \
+ CHECK(2, scomp); \
+ } \
}
ELL_2V_SET(size2, 1, 1);
@@ -138,20 +133,20 @@
/* 33333333333333333333333333333333333333333333333 */
-#define RUN3 \
- coord3[0] = coord3[1] = coord3[2] = 0; \
- for (kk=0; kk<size3[2]; kk++) { \
- for (jj=0; jj<size3[1]; jj++) { \
- for (ii=0; ii<size3[0]; ii++) { \
- if (ii || jj || kk) { \
- /* don't increment on the very first time, otherwise do */ \
- NRRD_COORD_INCR(coord3, size3, 3, 0); \
- } \
- airSprintVecSize_t(sbuff, coord3, 3); \
- sprintf(scomp, "[%u,%u,%u]", ii, jj, kk); \
- CHECK(3, scomp); \
- } \
- } \
+#define RUN3 \
+ coord3[0] = coord3[1] = coord3[2] = 0; \
+ for (kk = 0; kk < size3[2]; kk++) { \
+ for (jj = 0; jj < size3[1]; jj++) { \
+ for (ii = 0; ii < size3[0]; ii++) { \
+ if (ii || jj || kk) { \
+ /* don't increment on the very first time, otherwise do */ \
+ NRRD_COORD_INCR(coord3, size3, 3, 0); \
+ } \
+ airSprintVecSize_t(sbuff, coord3, 3); \
+ sprintf(scomp, "[%u,%u,%u]", ii, jj, kk); \
+ CHECK(3, scomp); \
+ } \
+ } \
}
ELL_3V_SET(size3, 1, 1, 1);
@@ -171,22 +166,22 @@
/* 44444444444444444444444444444444444444444444444 */
-#define RUN4 \
- coord4[0] = coord4[1] = coord4[2] = coord4[3] = 0; \
- for (ll=0; ll<size4[3]; ll++) { \
- for (kk=0; kk<size4[2]; kk++) { \
- for (jj=0; jj<size4[1]; jj++) { \
- for (ii=0; ii<size4[0]; ii++) { \
- if (ii || jj || kk || ll) { \
- /* don't increment on the very first time, otherwise do */ \
- NRRD_COORD_INCR(coord4, size4, 4, 0); \
- } \
- airSprintVecSize_t(sbuff, coord4, 4); \
- sprintf(scomp, "[%u,%u,%u,%u]", ii, jj, kk, ll); \
- CHECK(4, scomp); \
- } \
- } \
- } \
+#define RUN4 \
+ coord4[0] = coord4[1] = coord4[2] = coord4[3] = 0; \
+ for (ll = 0; ll < size4[3]; ll++) { \
+ for (kk = 0; kk < size4[2]; kk++) { \
+ for (jj = 0; jj < size4[1]; jj++) { \
+ for (ii = 0; ii < size4[0]; ii++) { \
+ if (ii || jj || kk || ll) { \
+ /* don't increment on the very first time, otherwise do */ \
+ NRRD_COORD_INCR(coord4, size4, 4, 0); \
+ } \
+ airSprintVecSize_t(sbuff, coord4, 4); \
+ sprintf(scomp, "[%u,%u,%u,%u]", ii, jj, kk, ll); \
+ CHECK(4, scomp); \
+ } \
+ } \
+ } \
}
ELL_4V_SET(size4, 1, 1, 1, 1);
Modified: teem/trunk/Testing/nrrd/tbspec.c
===================================================================
--- teem/trunk/Testing/nrrd/tbspec.c 2024-07-17 17:48:07 UTC (rev 7214)
+++ teem/trunk/Testing/nrrd/tbspec.c 2024-07-17 17:50:48 UTC (rev 7215)
@@ -35,7 +35,7 @@
void
checkFailOrDie(const NrrdBoundarySpec *bspec, airArray *mop) {
- static const char me[]="checkFailOrDie";
+ static const char me[] = "checkFailOrDie";
char *err;
if (!nrrdBoundarySpecCheck(bspec)) {
@@ -53,7 +53,7 @@
void
parseFailOrDie(NrrdBoundarySpec *bspec, const char *str, airArray *mop) {
- static const char me[]="parseFailOrDie";
+ static const char me[] = "parseFailOrDie";
char *err;
if (!nrrdBoundarySpecParse(bspec, str)) {
@@ -74,14 +74,12 @@
** not on the strings, but that isn't implemented yet
*/
void
-psLoopOrDie(NrrdBoundarySpec *bsp, const char *str,
- airArray *mop) {
- static const char me[]="psLoopOrDie";
+psLoopOrDie(NrrdBoundarySpec *bsp, const char *str, airArray *mop) {
+ static const char me[] = "psLoopOrDie";
char *err;
- char buff[AIR_STRLEN_LARGE];
+ char buff[AIR_STRLEN_LARGE + 1];
- if (nrrdBoundarySpecParse(bsp, str)
- || nrrdBoundarySpecSprint(buff, bsp)) {
+ if (nrrdBoundarySpecParse(bsp, str) || nrrdBoundarySpecSprint(buff, bsp)) {
err = biffGetDone(NRRD);
airMopAdd(mop, err, airFree, airMopAlways);
fprintf(stderr, "%s: error: %s", me, err);
@@ -89,8 +87,7 @@
exit(1);
}
if (strcmp(str, buff)) {
- fprintf(stderr, "%s: parse->sprint->\"%s\" != given \"%s\"\n", me,
- buff, str);
+ fprintf(stderr, "%s: parse->sprint->\"%s\" != given \"%s\"\n", me, buff, str);
airMopError(mop);
exit(1);
}
@@ -98,14 +95,13 @@
return;
}
-static const char *tbspecInfo =
- "for testing handling of boundary specifications";
+static const char *tbspecInfo = "for testing handling of boundary specifications";
int
main(int argc, const char *argv[]) {
/* stock variables */
const char *me;
- hestOpt *hopt=NULL;
+ hestOpt *hopt = NULL;
hestParm *hparm;
airArray *mop;
/* variables specific to this program */
@@ -112,25 +108,26 @@
char *err;
NrrdBoundarySpec *bspec, **bsv;
unsigned int bsNum, bsIdx;
- char buff[AIR_STRLEN_LARGE];
+ char buff[AIR_STRLEN_LARGE + 1];
me = argv[0];
mop = airMopNew();
hparm = hestParmNew();
airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways);
- hestOptAdd(&hopt, "bs", "bspec0", airTypeOther, 1, -1, &bsv, NULL,
- "bspecs", &bsNum, NULL, nrrdHestBoundarySpec);
- hestParseOrDie(hopt, argc-1, argv+1, hparm, me, tbspecInfo,
- AIR_TRUE, AIR_TRUE, AIR_TRUE);
+ hestOptAdd(&hopt, "bs", "bspec0", airTypeOther, 1, -1, &bsv, NULL, "bspecs", &bsNum,
+ NULL, nrrdHestBoundarySpec);
+ hestParseOrDie(hopt, argc - 1, argv + 1, hparm, me, tbspecInfo, AIR_TRUE, AIR_TRUE,
+ AIR_TRUE);
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
printf("command line options:\n");
- for (bsIdx=0; bsIdx<bsNum; bsIdx++) {
+ for (bsIdx = 0; bsIdx < bsNum; bsIdx++) {
if (nrrdBoundarySpecSprint(buff, bsv[bsIdx])) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: problem with bsv[%u]:%s", me, bsIdx, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
printf("%s: bspec[%u] = %s\n", me, bsIdx, buff);
}
Modified: teem/trunk/Testing/nrrd/tload.c
===================================================================
--- teem/trunk/Testing/nrrd/tload.c 2024-07-17 17:48:07 UTC (rev 7214)
+++ teem/trunk/Testing/nrrd/tload.c 2024-07-17 17:50:48 UTC (rev 7215)
@@ -48,21 +48,21 @@
if (nrrdLoad(nin, fullname, NULL)) {
char *err;
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
- fprintf(stderr, "%s: trouble reading data \"%s\":\n%s",
- me, fullname, err);
- airMopError(mop); return 1;
+ fprintf(stderr, "%s: trouble reading data \"%s\":\n%s", me, fullname, err);
+ airMopError(mop);
+ return 1;
}
{
Nrrd *ncopy;
- char *blah, *blah1L, explain[AIR_STRLEN_LARGE];
+ char *blah, *blah1L, explain[AIR_STRLEN_LARGE + 1];
size_t ii, blen;
ncopy = nrrdNew();
airMopAdd(mop, ncopy, (airMopper)nrrdNuke, airMopAlways);
- blen = AIR_STRLEN_HUGE*42;
+ blen = AIR_STRLEN_HUGE * 42;
blah = AIR_CALLOC(blen, char);
airMopAdd(mop, blah, airFree, airMopAlways);
- for (ii=0; ii<blen-1; ii++) {
+ for (ii = 0; ii < blen - 1; ii++) {
/* NOTE: a more rigorous test would put things in here that can't
be directly written to file, like \r \v \f, but fixing that bug
is enough of a significant change to functionality that it should
@@ -69,7 +69,7 @@
be discussed with users first */
blah[ii] = ("abcdefghijklmnopqrtsuvzwyz\n\"\\ "
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\n\"\\ ")
- [airRandInt((26 + 4)*2)]; /* 4 other characters */
+ [airRandInt((26 + 4) * 2)]; /* 4 other characters */
}
blah[ii] = '\0';
/* NOTE: this blah1L is to overcome a long-stanging bug that \n's
@@ -82,48 +82,49 @@
work */
blah1L = airOneLinify(airStrdup(blah));
airMopAdd(mop, blah1L, airFree, airMopAlways);
- nrrdAxisInfoSet_va(nin, nrrdAxisInfoLabel,
- "first axis label", "2nd axis label",
+ nrrdAxisInfoSet_va(nin, nrrdAxisInfoLabel, "first axis label", "2nd axis label",
blah1L);
nin->spaceUnits[0] = airOneLinify(airStrdup("\nsp\"\nu0\n"));
nin->spaceUnits[1] = airStrdup("bob");
- nin->spaceUnits[2] = airStrdup(blah1L); /* see NOTE above */
+ nin->spaceUnits[2] = airStrdup(blah1L); /* see NOTE above */
if (nrrdCommentAdd(nin, "the first comment")
- || nrrdCommentAdd(nin, "very long comment follows")
- || nrrdCommentAdd(nin, blah)
+ || nrrdCommentAdd(nin, "very long comment follows") || nrrdCommentAdd(nin, blah)
|| nrrdKeyValueAdd(nin, "first key", "first value")
|| nrrdKeyValueAdd(nin, "2nd key", "2nd value")
|| nrrdKeyValueAdd(nin, "big key", blah)) {
char *err;
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
- fprintf(stderr, "%s: trouble w/ comments or KVPs:\n%s",
- me, err);
- airMopError(mop); return 1;
+ fprintf(stderr, "%s: trouble w/ comments or KVPs:\n%s", me, err);
+ airMopError(mop);
+ return 1;
}
if (nrrdCopy(ncopy, nin)
- || nrrdCompare(nin, ncopy, AIR_FALSE /* onlyData */,
- 0.0 /* epsilon */, &differ, explain)) {
+ || nrrdCompare(nin, ncopy, AIR_FALSE /* onlyData */, 0.0 /* epsilon */, &differ,
+ explain)) {
char *err;
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble w/ copy or compare:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (differ) {
fprintf(stderr, "%s: difference in in-memory copy: %s\n", me, explain);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
- if (nrrdSave("tloadTest.nrrd", nin, NULL)
- || nrrdLoad(ncopy, "tloadTest.nrrd", NULL)
- || nrrdCompare(nin, ncopy, AIR_FALSE /* onlyData */,
- 0.0 /* epsilon */, &differ, explain)) {
+ if (nrrdSave("tloadTest.nrrd", nin, NULL) || nrrdLoad(ncopy, "tloadTest.nrrd", NULL)
+ || nrrdCompare(nin, ncopy, AIR_FALSE /* onlyData */, 0.0 /* epsilon */, &differ,
+ explain)) {
char *err;
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble w/ save, load, compare:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (differ) {
fprintf(stderr, "%s: difference in on-disk copy: %s\n", me, explain);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
Modified: teem/trunk/Testing/nrrd/tskip.c
===================================================================
--- teem/trunk/Testing/nrrd/tskip.c 2024-07-17 17:48:07 UTC (rev 7214)
+++ teem/trunk/Testing/nrrd/tskip.c 2024-07-17 17:50:48 UTC (rev 7215)
@@ -43,7 +43,7 @@
main(int argc, const char **argv) {
/* stock variables */
char me[] = BKEY;
- hestOpt *hopt=NULL;
+ hestOpt *hopt = NULL;
hestParm *hparm;
airArray *mop;
/* variables specific to this program */
@@ -51,7 +51,7 @@
Nrrd *nref, *nin;
size_t *size, ii, nn, tick, pad[2];
unsigned int axi, refCRC, gotCRC, sizeNum;
- char *berr, *outS[2], stmp[AIR_STRLEN_SMALL], doneStr[AIR_STRLEN_SMALL];
+ char *berr, *outS[2], stmp[AIR_STRLEN_SMALL + 1], doneStr[AIR_STRLEN_SMALL + 1];
airRandMTState *rng;
unsigned int seed, *rdata, printbytes;
unsigned char *dataUC;
@@ -63,8 +63,7 @@
hparm = hestParmNew();
airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways);
/* learn things from hest */
- hestOptAdd(&hopt, "seed", "N", airTypeUInt, 1, 1, &seed, "42",
- "seed for RNG");
+ hestOptAdd(&hopt, "seed", "N", airTypeUInt, 1, 1, &seed, "42", "seed for RNG");
hestOptAdd(&hopt, "s", "sz0", airTypeSize_t, 1, -1, &size, NULL,
"sizes of desired output", &sizeNum);
hestOptAdd(&hopt, "p", "pb pa", airTypeSize_t, 2, 2, pad, "0 0",
@@ -75,10 +74,10 @@
hestOptAdd(&hopt, "pb", "print", airTypeUInt, 1, 1, &printbytes, "0",
"bytes to print at beginning and end of data, to help "
"debug problems");
- hestOptAdd(&hopt, "o", "out.data out.nhdr", airTypeString, 2, 2,
- outS, NULL, "output filenames of data and header");
- hestParseOrDie(hopt, argc-1, argv+1, hparm, me, tskipInfo,
- AIR_TRUE, AIR_TRUE, AIR_TRUE);
+ hestOptAdd(&hopt, "o", "out.data out.nhdr", airTypeString, 2, 2, outS, NULL,
+ "output filenames of data and header");
+ hestParseOrDie(hopt, argc - 1, argv + 1, hparm, me, tskipInfo, AIR_TRUE, AIR_TRUE,
+ AIR_TRUE);
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
@@ -86,19 +85,21 @@
nref = nrrdNew();
airMopAdd(mop, nref, (airMopper)nrrdNuke, airMopAlways);
if (nrrdMaybeAlloc_nva(nref, nrrdTypeUInt, sizeNum, size)) {
- airMopAdd(mop, berr=biffGetDone(NRRD), airFree, airMopAlways);
+ airMopAdd(mop, berr = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error allocating data: %s\n", me, berr);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
rng = airRandMTStateNew(seed);
airMopAdd(mop, rng, (airMopper)airRandMTStateNix, airMopAlways);
nn = nrrdElementNumber(nref);
rdata = AIR_CAST(unsigned int *, nref->data);
- fprintf(stderr, "generating data: . . . "); fflush(stderr);
+ fprintf(stderr, "generating data: . . . ");
+ fflush(stderr);
time0 = airTime();
progress = AIR_FALSE;
- tick = nn/100;
- for (ii=0; ii<nn; ii++) {
+ tick = nn / 100;
+ for (ii = 0; ii < nn; ii++) {
rdata[ii] = airUIrandMT_r(rng);
if (ii && tick && !(ii % tick)) {
time1 = airTime();
@@ -108,77 +109,85 @@
progress = AIR_TRUE;
}
if (progress) {
- fprintf(stderr, "%s", airDoneStr(0, ii, nn, doneStr)); fflush(stderr);
+ fprintf(stderr, "%s", airDoneStr(0, ii, nn, doneStr));
+ fflush(stderr);
}
}
}
if (progress) {
- fprintf(stderr, "%s\n", airDoneStr(0, ii, nn, doneStr)); fflush(stderr);
+ fprintf(stderr, "%s\n", airDoneStr(0, ii, nn, doneStr));
+ fflush(stderr);
} else {
fprintf(stderr, "\n");
}
- fprintf(stderr, "finding reference (big-endian) CRC: "); fflush(stderr);
+ fprintf(stderr, "finding reference (big-endian) CRC: ");
+ fflush(stderr);
refCRC = nrrdCRC32(nref, airEndianBig);
fprintf(stderr, "%u\n", refCRC);
/* write data, with padding */
- fprintf(stderr, "saving data . . . "); fflush(stderr);
+ fprintf(stderr, "saving data . . . ");
+ fflush(stderr);
if (!(fout = fopen(outS[0], "wb" COMMIT))) {
- fprintf(stderr, "\n%s: couldn't open %s for writing: %s\n", me,
- outS[0], strerror(errno));
- airMopError(mop); return 1;
+ fprintf(stderr, "\n%s: couldn't open %s for writing: %s\n", me, outS[0],
+ strerror(errno));
+ airMopError(mop);
+ return 1;
}
airMopAdd(mop, fout, (airMopper)airFclose, airMopAlways);
- for (ii=0; ii<pad[0]; ii++) {
+ for (ii = 0; ii < pad[0]; ii++) {
if (EOF == fputc(1, fout)) {
fprintf(stderr, "\n%s: error doing pre-padding\n", me);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
if (nn != fwrite(nref->data, nrrdElementSize(nref), nn, fout)) {
fprintf(stderr, "\n%s: error writing data\n", me);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
- for (ii=0; ii<pad[1]; ii++) {
+ for (ii = 0; ii < pad[1]; ii++) {
if (EOF == fputc(2, fout)) {
fprintf(stderr, "\n%s: error doing post-padding\n", me);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
if (EOF == fflush(fout)) {
- fprintf(stderr, "\n%s: error fflushing data: %s\n", me,
- strerror(errno));
+ fprintf(stderr, "\n%s: error fflushing data: %s\n", me, strerror(errno));
}
fprintf(stderr, "\n");
if (printbytes) {
size_t bi, rpb, local_nn;
- char local_stmp[AIR_STRLEN_SMALL];
- local_nn = nrrdElementSize(nref)*nrrdElementNumber(nref);
+ char local_stmp[AIR_STRLEN_SMALL + 1];
+ local_nn = nrrdElementSize(nref) * nrrdElementNumber(nref);
rpb = AIR_MIN(printbytes, local_nn);
dataUC = AIR_CAST(unsigned char *, nref->data);
fprintf(stderr, "CORRECT %s bytes at beginning:\n",
airSprintSize_t(local_stmp, rpb));
- for (bi=0; bi<rpb; bi++) {
+ for (bi = 0; bi < rpb; bi++) {
fprintf(stderr, "%x ", dataUC[bi]);
}
fprintf(stderr, "...\n");
- fprintf(stderr, "CORRECT %s bytes at end:\n",
- airSprintSize_t(local_stmp, rpb));
+ fprintf(stderr, "CORRECT %s bytes at end:\n", airSprintSize_t(local_stmp, rpb));
fprintf(stderr, "...");
- for (bi=local_nn - rpb; bi<local_nn; bi++) {
+ for (bi = local_nn - rpb; bi < local_nn; bi++) {
fprintf(stderr, " %x", dataUC[bi]);
}
fprintf(stderr, "\n");
}
airMopSingleOkay(mop, fout);
- airMopSingleOkay(mop, nref); nref = NULL;
+ airMopSingleOkay(mop, nref);
+ nref = NULL;
/* write header; for now just writing the header directly */
fprintf(stderr, "writing header . . . \n");
if (!(fout = fopen(outS[1], "w"))) {
- fprintf(stderr, "%s: couldn't open %s for writing: %s\n", me,
- outS[1], strerror(errno));
- airMopError(mop); return 1;
+ fprintf(stderr, "%s: couldn't open %s for writing: %s\n", me, outS[1],
+ strerror(errno));
+ airMopError(mop);
+ return 1;
}
airMopAdd(mop, fout, (airMopper)airFclose, airMopAlways);
fprintf(fout, "NRRD0005\n");
@@ -185,19 +194,18 @@
fprintf(fout, "type: unsigned int\n");
fprintf(fout, "dimension: %u\n", sizeNum);
fprintf(fout, "sizes:");
- for (axi=0; axi<sizeNum; axi++) {
+ for (axi = 0; axi < sizeNum; axi++) {
fprintf(fout, " %s", airSprintSize_t(stmp, size[axi]));
}
fprintf(fout, "\n");
fprintf(fout, "endian: %s\n", airEnumStr(airEndian, airMyEndian()));
- fprintf(fout, "encoding: %s\n", airEnumStr(nrrdEncodingType,
- nrrdEncodingTypeRaw));
+ fprintf(fout, "encoding: %s\n", airEnumStr(nrrdEncodingType, nrrdEncodingTypeRaw));
if (!negskip) {
if (pad[0]) {
fprintf(fout, "byte skip: %s\n", airSprintSize_t(stmp, pad[0]));
}
} else {
- fprintf(fout, "byte skip: -%s\n", airSprintSize_t(stmp, pad[1]+1));
+ fprintf(fout, "byte skip: -%s\n", airSprintSize_t(stmp, pad[1] + 1));
}
fprintf(fout, "data file: %s\n", outS[0]);
airMopSingleOkay(mop, fout);
@@ -207,26 +215,25 @@
nin = nrrdNew();
airMopAdd(mop, nin, (airMopper)nrrdNuke, airMopAlways);
if (nrrdLoad(nin, outS[1], NULL)) {
- airMopAdd(mop, berr=biffGetDone(NRRD), airFree, airMopAlways);
+ airMopAdd(mop, berr = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error reading back in: %s\n", me, berr);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
if (printbytes) {
size_t bi, rpb, local_nn;
- char local_stmp[AIR_STRLEN_SMALL];
- local_nn = nrrdElementSize(nin)*nrrdElementNumber(nin);
+ char local_stmp[AIR_STRLEN_SMALL + 1];
+ local_nn = nrrdElementSize(nin) * nrrdElementNumber(nin);
rpb = AIR_MIN(printbytes, local_nn);
dataUC = AIR_CAST(unsigned char *, nin->data);
- fprintf(stderr, "FOUND %s bytes at beginning:\n",
- airSprintSize_t(local_stmp, rpb));
- for (bi=0; bi<rpb; bi++) {
+ fprintf(stderr, "FOUND %s bytes at beginning:\n", airSprintSize_t(local_stmp, rpb));
+ for (bi = 0; bi < rpb; bi++) {
fprintf(stderr, "%x ", dataUC[bi]);
}
fprintf(stderr, "...\n");
- fprintf(stderr, "FOUND %s bytes at end:\n",
- airSprintSize_t(local_stmp, rpb));
+ fprintf(stderr, "FOUND %s bytes at end:\n", airSprintSize_t(local_stmp, rpb));
fprintf(stderr, "...");
- for (bi=local_nn - rpb; bi<local_nn; bi++) {
+ for (bi = local_nn - rpb; bi < local_nn; bi++) {
fprintf(stderr, " %x", dataUC[bi]);
}
fprintf(stderr, "\n");
@@ -235,7 +242,8 @@
gotCRC = nrrdCRC32(nin, airEndianBig);
if (refCRC != gotCRC) {
fprintf(stderr, "%s: got CRC %u but wanted %u\n", me, gotCRC, refCRC);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
fprintf(stderr, "(all ok)\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|