Skip to content

Commit 4384cbd

Browse files
NIFTI Upstreamhjmjohnson
authored andcommitted
nifti 2022-08-02 (11eb262d)
Code extracted from: https://github.com/NIFTI-Imaging/nifti_clib.git at commit 11eb262d939fc139ddc3fe5b508179c637ffbf19 (master).
1 parent af2ec74 commit 4384cbd

File tree

4 files changed

+131
-102
lines changed

4 files changed

+131
-102
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ elseif(NOT WIN32)
158158
else()
159159
set(NIFTI_SYSTEM_MATH_LIB "")
160160
endif()
161+
mark_as_advanced(NIFTI_SYSTEM_MATH_LIB)
161162
#######################################################################
162163
add_subdirectory(znzlib)
163164
add_subdirectory(niftilib)

niftilib/nifti1_io.c

Lines changed: 70 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ nifti_image *nifti_image_read_bricks(const char * hname, int nbricks,
546546

547547
if( !hname || !NBL ){
548548
fprintf(stderr,"** nifti_image_read_bricks: bad params (%p,%p)\n",
549-
hname, (void *)NBL);
549+
(const void *)hname, (void *)NBL);
550550
return NULL;
551551
}
552552

@@ -1415,8 +1415,6 @@ char const *nifti_orientation_string( int ii )
14151415
\param nbyper pointer to return value: number of bytes per voxel
14161416
\param swapsize pointer to return value: size of swap blocks
14171417
1418-
\return appropriate values at nbyper and swapsize
1419-
14201418
The swapsize is set to 0 if this datatype doesn't ever need swapping.
14211419
14221420
\sa NIFTI1_DATATYPES in nifti1.h
@@ -2142,7 +2140,7 @@ void nifti_mat44_to_orientation( mat44 R , int *icod, int *jcod, int *kcod )
21422140
*
21432141
* Due to alignment of structures at some architectures (e.g. on ARM),
21442142
* stick to char variables.
2145-
* Fixes http://bugs.debian.org/446893 Yaroslav <debian@onerussian.com>
2143+
* Fixes <http://bugs.debian.org/446893> Yaroslav <debian @ onerussian.com>
21462144
*
21472145
*//*--------------------------------------------------------------------*/
21482146
void nifti_swap_2bytes( size_t n , void *ar ) /* 2 bytes at a time */
@@ -2581,7 +2579,7 @@ int nifti_validfilename(const char* fname)
25812579
25822580
\return a pointer to the extension substring within the original
25832581
function input parameter name, or NULL if not found.
2584-
\caution Note that if the input parameter is is immutabale
2582+
\warning Note that if the input parameter is is immutabale
25852583
(i.e. a const char *) then this function performs an
25862584
implicit casting away of the mutability constraint and
25872585
the return parameter will appear as a mutable
@@ -2831,8 +2829,8 @@ char * nifti_findhdrname(const char* fname)
28312829
/*! check current directory for existing image file
28322830
28332831
\param fname filename to check for
2834-
\nifti_type nifti_type for dataset - this determines whether to
2835-
first check for ".nii" or ".img" (since both may exist)
2832+
\param nifti_type nifti_type for dataset - this determines whether to
2833+
first check for ".nii" or ".img" (since both may exist)
28362834
28372835
\return filename of data/img file on success and NULL if no appropriate
28382836
file could be found
@@ -3077,7 +3075,7 @@ int nifti_set_filenames( nifti_image * nim, const char * prefix, int check,
30773075

30783076
if( !nim || !prefix ){
30793077
fprintf(stderr,"** nifti_set_filenames, bad params %p, %p\n",
3080-
(void *)nim,prefix);
3078+
(void *)nim,(const void *)prefix);
30813079
return -1;
30823080
}
30833081

@@ -3403,7 +3401,7 @@ int nifti_set_type_from_names( nifti_image * nim )
34033401

34043402
if( !nim->fname || !nim->iname ){
34053403
fprintf(stderr,"** NSTFN: missing filename(s) fname @ %p, iname @ %p\n",
3406-
nim->fname, nim->iname);
3404+
(const void *)nim->fname, (const void *)nim->iname);
34073405
return -1;
34083406
}
34093407

@@ -4489,7 +4487,7 @@ static int nifti_read_extensions( nifti_image *nim, znzFile fp, int remain )
44894487
44904488
\param nim - nifti_image to add extension to
44914489
\param data - raw extension data
4492-
\param length - length of raw extension data
4490+
\param len - length of raw extension data
44934491
\param ecode - extension code
44944492
44954493
\sa extension codes NIFTI_ECODE_* in nifti1_io.h
@@ -4571,7 +4569,7 @@ static int nifti_fill_extension( nifti1_extension *ext, const char * data,
45714569

45724570
if( !ext || !data || len < 0 ){
45734571
fprintf(stderr,"** fill_ext: bad params (%p,%p,%d)\n",
4574-
(void *)ext, data, len);
4572+
(void *)ext, (const void *)data, len);
45754573
return -1;
45764574
} else if( ! nifti_is_valid_ecode(ecode) ){
45774575
fprintf(stderr,"** warning: writing unknown ecode %d\n", ecode);
@@ -4819,7 +4817,7 @@ static znzFile nifti_image_load_prep( nifti_image *nim )
48194817
if ( g_opts.debug > 0 ){
48204818
if( !nim ) fprintf(stderr,"** ERROR: N_image_load: no nifti image\n");
48214819
else fprintf(stderr,"** ERROR: N_image_load: bad params (%p,%d,%u)\n",
4822-
nim->iname, nim->nbyper, (unsigned)nim->nvox);
4820+
(const void *)nim->iname, nim->nbyper, (unsigned)nim->nvox);
48234821
}
48244822
return NULL;
48254823
}
@@ -5903,8 +5901,6 @@ znzFile nifti_write_ascii_image(nifti_image *nim, const nifti_brick_list * NBL,
59035901
fields from the qto_xyz matrix, you can use the utility function
59045902
nifti_mat44_to_quatern()
59055903
5906-
\return 0 on success, -1 on error
5907-
59085904
\sa nifti_image_write_bricks, nifti_image_free, nifti_set_filenames,
59095905
nifti_image_write_hdr_img
59105906
*//*------------------------------------------------------------------------*/
@@ -6193,15 +6189,16 @@ char *nifti_image_to_ascii( const nifti_image *nim )
61936189

