关于struct dirent 中d_name成员在某些系统中为1的问题。

本文探讨了C99标准下伸缩数组的应用场景及其如何实现变长数据结构。通过具体实例解释了如何利用char[0]或char[1]进行内存管理,并对比了不同方法的优势。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

此为伸缩型结构成员的问题,详见c primer plus中相关章节

 

1楼 发表于 2007-9-19 23:19   
我在书中看到有以下结构描述.
struct dirent{
.......
.......
char a[1];}
其中a[1]是文件名地址.也有的书用a[255]描述.
我对此非常不解,a[1]怎么能放文件指针呢,作为字符数组,也只能够放'/0'.
请各位释疑,万分感谢.


===========================================================================


2楼 发表于 2007-9-20 09:03  
 


QUOTE:
原帖由 liurengui 于 2007-9-19 23:19 发表 
我在书中看到有以下结构描述.
struct dirent{
.......
.......
char a[1];}
其中a[1]是文件名地址.也有的书用a[255]描述.
我对此非常不解,a[1]怎么能放文件指针呢,作为字符数组,也只能够放'/0'.
请各位释 ... 
一般用于一些变长的数据结构, 方便访问结构体后面的地址. 可以让最后一位为char [0] 或者是 char [1]这种类型
如:

[Copy to clipboard] [ - ]CODE:
struct dirent
{
   int len;
   char a[0];
};

struct dirent *fun(char *str, int len)
{
   struct dirent* n = (struct dirent*)malloc(len +1 + sizeof(struct dirent));
   if (!n)
      return NULL;
   n->len = len;
   memcpy(n->a, str, len);
   return n;
}

===========================================================================

3楼 发表于 2007-9-20 09:20   
楼上是正解,还有一点值得说明的是.这些char a[0] 或者 char a[1] 必须作为结构体的最后一个成员.


===========================================================================

4楼 发表于 2007-9-20 11:37  


QUOTE:
原帖由 web_surf 于 2007-9-20 09:20 发表 
楼上是正解,还有一点值得说明的是.这些char a[0] 或者 char a[1] 必须作为结构体的最后一个成员. 
个人以为, char[0]更似更值得推荐,因为这样不会增加结构的size!而且大多数情况下,更利于对齐!


===========================================================================

5楼 发表于 2007-9-20 12:35   
但是字符数组长度定义成1,只能够存'/0',其他根本就存不下了。
为什么不直接定义成这样,char *a;这样不更简单.


===========================================================================

6楼 发表于 2007-9-20 12:45   
使用了malloc()给其分配了空间的, 所以说它可以有存放数据的空间. 使用char *p的方法也行, 不过这个结构体要多占sizeof(char*)这么多个字节, 在有些空间比较少的领域可以使用这种方式来减少空间的使用.


===========================================================================

7楼 发表于 2007-9-20 16:46  


QUOTE:
原帖由 独孤九贱 于 2007-9-20 11:37 发表


个人以为, char[0]更似更值得推荐,因为这样不会增加结构的size!而且大多数情况下,更利于对齐! 
说得一点都没错,不过我有点疑惑, 既然是char [0], sizeof(struct)也没发现这个变量占用了内存空间,但还是可以访问这个变量.奇怪,晚上会去查查c99怎么定义char[0]的.

查到了, c99这样定义的
struct s
{
  int a;
  char b[];
};

struct ss
{
  int a;
  char b[1];
};

sizeof(struct s) = offsetof(struct s, b) = offsetof(struct ss, b);


===========================================================================

8楼 发表于 2007-9-20 16:54  


