@@ -43,7 +43,7 @@ _EXPORT(char*) XDI_errorstring(int errcode) {
43
43
} else if (errcode == ERR_NCOLS_CHANGE ) {
44
44
return "number of columns changes in file" ;
45
45
} else if (errcode == ERR_NONNUMERIC ) {
46
- return "non-numeric value in data table" ;
46
+ return "non-numeric value in data table or for d-spacing " ;
47
47
} else if (errcode == ERR_IGNOREDMETA ) {
48
48
return "contains unrecognized header lines" ;
49
49
}
@@ -95,7 +95,7 @@ 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 , * mkey , * mval , * version_xdi , * version_extra ;
98
+ char * c , * line , * fullline , * mkey , * mval , * version_xdi , * version_extra ;
99
99
char * reword ;
100
100
char tlabel [32 ];
101
101
char comments [1024 ] = "" ;
@@ -119,7 +119,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
119
119
COPY_STRING (xdifile -> xdi_version , "" );
120
120
COPY_STRING (xdifile -> extra_version , "" );
121
121
COPY_STRING (xdifile -> element , "__" );
122
- COPY_STRING (xdifile -> edge , "K " );
122
+ COPY_STRING (xdifile -> edge , "_ " );
123
123
COPY_STRING (xdifile -> comments , "" );
124
124
COPY_STRING (xdifile -> error_line , "" );
125
125
COPY_STRING (xdifile -> outer_label , "" );
@@ -170,8 +170,9 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
170
170
nheader= index of first line that does not start with '#'
171
171
*/
172
172
for (i = 1 ; i < ilen ; i ++ ) {
173
- if ((strlen (textlines [i ]) > 3 ) &&
174
- (strncmp (textlines [i ], TOK_COMM , 1 ) != 0 )) {
173
+ regex_status = slre_match (1 , DATALINE , textlines [i ], strlen (textlines [i ]));
174
+ if ((strlen (textlines [i ]) > 3 ) && (regex_status == NULL )) {
175
+ /* (strncmp(textlines[i], TOK_COMM, 1) != 0)) { */
175
176
break ;
176
177
}
177
178
}
@@ -188,7 +189,9 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
188
189
189
190
if (strncmp (textlines [i ], TOK_COMM , 1 ) == 0 ) {
190
191
COPY_STRING (line , textlines [i ]);
192
+ COPY_STRING (fullline , textlines [i ]);
191
193
line ++ ;
194
+ fullline ++ ;
192
195
nwords = split_on (line , TOK_DELIM , words );
193
196
if (nwords < 1 ) { continue ; }
194
197
COPY_STRING (mkey , words [0 ]);
@@ -269,10 +272,10 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
269
272
if ((strlen (comments ) > 0 ) && strlen (comments ) < sizeof (comments )) {
270
273
strncat (comments , "\n" , sizeof (comments )- strlen (comments ) - 1 );
271
274
}
272
- if (strlen (line ) + 1 > sizeof (comments ) - strlen (comments )) {
275
+ if (strlen (fullline ) + 1 > sizeof (comments ) - strlen (comments )) {
273
276
printf ("Warning.... user comment may be truncated!\n" );
274
277
}
275
- strncat (comments , line , sizeof (comments ) - strlen (comments ) - 1 );
278
+ strncat (comments , fullline , sizeof (comments ) - strlen (comments ) - 1 );
276
279
} else if (mode == 0 ) {
277
280
return ERR_META_FORMAT ;
278
281
}
@@ -282,8 +285,8 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
282
285
}
283
286
}
284
287
}
285
- if (has_minusline == 0 ) { iret = ERR_NOMINUSLINE ; }
286
288
if (ignored_headerline > 0 ) { iret = ERR_IGNOREDMETA ; }
289
+ if (has_minusline == 0 ) { iret = ERR_NOMINUSLINE ; }
287
290
288
291
/* check edge, element, return error code if invalid */
289
292
valid = 0 ;
@@ -350,7 +353,7 @@ XDI_readfile(char *filename, XDIFile *xdifile) {
350
353
/* loop through data table, inserting data into xdifile->array */
351
354
ipt = 0 ;
352
355
iouter = 1 ;
353
- for (i = nheader - 2 ; i < ilen ; i ++ ) {
356
+ for (i = nheader - 2 ; i <= ilen ; i ++ ) {
354
357
/* may find a header line interspersed in array data */
355
358
COPY_STRING (line , textlines [i ]);
356
359
xdifile -> error_lineno = i ;
0 commit comments