MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / msh_opt_complete

Function msh_opt_complete

components/finsh/msh.c:903–938  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

901}
902
903static void msh_opt_complete(char *opts_str, struct msh_cmd_opt *cmd_opt)
904{
905 struct msh_cmd_opt *opt = cmd_opt;
906 const char *name_ptr = RT_NULL;
907 int min_length = 0, length, opts_str_len;
908
909 opts_str_len = strlen(opts_str);
910
911 for (opt = cmd_opt; opt->id; opt++)
912 {
913 if (!strncmp(opt->name, opts_str, opts_str_len))
914 {
915 if (min_length == 0)
916 {
917 /* set name_ptr */
918 name_ptr = opt->name;
919 /* set initial length */
920 min_length = strlen(name_ptr);
921 }
922
923 length = str_common(name_ptr, opt->name);
924 if (length < min_length)
925 {
926 min_length = length;
927 }
928
929 rt_kprintf("%s\n", opt->name);
930 }
931 }
932 rt_kprintf("\n");
933
934 if (name_ptr != NULL)
935 {
936 strncpy(opts_str, name_ptr, min_length);
937 }
938}
939
940static void msh_opt_help(msh_cmd_opt_t *cmd_opt)
941{

Callers 1

msh_opt_auto_completeFunction · 0.85

Calls 2

str_commonFunction · 0.85
rt_kprintfFunction · 0.85

Tested by

no test coverage detected