61946190
if( nim == NULL ) return NULL ; /* stupid caller */
61956191

6196-
buf = (char *)calloc(1,65534); /* longer than needed, to be safe */
6192+
const size_t bufLen = 65534; /* longer than needed, to be safe */
6193+
buf = (char *)calloc(1,bufLen);
61976194
if( !buf ){
6198-
fprintf(stderr,"** NITA: failed to alloc %d bytes\n",65534);
6195+
fprintf(stderr,"** NITA: failed to alloc %zu bytes\n",bufLen);
61996196
return NULL;
62006197
}
62016198

6202-
sprintf( buf , "<nifti_image\n" ) ; /* XML-ish opener */
6199+
snprintf( buf , bufLen , "<nifti_image\n" ) ; /* XML-ish opener */
62036200

6204-
sprintf( buf+strlen(buf) , " nifti_type = '%s'\n" ,
6201+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " nifti_type = '%s'\n" ,
62056202
(nim->nifti_type == NIFTI_FTYPE_NIFTI1_1) ? "NIFTI-1+"
62066203
:(nim->nifti_type == NIFTI_FTYPE_NIFTI1_2) ? "NIFTI-1"
62076204
:(nim->nifti_type == NIFTI_FTYPE_ASCII ) ? "NIFTI-1A"
@@ -6215,126 +6212,126 @@ char *nifti_image_to_ascii( const nifti_image *nim )
62156212
- The result is that the NIFTI ASCII-format header is XML-compliant. */
62166213

62176214
ebuf = escapize_string(nim->fname) ;
6218-
sprintf( buf+strlen(buf) , " header_filename = %s\n",ebuf); free(ebuf);
6215+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " header_filename = %s\n",ebuf); free(ebuf);
62196216

