void urj_completion_mayben_add_match (char ***matches, size_t *cnt, const char *text, size_t text_len, const char *match) { if (!strncmp (text, match, text_len)) urj_completion_add_match_dupe (matches, cnt, match); }
static void cmd_flashmem_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, const char *text, size_t text_len, size_t token_point) { switch (token_point) { case 1: /* [addr|msbin] */ break; case 2: /* filename */ { #ifdef HAVE_LIBREADLINE int state; char *match; state = 0; while (1) { match = rl_filename_completion_function (text, state++); if (!match) break; urj_completion_add_match_dupe (matches, match_cnt, match); free (match); } #endif break; } case 3: /* [noverify] */ urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "noverify"); break; } }
void urj_completion_mayben_add_file (char ***matches, size_t *cnt, const char *text, size_t text_len, bool search) { #ifdef HAVE_LIBREADLINE int state; size_t implicit_len; char *match, *search_text; /* Use the search path if path isn't explicitly relative/absolute */ if (search && text[0] != '/' && text[0] != '.') { const char *jtag_data_dir = urj_get_data_dir (); implicit_len = strlen (jtag_data_dir) + 1; search_text = malloc (implicit_len + text_len + 1); if (!search_text) return; sprintf (search_text, "%s/%s", jtag_data_dir, text); text = search_text; text_len += implicit_len; } else { implicit_len = 0; search_text = NULL; } state = 0; while (1) { match = rl_filename_completion_function (text, state++); if (!match) break; urj_completion_add_match_dupe (matches, cnt, match + implicit_len); free (match); } free (search_text); #endif }