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

Function msh_auto_complete

components/finsh/msh.c:776–851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

774#endif /* DFS_USING_POSIX */
775
776void msh_auto_complete(char *prefix)
777{
778 int length, min_length;
779 const char *name_ptr, *cmd_name;
780 struct finsh_syscall *index;
781
782 min_length = 0;
783 name_ptr = RT_NULL;
784
785 if (*prefix == '\0')
786 {
787 msh_help(0, RT_NULL);
788 return;
789 }
790
791#ifdef DFS_USING_POSIX
792 /* check whether a spare in the command */
793 {
794 char *ptr;
795
796 ptr = prefix + rt_strlen(prefix);
797 while (ptr != prefix)
798 {
799 if (*ptr == ' ')
800 {
801 msh_auto_complete_path(ptr + 1);
802 break;
803 }
804
805 ptr --;
806 }
807#if defined(RT_USING_MODULE) || defined(RT_USING_SMART)
808 /* There is a chance that the user want to run the module directly. So
809 * try to complete the file names. If the completed path is not a
810 * module, the system won't crash anyway. */
811 if (ptr == prefix)
812 {
813 msh_auto_complete_path(ptr);
814 }
815#endif /* RT_USING_MODULE */
816 }
817#endif /* DFS_USING_POSIX */
818#if defined(FINSH_USING_SYMTAB)
819 /* checks in internal command */
820 {
821 for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index))
822 {
823 /* skip finsh shell function */
824 cmd_name = (const char *) index->name;
825 if (strncmp(prefix, cmd_name, strlen(prefix)) == 0)
826 {
827 if (min_length == 0)
828 {
829 /* set name_ptr */
830 name_ptr = cmd_name;
831 /* set initial length */
832 min_length = strlen(name_ptr);
833 }

Callers 1

shell_auto_completeFunction · 0.85

Calls 6

msh_helpFunction · 0.85
rt_strlenFunction · 0.85
msh_auto_complete_pathFunction · 0.85
str_commonFunction · 0.85
rt_kprintfFunction · 0.85
rt_strncpyFunction · 0.85

Tested by

no test coverage detected