File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,14 +9,13 @@ fn main() {
99 let mut line = String :: new ( ) ;
1010 let mut table_name = String :: new ( ) ;
1111 let mut fields = String :: new ( ) ;
12- let re = Regex :: new ( r"^COPY ([\w\.] +) \(([\w, ] +)\) FROM stdin;" ) . unwrap ( ) ;
12+ let re = Regex :: new ( r"^COPY (. +) \((. +)\) FROM stdin;" ) . unwrap ( ) ;
1313 let mut insert_mode = false ;
1414 while stdin. read_line ( & mut line) . unwrap ( ) > 0 {
1515 if insert_mode {
1616 if line == "\\ .\n " {
1717 insert_mode = false ;
18- }
19- else {
18+ } else {
2019 let mut values = String :: new ( ) ;
2120 line. pop ( ) ;
2221 for s in line. replace ( "'" , "''" ) . split ( "\t " ) {
@@ -30,18 +29,19 @@ fn main() {
3029 }
3130 values. pop ( ) ;
3231 values. pop ( ) ;
33- println ! ( "INSERT INTO {} ({}) VALUES ({});" ,
34- table_name, fields, values) ;
32+ println ! (
33+ "INSERT INTO {} ({}) VALUES ({});" ,
34+ table_name, fields, values
35+ ) ;
3536 }
36- }
37- else {
37+ } else {
3838 match re. captures ( & line) {
3939 None => print ! ( "{}" , line) ,
4040 Some ( caps) => {
4141 table_name = String :: from ( caps. get ( 1 ) . map_or ( "" , |m| m. as_str ( ) ) ) ;
4242 fields = String :: from ( caps. get ( 2 ) . map_or ( "" , |m| m. as_str ( ) ) ) ;
4343 insert_mode = true ;
44- } ,
44+ }
4545 } ;
4646 }
4747 line. clear ( ) ;
You can’t perform that action at this time.
0 commit comments