@@ -97,8 +97,9 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
97
97
char * col_labels [MAX_COLUMNS ], * col_units [MAX_COLUMNS ];
98
98
char * c , * line , * fullline , * mkey , * mval , * version_xdi , * version_extra ;
99
99
char * reword ;
100
- char tlabel [32 ];
101
- char comments [1024 ] = "" ;
100
+ char tlabel [32 ] = {'\0' };
101
+ char comments [1025 ] = {'\0' };
102
+ char elem [3 ] = {'\0' };
102
103
double dval ;
103
104
double * outer_arr , outer_arr0 ;
104
105
long * outer_pts ;
@@ -115,12 +116,20 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
115
116
116
117
iret = 0 ;
117
118
119
+ strcpy (comments , " " );
120
+ xdifile -> comments = calloc (1025 , sizeof (char ));
121
+ strcpy (xdifile -> comments , comments );
122
+
123
+ strcpy (elem , " " );
124
+ xdifile -> element = calloc (3 , sizeof (char ));
125
+ strncpy (xdifile -> element , elem , 2 );
126
+
118
127
COPY_STRING (xdifile -> xdi_libversion , XDI_VERSION );
119
128
COPY_STRING (xdifile -> xdi_version , "" );
120
129
COPY_STRING (xdifile -> extra_version , "" );
121
- COPY_STRING (xdifile -> element , "__" );
130
+ /* COPY_STRING(xdifile->element, "__"); */
122
131
COPY_STRING (xdifile -> edge , "_" );
123
- COPY_STRING (xdifile -> comments , "" );
132
+ /* COPY_STRING(xdifile->comments, comments); */
124
133
COPY_STRING (xdifile -> error_line , "" );
125
134
COPY_STRING (xdifile -> outer_label , "" );
126
135
xdifile -> nouter = 1 ;
@@ -244,7 +253,8 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
244
253
} else if (strcasecmp (mkey , TOK_ELEM ) == 0 ) {
245
254
for (j = 0 ; j < n_elems ; j ++ ) {
246
255
if (strcasecmp (ValidElems [j ], mval ) == 0 ) {
247
- COPY_STRING (xdifile -> element , mval );
256
+ /* COPY_STRING(xdifile->element, mval); */
257
+ strncpy (xdifile -> element , mval , 2 );
248
258
break ;
249
259
}
250
260
}
@@ -318,7 +328,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
318
328
COPY_STRING (line , textlines [i ]);
319
329
ncols = make_words (line , words , MAX_WORDS );
320
330
321
- COPY_STRING (xdifile -> comments , comments );
331
+ strcpy (xdifile -> comments , comments );
322
332
COPY_STRING (xdifile -> filename , filename );
323
333
324
334
maxcol ++ ;
0 commit comments