62206217
ebuf = escapize_string(nim->iname) ;
6221-
sprintf( buf+strlen(buf) , " image_filename = %s\n", ebuf); free(ebuf);
6218+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " image_filename = %s\n", ebuf); free(ebuf);
62226219

6223-
sprintf( buf+strlen(buf) , " image_offset = '%d'\n" , nim->iname_offset );
6220+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " image_offset = '%d'\n" , nim->iname_offset );
62246221

6225-
sprintf(buf + strlen(buf), " ndim = '%d'\n", nim->ndim);
6226-
sprintf(buf + strlen(buf), " nx = '%d'\n", nim->nx);
6222+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " ndim = '%d'\n", nim->ndim);
6223+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " nx = '%d'\n", nim->nx);
62276224
if (nim->ndim > 1)
6228-
sprintf(buf + strlen(buf), " ny = '%d'\n", nim->ny);
6225+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " ny = '%d'\n", nim->ny);
62296226
if (nim->ndim > 2)
6230-
sprintf(buf + strlen(buf), " nz = '%d'\n", nim->nz);
6227+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " nz = '%d'\n", nim->nz);
62316228
if (nim->ndim > 3)
6232-
sprintf(buf + strlen(buf), " nt = '%d'\n", nim->nt);
6229+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " nt = '%d'\n", nim->nt);
62336230
if (nim->ndim > 4)
6234-
sprintf(buf + strlen(buf), " nu = '%d'\n", nim->nu);
6231+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " nu = '%d'\n", nim->nu);
62356232
if (nim->ndim > 5)
6236-
sprintf(buf + strlen(buf), " nv = '%d'\n", nim->nv);
6233+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " nv = '%d'\n", nim->nv);
62376234
if (nim->ndim > 6)
6238-
sprintf(buf + strlen(buf), " nw = '%d'\n", nim->nw);
6239-
sprintf(buf + strlen(buf), " dx = '%g'\n", nim->dx);
6235+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " nw = '%d'\n", nim->nw);
6236+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " dx = '%g'\n", nim->dx);
62406237
if (nim->ndim > 1)
6241-
sprintf(buf + strlen(buf), " dy = '%g'\n", nim->dy);
6238+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " dy = '%g'\n", nim->dy);
62426239
if (nim->ndim > 2)
6243-
sprintf(buf + strlen(buf), " dz = '%g'\n", nim->dz);
6240+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " dz = '%g'\n", nim->dz);
62446241
if (nim->ndim > 3)
6245-
sprintf(buf + strlen(buf), " dt = '%g'\n", nim->dt);
6242+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " dt = '%g'\n", nim->dt);
62466243
if (nim->ndim > 4)
6247-
sprintf(buf + strlen(buf), " du = '%g'\n", nim->du);
6244+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " du = '%g'\n", nim->du);
62486245
if (nim->ndim > 5)
6249-
sprintf(buf + strlen(buf), " dv = '%g'\n", nim->dv);
6246+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " dv = '%g'\n", nim->dv);
62506247
if (nim->ndim > 6)
6251-
sprintf(buf + strlen(buf), " dw = '%g'\n", nim->dw);
6248+
snprintf(buf+strlen(buf), bufLen-strlen(buf), " dw = '%g'\n", nim->dw);
62526249

6253-
sprintf( buf+strlen(buf) , " datatype = '%d'\n" , nim->datatype ) ;
6254-
sprintf( buf+strlen(buf) , " datatype_name = '%s'\n" ,
6250+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " datatype = '%d'\n" , nim->datatype ) ;
6251+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " datatype_name = '%s'\n" ,
62556252
nifti_datatype_string(nim->datatype) ) ;
62566253

