1
1
use std:: io:: { Read , Write , BufReader , BufRead , stdin, stdout} ;
2
2
use std:: fs:: { File , OpenOptions } ;
3
+ use std:: mem;
3
4
use std:: path:: Path ;
4
5
use std:: env;
5
6
use std:: cell:: { Cell , RefCell } ;
@@ -288,6 +289,8 @@ fn add_table<'a>(name: &str, rowpath: &str, outfile: Option<&str>, settings: &Se
288
289
_ => None
289
290
} ;
290
291
let mut datatype = col[ "type" ] . as_str ( ) . unwrap_or ( "text" ) . to_string ( ) ;
292
+ let mut include: Option < Regex > = col[ "incl" ] . as_str ( ) . map ( |str| Regex :: new ( str) . unwrap_or_else ( |err| fatalerr ! ( "Error: invalid regex in 'incl' entry in configuration file: {}" , err) ) ) ;
293
+ let mut exclude: Option < Regex > = col[ "excl" ] . as_str ( ) . map ( |str| Regex :: new ( str) . unwrap_or_else ( |err| fatalerr ! ( "Error: invalid regex in 'excl' entry in configuration file: {}" , err) ) ) ;
291
294
let norm = col[ "norm" ] . as_str ( ) ;
292
295
let file = col[ "file" ] . as_str ( ) ;
293
296
let cardinality = match ( file, norm) { // The combination of 'file' and 'norm' options determine relation to the subtable (if any)
@@ -302,7 +305,7 @@ fn add_table<'a>(name: &str, rowpath: &str, outfile: Option<&str>, settings: &Se
302
305
let filename = col[ "file" ] . as_str ( ) . unwrap ( ) ;
303
306
if table. columns . is_empty ( ) { fatalerr ! ( "Error: table '{}' cannot have a subtable as first column" , name) ; }
304
307
let mut subtable = add_table ( colname, & path, Some ( filename) , settings, & [ ] , cardinality) ;
305
- subtable. columns . push ( Column { name : colname. to_string ( ) , path : path. clone ( ) , datatype : datatype. to_string ( ) , ..Default :: default ( ) } ) ;
308
+ subtable. columns . push ( Column { name : colname. to_string ( ) , path : path. clone ( ) , datatype : datatype. to_string ( ) , include : mem :: take ( & mut include ) , exclude : mem :: take ( & mut exclude ) , ..Default :: default ( ) } ) ;
306
309
emit_preamble ( & subtable, settings, Some ( format ! ( "{} {}" , name, table. columns[ 0 ] . datatype) ) ) ;
307
310
Some ( subtable)
308
311
} ,
@@ -311,7 +314,7 @@ fn add_table<'a>(name: &str, rowpath: &str, outfile: Option<&str>, settings: &Se
311
314
if table. columns . is_empty ( ) { fatalerr ! ( "Error: table '{}' cannot have a subtable as first column" , name) ; }
312
315
let mut subtable = add_table ( colname, & path, Some ( filename) , settings, & [ ] , cardinality) ;
313
316
// subtable.columns.push(Column { name: String::from("id"), path: String::new(), datatype: String::from("integer"), ..Default::default() });
314
- subtable. columns . push ( Column { name : colname. to_string ( ) , path : path. clone ( ) , datatype : "integer" . to_string ( ) , ..Default :: default ( ) } ) ;
317
+ subtable. columns . push ( Column { name : colname. to_string ( ) , path : path. clone ( ) , datatype : "integer" . to_string ( ) , include : mem :: take ( & mut include ) , exclude : mem :: take ( & mut exclude ) , ..Default :: default ( ) } ) ;
315
318
emit_preamble ( & subtable, settings, Some ( format ! ( "{} {}" , name, table. columns[ 0 ] . datatype) ) ) ;
316
319
Some ( subtable)
317
320
} ,
@@ -340,8 +343,6 @@ fn add_table<'a>(name: &str, rowpath: &str, outfile: Option<&str>, settings: &Se
340
343
}
341
344
} ;
342
345
let hide = col[ "hide" ] . as_bool ( ) . unwrap_or ( false ) ;
343
- let include: Option < Regex > = col[ "incl" ] . as_str ( ) . map ( |str| Regex :: new ( str) . unwrap_or_else ( |err| fatalerr ! ( "Error: invalid regex in 'incl' entry in configuration file: {}" , err) ) ) ;
344
- let exclude: Option < Regex > = col[ "excl" ] . as_str ( ) . map ( |str| Regex :: new ( str) . unwrap_or_else ( |err| fatalerr ! ( "Error: invalid regex in 'excl' entry in configuration file: {}" , err) ) ) ;
345
346
let trim = col[ "trim" ] . as_bool ( ) . unwrap_or ( false ) ;
346
347
let attr = col[ "attr" ] . as_str ( ) ;
347
348
let convert = col[ "conv" ] . as_str ( ) ;
0 commit comments