goto to ok_to_continue

This commit is contained in:
Simon Laux
2019-08-12 01:32:34 +02:00
parent b94f9ef496
commit b9bd128c7a

View File

@@ -125,7 +125,7 @@ unsafe fn poke_spec(context: &Context, spec: *const libc::c_char) -> libc::c_int
return 0; return 0;
} }
let mut current_block: u64; let ok_to_continue;
let mut success: libc::c_int = 0; let mut success: libc::c_int = 0;
let real_spec: *mut libc::c_char; let real_spec: *mut libc::c_char;
let mut suffix: *mut libc::c_char = 0 as *mut libc::c_char; let mut suffix: *mut libc::c_char = 0 as *mut libc::c_char;
@@ -138,20 +138,19 @@ unsafe fn poke_spec(context: &Context, spec: *const libc::c_char) -> libc::c_int
.sql .sql
.set_config(context, "import_spec", Some(as_str(real_spec))) .set_config(context, "import_spec", Some(as_str(real_spec)))
.unwrap(); .unwrap();
current_block = 7149356873433890176; ok_to_continue = true;
} else { } else {
let rs = context.sql.get_config(context, "import_spec"); let rs = context.sql.get_config(context, "import_spec");
if rs.is_none() { if rs.is_none() {
error!(context, 0, "Import: No file or folder given."); error!(context, 0, "Import: No file or folder given.");
current_block = 8522321847195001863; ok_to_continue = false;
} else { } else {
current_block = 7149356873433890176; ok_to_continue = true;
} }
real_spec = rs.unwrap_or_default().strdup(); real_spec = rs.unwrap_or_default().strdup();
} }
match current_block { if ok_to_continue {
8522321847195001863 => {} let ok_to_continue2;
_ => {
suffix = dc_get_filesuffix_lc(real_spec); suffix = dc_get_filesuffix_lc(real_spec);
if !suffix.is_null() if !suffix.is_null()
&& strcmp(suffix, b"eml\x00" as *const u8 as *const libc::c_char) == 0 && strcmp(suffix, b"eml\x00" as *const u8 as *const libc::c_char) == 0
@@ -159,7 +158,7 @@ unsafe fn poke_spec(context: &Context, spec: *const libc::c_char) -> libc::c_int
if 0 != dc_poke_eml_file(context, real_spec) { if 0 != dc_poke_eml_file(context, real_spec) {
read_cnt += 1 read_cnt += 1
} }
current_block = 1622411330066726685; ok_to_continue2 = true;
} else { } else {
/* import a directory */ /* import a directory */
let dir_name = std::path::Path::new(as_str(real_spec)); let dir_name = std::path::Path::new(as_str(real_spec));
@@ -171,7 +170,7 @@ unsafe fn poke_spec(context: &Context, spec: *const libc::c_char) -> libc::c_int
"Import: Cannot open directory \"{}\".", "Import: Cannot open directory \"{}\".",
as_str(real_spec), as_str(real_spec),
); );
current_block = 8522321847195001863; ok_to_continue2 = false;
} else { } else {
let dir = dir.unwrap(); let dir = dir.unwrap();
for entry in dir { for entry in dir {
@@ -190,12 +189,10 @@ unsafe fn poke_spec(context: &Context, spec: *const libc::c_char) -> libc::c_int
} }
} }
} }
current_block = 1622411330066726685; ok_to_continue2 = true;
} }
} }
match current_block { if ok_to_continue2 {
8522321847195001863 => {}
_ => {
info!( info!(
context, context,
0, 0,
@@ -207,9 +204,7 @@ unsafe fn poke_spec(context: &Context, spec: *const libc::c_char) -> libc::c_int
context.call_cb(Event::MSGS_CHANGED, 0 as uintptr_t, 0 as uintptr_t); context.call_cb(Event::MSGS_CHANGED, 0 as uintptr_t, 0 as uintptr_t);
} }
success = 1 success = 1
}
} }
}
} }
free(real_spec as *mut libc::c_void); free(real_spec as *mut libc::c_void);