6257-
sprintf( buf+strlen(buf) , " nvox = '%u'\n" , (unsigned)nim->nvox ) ;
6258-
sprintf( buf+strlen(buf) , " nbyper = '%d'\n" , nim->nbyper ) ;
6254+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " nvox = '%u'\n" , (unsigned)nim->nvox ) ;
6255+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " nbyper = '%d'\n" , nim->nbyper ) ;
62596256

6260-
sprintf( buf+strlen(buf) , " byteorder = '%s'\n" ,
6257+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " byteorder = '%s'\n" ,
62616258
(nim->byteorder==MSB_FIRST) ? "MSB_FIRST" : "LSB_FIRST" ) ;
62626259

62636260
if( nim->cal_min < nim->cal_max ){
6264-
sprintf( buf+strlen(buf) , " cal_min = '%g'\n", nim->cal_min ) ;
6265-
sprintf( buf+strlen(buf) , " cal_max = '%g'\n", nim->cal_max ) ;
6261+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " cal_min = '%g'\n", nim->cal_min ) ;
6262+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " cal_max = '%g'\n", nim->cal_max ) ;
62666263
}
62676264

62686265
if( nim->scl_slope != 0.0 ){
6269-
sprintf( buf+strlen(buf) , " scl_slope = '%g'\n" , nim->scl_slope ) ;
6270-
sprintf( buf+strlen(buf) , " scl_inter = '%g'\n" , nim->scl_inter ) ;
6266+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " scl_slope = '%g'\n" , nim->scl_slope ) ;
6267+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " scl_inter = '%g'\n" , nim->scl_inter ) ;
62716268
}
62726269

62736270
if( nim->intent_code > 0 ){
6274-
sprintf( buf+strlen(buf) , " intent_code = '%d'\n", nim->intent_code ) ;
6275-
sprintf( buf+strlen(buf) , " intent_code_name = '%s'\n" ,
6271+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " intent_code = '%d'\n", nim->intent_code ) ;
6272+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " intent_code_name = '%s'\n" ,
62766273
nifti_intent_string(nim->intent_code) ) ;
6277-
sprintf( buf+strlen(buf) , " intent_p1 = '%g'\n" , nim->intent_p1 ) ;
6278-
sprintf( buf+strlen(buf) , " intent_p2 = '%g'\n" , nim->intent_p2 ) ;
6279-
sprintf( buf+strlen(buf) , " intent_p3 = '%g'\n" , nim->intent_p3 ) ;
6274+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " intent_p1 = '%g'\n" , nim->intent_p1 ) ;
6275+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " intent_p2 = '%g'\n" , nim->intent_p2 ) ;
6276+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " intent_p3 = '%g'\n" , nim->intent_p3 ) ;
62806277

62816278
if( nim->intent_name[0] != '\0' ){
62826279
ebuf = escapize_string(nim->intent_name) ;
6283-
sprintf( buf+strlen(buf) , " intent_name = %s\n",ebuf) ;
6280+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " intent_name = %s\n",ebuf) ;
62846281
free(ebuf) ;
62856282
}
62866283
}
62876284

62886285
if( nim->toffset != 0.0 )
6289-
sprintf( buf+strlen(buf) , " toffset = '%g'\n",nim->toffset ) ;
6286+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " toffset = '%g'\n",nim->toffset ) ;
62906287

62916288
if( nim->xyz_units > 0 )
6292-
sprintf( buf+strlen(buf) ,
6289+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
62936290
" xyz_units = '%d'\n"
62946291
" xyz_units_name = '%s'\n" ,
62956292
nim->xyz_units , nifti_units_string(nim->xyz_units) ) ;
62966293

