@@ -778,13 +778,13 @@ int writeHB_mat_double(const char* filename, int M, int N,
778
778
779
779
if ( Ptrfmt == NULL ) Ptrfmt = "(8I10)" ;
780
780
ParseIfmt (Ptrfmt ,& Ptrperline ,& Ptrwidth );
781
- sprintf (pformat ,"%%%dd" ,Ptrwidth );
781
+ snprintf (pformat , sizeof ( pformat ), "%%%dd" , Ptrwidth );
782
782
ptrcrd = (N + 1 )/Ptrperline ;
783
783
if ( (N + 1 )%Ptrperline != 0 ) ptrcrd ++ ;
784
784
785
785
if ( Indfmt == NULL ) Indfmt = Ptrfmt ;
786
786
ParseIfmt (Indfmt ,& Indperline ,& Indwidth );
787
- sprintf (iformat ,"%%%dd" ,Indwidth );
787
+ snprintf (iformat , sizeof ( iformat ), "%%%dd" , Indwidth );
788
788
indcrd = nz /Indperline ;
789
789
if ( nz %Indperline != 0 ) indcrd ++ ;
790
790
@@ -793,9 +793,9 @@ int writeHB_mat_double(const char* filename, int M, int N,
793
793
ParseRfmt (Valfmt ,& Valperline ,& Valwidth ,& Valprec ,& Valflag );
794
794
if (Valflag == 'D' ) * strchr (Valfmt ,'D' ) = 'E' ;
795
795
if (Valflag == 'F' )
796
- sprintf (vformat ,"%% %d.%df" ,Valwidth ,Valprec );
796
+ snprintf (vformat , sizeof ( vformat ), "%% %d.%df" , Valwidth , Valprec );
797
797
else
798
- sprintf (vformat ,"%% %d.%dE" ,Valwidth ,Valprec );
798
+ snprintf (vformat , sizeof ( vformat ), "%% %d.%dE" , Valwidth , Valprec );
799
799
valcrd = nvalentries /Valperline ;
800
800
if ( nvalentries %Valperline != 0 ) valcrd ++ ;
801
801
} else valcrd = 0 ;
@@ -804,9 +804,9 @@ int writeHB_mat_double(const char* filename, int M, int N,
804
804
if ( Rhsfmt == NULL ) Rhsfmt = Valfmt ;
805
805
ParseRfmt (Rhsfmt ,& Rhsperline ,& Rhswidth ,& Rhsprec , & Rhsflag );
806
806
if (Rhsflag == 'F' )
807
- sprintf (rformat ,"%% %d.%df" ,Rhswidth ,Rhsprec );
807
+ snprintf (rformat , sizeof ( rformat ), "%% %d.%df" , Rhswidth , Rhsprec );
808
808
else
809
- sprintf (rformat ,"%% %d.%dE" ,Rhswidth ,Rhsprec );
809
+ snprintf (rformat , sizeof ( rformat ), "%% %d.%dE" , Rhswidth , Rhsprec );
810
810
if (Rhsflag == 'D' ) * strchr (Rhsfmt ,'D' ) = 'E' ;
811
811
rhscrd = nrhsentries /Rhsperline ;
812
812
if ( nrhsentries %Rhsperline != 0 ) rhscrd ++ ;
@@ -1361,16 +1361,16 @@ int writeHB_mat_char(const char* filename, int M, int N,
1361
1361
1362
1362
if ( Ptrfmt == NULL ) Ptrfmt = "(8I10)" ;
1363
1363
ParseIfmt (Ptrfmt ,& Ptrperline ,& Ptrwidth );
1364
- sprintf (pformat ,"%%%dd" ,Ptrwidth );
1364
+ snprintf (pformat , sizeof ( pformat ), "%%%dd" , Ptrwidth );
1365
1365
1366
1366
if ( Indfmt == NULL ) Indfmt = Ptrfmt ;
1367
1367
ParseIfmt (Indfmt ,& Indperline ,& Indwidth );
1368
- sprintf (iformat ,"%%%dd" ,Indwidth );
1368
+ snprintf (iformat , sizeof ( iformat ), "%%%dd" , Indwidth );
1369
1369
1370
1370
if ( Type [0 ] != 'P' ) { /* Skip if pattern only */
1371
1371
if ( Valfmt == NULL ) Valfmt = "(4E20.13)" ;
1372
1372
ParseRfmt (Valfmt ,& Valperline ,& Valwidth ,& Valprec ,& Valflag );
1373
- sprintf (vformat ,"%%%ds" ,Valwidth );
1373
+ snprintf (vformat , sizeof ( vformat ), "%%%ds" , Valwidth );
1374
1374
}
1375
1375
1376
1376
ptrcrd = (N + 1 )/Ptrperline ;
@@ -1385,7 +1385,7 @@ int writeHB_mat_char(const char* filename, int M, int N,
1385
1385
if ( Nrhs > 0 ) {
1386
1386
if ( Rhsfmt == NULL ) Rhsfmt = Valfmt ;
1387
1387
ParseRfmt (Rhsfmt ,& Rhsperline ,& Rhswidth ,& Rhsprec , & Rhsflag );
1388
- sprintf (rformat ,"%%%ds" ,Rhswidth );
1388
+ snprintf (rformat , sizeof ( rformat ), "%%%ds" , Rhswidth );
1389
1389
rhscrd = nrhsentries /Rhsperline ;
1390
1390
if ( nrhsentries %Rhsperline != 0 ) rhscrd ++ ;
1391
1391
if ( Rhstype [1 ] == 'G' ) rhscrd += rhscrd ;
0 commit comments