@@ -72,7 +72,7 @@ attribute_hidden SEXP do_readDCF(SEXP call, SEXP op, SEXP args, SEXP env)
7272 bool blank_skip , field_skip = false;
7373 int whatlen , dynwhat , buflen = 8096 ; // was 100, but that re-alloced often
7474 char * line , * buf ;
75- regex_t blankline , contline , trailblank , regline , eblankline ;
75+ regex_t blankline , contline , trailblank , regline , eblankline , commentline ;
7676 regmatch_t regmatch [1 ];
7777 SEXP file , what , what2 , retval , retval2 , dims , dimnames ;
7878 Rconnection con = NULL ;
@@ -122,6 +122,7 @@ attribute_hidden SEXP do_readDCF(SEXP call, SEXP op, SEXP args, SEXP env)
122122 tre_regcompb (& contline , "^[ \t]+" , REG_EXTENDED );
123123 tre_regcompb (& regline , "^[^:]+:[ \t]*" , REG_EXTENDED );
124124 tre_regcompb (& eblankline , "^[ \f\n\r\t\v]+\\.[ \f\n\r\t\v]*$" , REG_EXTENDED );
125+ tre_regcompb (& commentline , "^#" , REG_EXTENDED );
125126
126127 k = 0 ;
127128 lastm = -1 ; /* index of the field currently being recorded */
@@ -149,6 +150,8 @@ attribute_hidden SEXP do_readDCF(SEXP call, SEXP op, SEXP args, SEXP env)
149150 field_fold = true;
150151 n_eblanklines = 0 ;
151152 }
153+ } else if (tre_regexecb (& commentline , line , 0 , 0 , 0 ) == 0 ) {
154+ /* comment-line detected. skipping it per DCF specification */
152155 } else {
153156 blank_skip = false;
154157 if (tre_regexecb (& contline , line , 1 , regmatch , 0 ) == 0 ) {
@@ -308,6 +311,7 @@ attribute_hidden SEXP do_readDCF(SEXP call, SEXP op, SEXP args, SEXP env)
308311 tre_regfree (& trailblank );
309312 tre_regfree (& regline );
310313 tre_regfree (& eblankline );
314+ tre_regfree (& commentline );
311315
312316 if (!blank_skip ) k ++ ;
313317
0 commit comments