62976294
if( nim->time_units > 0 )
6298-
sprintf( buf+strlen(buf) ,
6295+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
62996296
" time_units = '%d'\n"
63006297
" time_units_name = '%s'\n" ,
63016298
nim->time_units , nifti_units_string(nim->time_units) ) ;
63026299

63036300
if( nim->freq_dim > 0 )
6304-
sprintf( buf+strlen(buf) , " freq_dim = '%d'\n",nim->freq_dim ) ;
6301+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " freq_dim = '%d'\n",nim->freq_dim ) ;
63056302
if( nim->phase_dim > 0 )
6306-
sprintf( buf+strlen(buf) , " phase_dim = '%d'\n",nim->phase_dim ) ;
6303+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " phase_dim = '%d'\n",nim->phase_dim ) ;
63076304
if( nim->slice_dim > 0 )
6308-
sprintf( buf+strlen(buf) , " slice_dim = '%d'\n",nim->slice_dim ) ;
6305+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " slice_dim = '%d'\n",nim->slice_dim ) ;
63096306
if( nim->slice_code > 0 )
6310-
sprintf( buf+strlen(buf) ,
6307+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
63116308
" slice_code = '%d'\n"
63126309
" slice_code_name = '%s'\n" ,
63136310
nim->slice_code , nifti_slice_string(nim->slice_code) ) ;
63146311
if( nim->slice_start >= 0 && nim->slice_end > nim->slice_start )
6315-
sprintf( buf+strlen(buf) ,
6312+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
63166313
" slice_start = '%d'\n"
63176314
" slice_end = '%d'\n" , nim->slice_start , nim->slice_end ) ;
63186315
if( nim->slice_duration != 0.0 )
6319-
sprintf( buf+strlen(buf) , " slice_duration = '%g'\n",
6316+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " slice_duration = '%g'\n",
63206317
nim->slice_duration ) ;
63216318

63226319
if( nim->descrip[0] != '\0' ){
63236320
ebuf = escapize_string(nim->descrip) ;
6324-
sprintf( buf+strlen(buf) , " descrip = %s\n",ebuf) ;
6321+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " descrip = %s\n",ebuf) ;
63256322
free(ebuf) ;
63266323
}
63276324

63286325
if( nim->aux_file[0] != '\0' ){
63296326
ebuf = escapize_string(nim->aux_file) ;
6330-
sprintf( buf+strlen(buf) , " aux_file = %s\n",ebuf) ;
6327+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " aux_file = %s\n",ebuf) ;
63316328
free(ebuf) ;
63326329
}
63336330

