@@ -95,11 +95,16 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
95
95
char * header [MAX_LINES ];
96
96
char * words [MAX_WORDS ], * cwords [2 ];
97
97
char * col_labels [MAX_COLUMNS ], * col_units [MAX_COLUMNS ];
98
- char * c , * line , * fullline , * mkey , * mval , * version_xdi , * version_extra ;
98
+ char * c , * line , * fullline , * mkey , * mval ;
99
99
char * reword ;
100
100
char tlabel [32 ] = {'\0' };
101
101
char comments [1025 ] = {'\0' };
102
102
char elem [3 ] = {'\0' };
103
+ char edge [3 ] = {'\0' };
104
+ char version_xdi [8 ] = {'\0' };
105
+ char version_extra [MAX_LINE_LENGTH ] = {'\0' };
106
+ char errline [MAX_LINE_LENGTH ] = {'\0' };
107
+ char outerlabel [MAX_WORD_LENGTH ] = {'\0' };
103
108
double dval ;
104
109
double * outer_arr , outer_arr0 ;
105
110
long * outer_pts ;
@@ -116,6 +121,9 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
116
121
117
122
iret = 0 ;
118
123
124
+
125
+ /* initialize string attributes of thr XDIFile struct */
126
+
119
127
strcpy (comments , " " );
120
128
xdifile -> comments = calloc (1025 , sizeof (char ));
121
129
strcpy (xdifile -> comments , comments );
@@ -124,14 +132,43 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
124
132
xdifile -> element = calloc (3 , sizeof (char ));
125
133
strncpy (xdifile -> element , elem , 2 );
126
134
127
- COPY_STRING (xdifile -> xdi_libversion , XDI_VERSION );
128
- COPY_STRING (xdifile -> xdi_version , "" );
129
- COPY_STRING (xdifile -> extra_version , "" );
135
+ strcpy (edge , " " );
136
+ xdifile -> edge = calloc (3 , sizeof (char ));
137
+ strncpy (xdifile -> edge , edge , 2 );
138
+
139
+ xdifile -> xdi_libversion = calloc (8 , sizeof (char ));
140
+ strncpy (xdifile -> xdi_libversion , XDI_VERSION , 7 );
141
+
142
+ strcpy (version_xdi , " " );
143
+ xdifile -> xdi_version = calloc (8 , sizeof (char ));
144
+ strncpy (xdifile -> xdi_version , version_xdi , 7 );
145
+
146
+ strcpy (version_extra , " " );
147
+ xdifile -> extra_version = calloc (MAX_LINE_LENGTH + 1 , sizeof (char ));
148
+ strncpy (xdifile -> extra_version , version_extra , MAX_LINE_LENGTH );
149
+
150
+
151
+ strcpy (errline , " " );
152
+ xdifile -> error_line = calloc (MAX_LINE_LENGTH + 1 , sizeof (char ));
153
+ strncpy (xdifile -> error_line , errline , MAX_LINE_LENGTH );
154
+
155
+ strcpy (outerlabel , " " );
156
+ xdifile -> outer_label = calloc (MAX_LINE_LENGTH + 1 , sizeof (char ));
157
+ strncpy (xdifile -> outer_label , outerlabel , MAX_LINE_LENGTH );
158
+
159
+
160
+ /* COPY_STRING(xdifile->xdi_libversion, XDI_VERSION); */
161
+ /* COPY_STRING(xdifile->xdi_version, ""); */
162
+ /* COPY_STRING(xdifile->extra_version, ""); */
130
163
/* COPY_STRING(xdifile->element, "__"); */
131
- COPY_STRING (xdifile -> edge , "_" );
164
+ /* COPY_STRING(xdifile->edge, "_"); */
132
165
/* COPY_STRING(xdifile->comments, comments); */
133
- COPY_STRING (xdifile -> error_line , "" );
134
- COPY_STRING (xdifile -> outer_label , "" );
166
+ /* COPY_STRING(xdifile->error_line, ""); */
167
+ /* COPY_STRING(xdifile->outer_label, ""); */
168
+
169
+
170
+ /* initialize numeric attributes of thr XDIFile struct */
171
+
135
172
xdifile -> nouter = 1 ;
136
173
xdifile -> error_lineno = -1 ;
137
174
xdifile -> dspacing = -1.0 ;
@@ -158,7 +195,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
158
195
return ilen ;
159
196
}
160
197
161
- /* check fist line for XDI header, get version info */
198
+ /* check first line for XDI header, get version info */
162
199
if (strncmp (textlines [0 ], TOK_COMM , 1 ) == 0 ) {
163
200
line = textlines [0 ]; line ++ ;
164
201
line [strcspn (line , CRLF )] = '\0' ;
@@ -168,10 +205,10 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
168
205
return ERR_NOTXDI ;
169
206
} else {
170
207
line = line + 5 ;
171
- COPY_STRING (xdifile -> xdi_version , line )
208
+ strcpy (xdifile -> xdi_version , line );
172
209
}
173
210
if (nwords > 1 ) { /* extra version tags */
174
- COPY_STRING (xdifile -> extra_version , cwords [1 ]);
211
+ strcpy (xdifile -> extra_version , cwords [1 ]);
175
212
}
176
213
}
177
214
@@ -245,7 +282,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
245
282
} else if (strcasecmp (mkey , TOK_EDGE ) == 0 ) {
246
283
for (j = 0 ; j < n_edges ; j ++ ) {
247
284
if (strcasecmp (ValidEdges [j ], mval ) == 0 ) {
248
- COPY_STRING (xdifile -> edge , mval );
285
+ strcpy (xdifile -> edge , mval );
249
286
break ;
250
287
}
251
288
}
@@ -396,7 +433,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
396
433
}
397
434
/* success */
398
435
xdifile -> error_lineno = 0 ;
399
- COPY_STRING (xdifile -> error_line , "" );
436
+ strcpy (xdifile -> error_line , "" );
400
437
401
438
xdifile -> npts = ipt ;
402
439
xdifile -> nouter = iouter ;
@@ -437,7 +474,8 @@ _EXPORT(int) XDI_get_array_name(XDIFile *xdifile, char *name, double *out) {
437
474
return ERR_NOARR_NAME ;
438
475
}
439
476
440
- _EXPORT (void ) XDI_cleanup (XDIFile * xdifile ) {
477
+ _EXPORT (void )
478
+ XDI_cleanup (XDIFile * xdifile ) {
441
479
/* one needs to explicitly free each part of the struct */
442
480
long j ;
443
481
for (j = 0 ; j < xdifile -> narrays ; j ++ ) {
0 commit comments