QUOTE:
原帖由 liurengui 于 2007-9-20 12:35 发表 
但是字符数组长度定义成1,只能够存'/0',其他根本就存不下了。
为什么不直接定义成这样,char *a;这样不更简单. 
谁说长度为1就只能存'/0'了.malloc时扩展了size的. 而扩展的size正好在struct的尾端, 也就是说扩展的内存跟最后一个成员char p[0]的地址是相邻的. 也就是说可以通过成员char p[0]访问.
用char p[0]比char *p的好处是:
(1) 前者malloc之后不需要给p赋值,因为前者是array.
(2) 前者实现了一个动态数组的功能,如果不需要,他根本就可以不占用任何内存,而后者会占用4个字节.


#define _GNU_SOURCE #include <sys/ptrace.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <elf.h> #include <sys/uio.h> #include <sys/stat.h> #include <dirent.h> #include <asm/ptrace.h> // 修复1: 正确定义ARM64硬件调试寄存器 #ifndef NT_ARM_HW_BREAK #define NT_ARM_HW_BREAK 0x402 // 执行断点 #endif #ifndef NT_ARM_HW_WATCH #define NT_ARM_HW_WATCH 0x403 // 观察点 #endif // 修复2: 正确定义调试寄存器状态结构体 struct user_hwdebug_state { uint32_t dbg_info; // 调试信息 uint32_t pad; // 填充 struct { uint64_t addr; // 地址寄存器 uint64_t ctrl; // 控制寄存器 } dbg_regs[16]; // 最大16个断点 }; // 获取线程ID int get_threads(pid_t pid, pid_t *threads, int max_threads) { char path[64]; int count = 0; snprintf(path, sizeof(path), "/proc/%d/task", pid); DIR *dir = opendir(path); if (!dir) { perror("opendir failed"); return 0; } struct dirent *entry; while ((entry = readdir(dir)) != NULL) { if (count >= max_threads) break; if (entry->d_type == DT_DIR && strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { threads[count++] = atoi(entry->d_name); } } closedir(dir); return count; } // 附加到进程 bool attach_to_process(pid_t pid) { if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) { perror("【错误】附加主进程失败"); return false; } int status; if (waitpid(pid, &status, 0) < 0) { perror("【错误】等待主进程失败"); return false; } pid_t threads[64]; int thread_count = get_threads(pid, threads, 64); if (thread_count == 0) { fprintf(stderr, "【警告】未找到任何线程\n"); return false; } for (int i = 0; i < thread_count; i++) { pid_t tid = threads[i]; if (tid == pid) continue; if (ptrace(PTRACE_ATTACH, tid, NULL, NULL) < 0) { perror("【错误】附加子线程失败"); continue; } if (waitpid(tid, &status, 0) < 0) { perror("【错误】等待子线程失败"); ptrace(PTRACE_DETACH, tid, NULL, NULL); continue; } printf("【已附加线程】tid=%d\n", tid); } return true; } // 修复3: 正确设置硬件断点 bool set_hw_breakpoint(pid_t pid, pid_t thread_id, uintptr_t addr, int len, int type) { // 选择寄存器集类型 int nt_type = (type == 0) ? NT_ARM_HW_BREAK : NT_ARM_HW_WATCH; struct user_hwdebug_state dbg_regs; struct iovec iov = { .iov_base = &dbg_regs, .iov_len = sizeof(dbg_regs) }; // 获取当前状态 if (ptrace(PTRACE_GETREGSET, thread_id, nt_type, &iov) < 0) { perror("【错误】PTRACE_GETREGSET获取失败"); return false; } // 查找空闲槽位 int slot = -1; for (int i = 0; i < 16; i++) { if (dbg_regs.dbg_regs[i].addr == 0) { slot = i; break; } } if (slot == -1) { fprintf(stderr, "【错误】线程%d无可用硬件断点\n", thread_id); return false; } // 设置控制寄存器 uint64_t ctrl_value = 0; if (type == 0) { // 执行断点 ctrl_value = (1 << 0) | // 启用 (0b01 << 8); // 用户空间(EL0) } else { // 观察点 // 计算BAS掩码 uint64_t bas = 0; switch (len) { case 1: bas = 0x1; break; case 2: bas = 0x3; break; case 4: bas = 0xF; break; case 8: bas = 0xFF; break; default: fprintf(stderr, "【错误】无效长度: %d\n", len); return false; } ctrl_value = (1 << 0) | // 启用 (0b01 << 8); // 用户空间(EL0) // 设置类型 if (type == 1) { // 读 ctrl_value |= (0b01 << 3); // Load } else if (type == 2) { // 写 ctrl_value |= (0b10 << 3); // Store } else if (type == 3) { // 读写 ctrl_value |= (0b11 << 3); // Load/Store } // 设置长度(BAS) ctrl_value |= (bas << 16); } // 设置地址和控制寄存器 dbg_regs.dbg_regs[slot].addr = addr; dbg_regs.dbg_regs[slot].ctrl = ctrl_value; // 应用设置 if (ptrace(PTRACE_SETREGSET, thread_id, nt_type, &iov) < 0) { perror("【错误】PTRACE_SETREGSET设置失败"); return false; } printf("【线程%d断点设置成功】 地址:0x%llx 类型:%s 长度:%d字节\n", thread_id, (unsigned long long)addr, type == 0 ? "执行" : type == 1 ? "读" : type == 2 ? "写" : "读写", len); return true; } // 清除所有硬件断点 bool clear_all_hw_breakpoints(pid_t thread_id) { struct user_hwdebug_state dbg_regs; struct iovec iov = { .iov_base = &dbg_regs, .iov_len = sizeof(dbg_regs) }; // 清除执行断点 memset(&dbg_regs, 0, sizeof(dbg_regs)); if (ptrace(PTRACE_SETREGSET, thread_id, NT_ARM_HW_BREAK, &iov) < 0) { perror("【错误】清除执行断点失败"); } // 清除观察点 memset(&dbg_regs, 0, sizeof(dbg_regs)); if (ptrace(PTRACE_SETREGSET, thread_id, NT_ARM_HW_WATCH, &iov) < 0) { perror("【错误】清除观察点失败"); return false; } return true; } // 获取寄存器信息 bool get_registers(pid_t tid, struct user_pt_regs *regs) { struct iovec iov = { .iov_base = regs, .iov_len = sizeof(*regs) }; if (ptrace(PTRACE_GETREGSET, tid, NT_PRSTATUS, &iov) < 0) { perror("【错误】PTRACE_GETREGSET获取失败"); return false; } return true; } int main() { pid_t target_pid; printf("【输入目标进程PID】\n"); scanf("%d", &target_pid); if (geteuid() != 0) { fprintf(stderr, "【错误】需要root权限\n"); return 1; } if (!attach_to_process(target_pid)) { fprintf(stderr, "【致命错误】无法附加目标进程\n"); return 1; } uintptr_t bp_addr; printf("【输入断点地址(十六进制)】\n"); scanf("%llx", (unsigned long long *)&bp_addr); int len, type; printf("【选择断点类型(0:执行,1:读,2:写,3:读写)】\n"); scanf("%d", &type); if (type != 0) { printf("【输入断点长度(1,2,4,8字节)】\n"); scanf("%d", &len); // 检查长度有效性 if (len != 1 && len != 2 && len != 4 && len != 8) { fprintf(stderr, "【错误】无效长度,使用默认值4字节\n"); len = 4; } } else { len = 4; // 执行断点长度固定 } pid_t threads[64]; int thread_count = get_threads(target_pid, threads, 64); for (int i = 0; i < thread_count; i++) { pid_t tid = threads[i]; printf("【处理线程】tid=%d\n", tid); if (!set_hw_breakpoint(target_pid, tid, bp_addr, len, type)) { fprintf(stderr, "【警告】线程%d断点设置失败\n", tid); continue; } } printf("【恢复进程执行...】\n"); if (ptrace(PTRACE_CONT, target_pid, NULL, NULL) < 0) { perror("【错误】恢复执行失败"); return 1; } printf("【等待断点触发...】\n"); int status; pid_t wait_pid = waitpid(-1, &status, 0); bool breakpoint_hit = false; for (int i = 0; i < thread_count; i++) { pid_t tid = threads[i]; int nt_type = (type == 0) ? NT_ARM_HW_BREAK : NT_ARM_HW_WATCH; struct user_hwdebug_state dbg_regs; struct iovec iov = { .iov_base = &dbg_regs, .iov_len = sizeof(dbg_regs) }; if (ptrace(PTRACE_GETREGSET, tid, nt_type, &iov) < 0) { perror("【错误】获取调试寄存器失败"); continue; } for (int j = 0; j < 16; j++) { if (dbg_regs.dbg_regs[j].addr == bp_addr && (dbg_regs.dbg_regs[j].ctrl & 0x1)) { breakpoint_hit = true; printf("\n【断点命中!】\n"); printf("触发线程:tid=%d\n", tid); printf("命中地址:0x%llx\n", (unsigned long long)bp_addr); const char *type_str = type == 0 ? "执行" : type == 1 ? "读" : type == 2 ? "写" : "读写"; printf("类型:%s | 长度:%d字节\n", type_str, len); struct user_pt_regs regs; if (get_registers(tid, &regs)) { printf("\n寄存器状态:\n"); printf("PC=0x%llx (程序计数器)\n", (unsigned long long)regs.pc); printf("LR=0x%llx (链接寄存器x30)\n", (unsigned long long)regs.regs[30]); printf("SP=0x%llx (栈指针sp)\n", (unsigned long long)regs.sp); printf("X0=0x%llx, X1=0x%llx, X2=0x%llx, X3=0x%llx\n", (unsigned long long)regs.regs[0], (unsigned long long)regs.regs[1], (unsigned long long)regs.regs[2], (unsigned long long)regs.regs[3]); } break; } } if (breakpoint_hit) break; } if (!breakpoint_hit) { printf("\n【未检测到断点命中,恢复进程执行...】\n"); ptrace(PTRACE_CONT, target_pid, NULL, NULL); } printf("\n【清理断点...】\n"); for (int i = 0; i < thread_count; i++) { pid_t tid = threads[i]; if (!clear_all_hw_breakpoints(tid)) { fprintf(stderr, "【警告】线程%d断点清除失败\n", tid); } else { printf("【已清除线程】tid=%d的断点\n", tid); } } printf("\n【分离调试会话...】\n"); for (int i = 0; i < thread_count; i++) { pid_t tid = threads[i]; if (ptrace(PTRACE_DETACH, tid, NULL, NULL) < 0) { perror("【错误】分离线程失败"); } } return 0; } Android NDK: src/ptrace断点.cpp.bak [arm64-v8a] Compile++ : 无痕hook.sh <= ptrace断点.cpp jni/src/ptrace断点.cpp:25:8: error: redefinition of 'user_hwdebug_state' struct user_hwdebug_state { ^ /data/data/com.aide.ui.mgai/no_backup/ndksupport-1710240003/android-ndk-aide/sysroot/usr/include/aarch64-linux-android/asm/ptrace.h:61:8: note: previous definition is here struct user_hwdebug_state { ^ 1 error generated. make: *** [/data/data/com.aide.ui.mgai/no_backup/ndksupport-1710240003/android-ndk-aide/build/core/build-binary.mk:530: obj/local/arm64-v8a/objs/无痕hook.sh/src/ptrace 断点.o] Error 1 修复好报错问题完整发给我
07-14
// 补全状态结构(优化版) typedef struct { char **matches; // 所有匹配项 int count; // 匹配项总数 char *base_dir; // 当前基础目录 char *original_prefix; // 原始前缀 char *current_text; // 当前输入文本 int last_state; // 上一次使用的state值 int current_level; // 当前目录层级 char *persistent_path; // 持久化路径(同时作为初始化标志) int is_directory; int max_level; // 最大允许层级(关键新增) } CompletionState; static CompletionState comp_state = { .matches = NULL, .count = 0, .base_dir = NULL, .original_prefix = NULL, .current_text = NULL, .last_state = -1, .current_level = 0, .persistent_path = NULL, .is_directory = 0, .max_level = 0 }; // 重置补全状态 void reset_completion_state() { if (comp_state.matches) { for (int i = 0; i < comp_state.count; i++) { XFREE(MTYPE_TMP, comp_state.matches[i]); } XFREE(MTYPE_TMP, comp_state.matches); comp_state.matches = NULL; } if (comp_state.original_prefix) { XFREE(MTYPE_TMP, comp_state.original_prefix); } if (comp_state.base_dir) { XFREE(MTYPE_TMP, comp_state.base_dir); } if (comp_state.current_text) { XFREE(MTYPE_TMP, comp_state.current_text); } if (comp_state.persistent_path) { XFREE(MTYPE_TMP, comp_state.persistent_path); } comp_state.count = 0; comp_state.original_prefix = NULL; comp_state.base_dir = NULL; comp_state.current_text = NULL; comp_state.last_state = -1; comp_state.current_level = 0; comp_state.persistent_path = NULL; // 关键:清除持久化路径 comp_state.is_directory = 0; comp_state.max_level = 0; } // 修复的路径解析函数 void parse_input_text(const char *text, char **base_dir, char **prefix, int *level) { *level = 0; const char *ptr = text; while (*ptr) { if (*ptr == '/') (*level)++; ptr++; } const char *last_slash = strrchr(text, '/'); const char *last_char = text + strlen(text) - 1; if (last_slash) { if (last_char == last_slash) { size_t base_len = last_slash - text + 1; *base_dir = (char *)XCALLOC(MTYPE_TMP, base_len + 1); strncpy(*base_dir, text, base_len); (*base_dir)[base_len] = '\0'; *prefix = XSTRDUP(MTYPE_TMP, ""); } else { size_t base_len = last_slash - text + 1; *base_dir = (char *)XCALLOC(MTYPE_TMP, base_len + 1); strncpy(*base_dir, text, base_len); (*base_dir)[base_len] = '\0'; *prefix = XSTRDUP(MTYPE_TMP, last_slash + 1); } } else { *base_dir = XSTRDUP(MTYPE_TMP, ""); *prefix = XSTRDUP(MTYPE_TMP, text); } printf("parse_input_text: text = %s, base_dir = %s, prefix = %s, level = %d\n", text, *base_dir, *prefix, *level); } // 修复的上下文检测函数 int is_same_completion_context(const char *text) { if (!comp_state.persistent_path || !text) return 0; // 临时解析获取当前层级 char *temp_base = NULL; char *temp_prefix = NULL; int current_level = 0; parse_input_text(text, &temp_base, &temp_prefix, &current_level); // 关键改进:检查是否超过最大层级 int within_level_limit = (current_level <= comp_state.max_level); // 检查路径前缀是否相同 size_t len = strlen(comp_state.persistent_path); int same_path = strncmp(text, comp_state.persistent_path, len) == 0; XFREE(MTYPE_TMP, temp_base); XFREE(MTYPE_TMP, temp_prefix); printf("is_same_completion_context: text=%s persistent=%s level=%d/%d same_path=%d within_level=%d\n", text, comp_state.persistent_path, current_level, comp_state.max_level, same_path, within_level_limit); return same_path && within_level_limit; } // 路径比较函数 int compare_paths(const void *a, const void *b) { const char *path1 = *(const char **)a; const char *path2 = *(const char **)b; return strcmp(path1, path2); } // 修复的目录内容生成函数 char **generate_current_dir_paths(const char *base_dir, const char *prefix, int add_empty) { // 关键修复:正确处理空目录路径 const char *scan_dir = base_dir; if (!scan_dir || strlen(scan_dir) == 0) { scan_dir = "."; } printf("[generate] Scanning: '%s' with prefix '%s'\n", scan_dir, prefix ? prefix : "(none)"); DIR *dir = opendir(scan_dir); if (!dir) { printf("opendir failed"); if (add_empty) { char **matches = (char **)XCALLOC(MTYPE_TMP, sizeof(char *)); matches[0] = XSTRDUP(MTYPE_TMP, ""); return matches; } return NULL; } int capacity = 32; int count = 0; char **matches = (char **)XCALLOC(MTYPE_TMP, capacity * sizeof(char *)); struct dirent *entry; while ((entry = readdir(dir)) != NULL) { char *name = entry->d_name; // 跳过特殊目录 if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) { continue; } // 应用前缀过滤 if (prefix && *prefix && strncmp(name, prefix, strlen(prefix)) != 0) { continue; } // 检测目录类型 int is_dir = 0; if (entry->d_type == DT_DIR) { is_dir = 1; } else if (entry->d_type == DT_UNKNOWN) { char full_path[PATH_MAX]; snprintf(full_path, sizeof(full_path), "%s/%s", scan_dir, name); struct stat statbuf; if (stat(full_path, &statbuf) == 0 && S_ISDIR(statbuf.st_mode)) { is_dir = 1; } } // 创建带斜杠的目录名 char *new_name; if (is_dir) { new_name = (char *)XCALLOC(MTYPE_TMP, strlen(name) + 2); sprintf(new_name, "%s/", name); } else { new_name = XSTRDUP(MTYPE_TMP, name); } // 添加到匹配列表 if (count >= capacity) { capacity *= 2; matches = (char **)XREALLOC(MTYPE_TMP, matches, capacity * sizeof(char *)); } matches[count++] = new_name; } closedir(dir); // 排序结果 if (count > 0) { qsort(matches, count, sizeof(char *), compare_paths); } // Null-terminate if (count >= capacity) { matches = (char **)XREALLOC(MTYPE_TMP, matches, (count+1) * sizeof(char *)); } matches[count] = NULL; // 在非顶级目录添加空字符串作为循环结束标记 if (count > 0 && !add_empty) { matches = (char **)XREALLOC(MTYPE_TMP, matches, (count+2) * sizeof(char *)); matches[count] = XSTRDUP(MTYPE_TMP, ""); matches[count+1] = NULL; count++; } printf("[generate] Found %d matches\n", count); return matches; } // 修复的智能文件补全函数 char *filename_completion_function(const char *text, int state) { printf("\n[COMP] Entering: text='%s', state=%d, last_state=%d\n", text, state, comp_state.last_state); // 初始化新补全 if (state == 0) { int same_context = is_same_completion_context(text); printf(" Same context: %d\n", same_context); if (!same_context) { // 上下文变化,重置状态 reset_completion_state(); char *current_base = NULL; char *current_prefix = NULL; int current_level = 0; // 解析当前输入文本 parse_input_text(text, &current_base, &current_prefix, &current_level); printf(" Parsed: base='%s', prefix='%s', level=%d\n", current_base, current_prefix, current_level); // 初始化状态 comp_state.base_dir = current_base; comp_state.current_text = XSTRDUP(MTYPE_TMP, text); comp_state.current_level = current_level; // 设置持久化路径(当前目录) if (strlen(current_base) > 0) { comp_state.persistent_path = XSTRDUP(MTYPE_TMP, current_base); } else { comp_state.persistent_path = XSTRDUP(MTYPE_TMP, "."); } // 仅在顶级目录添加空字符串项 int add_empty = (current_level == 0) ? 1 : 0; // 生成匹配项 comp_state.matches = generate_current_dir_paths(current_base, current_prefix, add_empty); // 计算匹配项数量 if (comp_state.matches) { comp_state.count = 0; while (comp_state.matches[comp_state.count]) { comp_state.count++; } printf(" Generated %d matches\n", comp_state.count); } else { comp_state.count = 0; } comp_state.last_state = -1; } } // 无匹配项时返回NULL if (!comp_state.matches || comp_state.count == 0) { printf("[COMP] No matches found\n"); return NULL; } // 循环获取下一个匹配项 int next_index = (comp_state.last_state + 1) % comp_state.count; comp_state.last_state = next_index; char *match = comp_state.matches[next_index]; printf(" Next index: %d/%d, match='%s'\n", next_index, comp_state.count - 1, match); // 构建完整路径 char *full_path = NULL; if (comp_state.base_dir && strlen(comp_state.base_dir) > 0) { int base_len = strlen(comp_state.base_dir); int needs_slash = (comp_state.base_dir[base_len - 1] != '/'); int len = base_len + strlen(match) + (needs_slash ? 1 : 0) + 1; full_path = (char *)XCALLOC(MTYPE_TMP, len); if (needs_slash) { snprintf(full_path, len, "%s/%s", comp_state.base_dir, match); } else { snprintf(full_path, len, "%s%s", comp_state.base_dir, match); } } else { full_path = XSTRDUP(MTYPE_TMP, match); } printf("[COMP] Returning: '%s'\n", full_path); return full_path; } // 补全匹配函数(返回单个匹配项) char **filename_completion_matches(const char *text, CPFunction* genfunc) { printf("\n[MATCHES] Called with text='%s'\n", text); // 获取下一个匹配项 char *match = (*genfunc)(text, 0); if (!match) { printf("[MATCHES] No matches found\n"); return NULL; } // 创建只包含一个匹配项的数组 char **matches = (char **)XCALLOC(MTYPE_TMP, 2 * sizeof(char *)); matches[0] = match; matches[1] = NULL; printf("[MATCHES] Returning single match: '%s'\n", match); return matches; } <dahua>dir e【cmlsh_completion】text = e [MATCHES] Called with text='e' [COMP] Entering: text='e', state=0, last_state=-1 Same context: 0 parse_input_text: text = e, base_dir = , prefix = e, level = 0 Parsed: base='', prefix='e', level=0 [generate] Scanning: '.' with prefix 'e' [generate] Found 1 matches Generated 1 matches Next index: 0/0, match='etc/' [COMP] Returning: 'etc/' [MATCHES] Returning single match: 'etc/' tc/【cmlsh_completion】text = etc/ [MATCHES] Called with text='etc/' [COMP] Entering: text='etc/', state=0, last_state=0 parse_input_text: text = etc/, base_dir = etc/, prefix = , level = 1 is_same_completion_context: text=etc/ persistent=. level=1/0 same_path=0 within_level=0 Same context: 0 parse_input_text: text = etc/, base_dir = etc/, prefix = , level = 1 Parsed: base='etc/', prefix='', level=1 [generate] Scanning: 'etc/' with prefix '' [generate] Found 5 matches Generated 5 matches Next index: 0/4, match='CML_DB.db' [COMP] Returning: 'etc/CML_DB.db' [MATCHES] Returning single match: 'etc/CML_DB.db' CML_DB.db【cmlsh_completion】text = etc/CML_DB.db [MATCHES] Called with text='etc/CML_DB.db' [COMP] Entering: text='etc/CML_DB.db', state=0, last_state=0 parse_input_text: text = etc/CML_DB.db, base_dir = etc/, prefix = CML_DB.db, level = 1 is_same_completion_context: text=etc/CML_DB.db persistent=etc/ level=1/0 same_path=1 within_level=0 Same context: 0 parse_input_text: text = etc/CML_DB.db, base_dir = etc/, prefix = CML_DB.db, level = 1 Parsed: base='etc Username: 上边的代码逻辑会异常退出
最新发布
08-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值