63346331
if( nim->qform_code > 0 ){
63356332
int i,j,k ;
63366333

6337-
sprintf( buf+strlen(buf) ,
6334+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
63386335
" qform_code = '%d'\n"
63396336
" qform_code_name = '%s'\n"
63406337
" qto_xyz_matrix = '%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g'\n" ,
@@ -6348,7 +6345,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
63486345
nim->qto_xyz.m[3][0] , nim->qto_xyz.m[3][1] ,
63496346
nim->qto_xyz.m[3][2] , nim->qto_xyz.m[3][3] ) ;
63506347

6351-
sprintf( buf+strlen(buf) ,
6348+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
63526349
" qto_ijk_matrix = '%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g'\n" ,
63536350
nim->qto_ijk.m[0][0] , nim->qto_ijk.m[0][1] ,
63546351
nim->qto_ijk.m[0][2] , nim->qto_ijk.m[0][3] ,
@@ -6359,7 +6356,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
63596356
nim->qto_ijk.m[3][0] , nim->qto_ijk.m[3][1] ,
63606357
nim->qto_ijk.m[3][2] , nim->qto_ijk.m[3][3] ) ;
63616358

6362-
sprintf( buf+strlen(buf) ,
6359+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
63636360
" quatern_b = '%g'\n"
63646361
" quatern_c = '%g'\n"
63656362
" quatern_d = '%g'\n"
@@ -6372,7 +6369,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
63726369

63736370
nifti_mat44_to_orientation( nim->qto_xyz , &i,&j,&k ) ;
63746371
if( i > 0 && j > 0 && k > 0 )
6375-
sprintf( buf+strlen(buf) ,
6372+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
63766373
" qform_i_orientation = '%s'\n"
63776374
" qform_j_orientation = '%s'\n"
63786375
" qform_k_orientation = '%s'\n" ,
@@ -6384,7 +6381,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
63846381
if( nim->sform_code > 0 ){
63856382
int i,j,k ;
63866383

6387-
sprintf( buf+strlen(buf) ,
6384+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
63886385
" sform_code = '%d'\n"
63896386
" sform_code_name = '%s'\n"
63906387
" sto_xyz_matrix = '%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g'\n" ,
@@ -6398,7 +6395,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
63986395
nim->sto_xyz.m[3][0] , nim->sto_xyz.m[3][1] ,
63996396
nim->sto_xyz.m[3][2] , nim->sto_xyz.m[3][3] ) ;
64006397

6401-
sprintf( buf+strlen(buf) ,
6398+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
64026399
" sto_ijk matrix = '%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g'\n" ,
64036400
nim->sto_ijk.m[0][0] , nim->sto_ijk.m[0][1] ,
64046401
nim->sto_ijk.m[0][2] , nim->sto_ijk.m[0][3] ,
@@ -6411,7 +6408,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
64116408

64126409
nifti_mat44_to_orientation( nim->sto_xyz , &i,&j,&k ) ;
64136410
if( i > 0 && j > 0 && k > 0 )
6414-
sprintf( buf+strlen(buf) ,
6411+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) ,
64156412
" sform_i_orientation = '%s'\n"
64166413
" sform_j_orientation = '%s'\n"
64176414
" sform_k_orientation = '%s'\n" ,
@@ -6420,9 +6417,9 @@ char *nifti_image_to_ascii( const nifti_image *nim )
64206417
nifti_orientation_string(k) ) ;
64216418
}
64226419

6423-
sprintf( buf+strlen(buf) , " num_ext = '%d'\n", nim->num_ext ) ;
6420+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , " num_ext = '%d'\n", nim->num_ext ) ;
64246421

6425-
sprintf( buf+strlen(buf) , "/>\n" ) ; /* XML-ish closer */
6422+
snprintf( buf+strlen(buf) , bufLen-strlen(buf) , "/>\n" ) ; /* XML-ish closer */
64266423

64276424
nbuf = (int)strlen(buf) ;
64286425
buf = (char *)realloc((void *)buf, nbuf+1); /* cut back to proper length */
@@ -6457,7 +6454,7 @@ int nifti_short_order(void) /* determine this CPU's byte order */
64576454
/* macro to check lhs string against "n1"; if it matches,
64586455
interpret rhs string as a number, and put it into nim->"n2" */
64596456

6460-
#define QQNUM(n1,n2,tt) if( strcmp(lhs,#n1)==0 ) nim->n2=(tt)strtod(rhs,NULL)
6457+
#define QQNUM(n1,n2,tt) if( strcmp(lhs,#n1)==0 ) nim->n2=(tt)(strtod(rhs,NULL))
64616458

64626459
/* same, but where "n1" == "n2" */
64636460

@@ -6959,7 +6956,7 @@ compute_strides(int *strides,const int *size,int nbyper)
69596956
speed and possibly repeated calls to this function.
69606957
\return
69616958
- the total number of bytes read, or < 0 on failure
6962-
- the read and byte-swapped data, in 'data' </pre>
6959+
- the read and byte-swapped data, in 'data'
69636960
69646961
\sa nifti_image_read, nifti_image_free, nifti_image_read_bricks
69656962
nifti_image_load, nifti_read_collapsed_image

0 commit comments

Comments
 (0)