整理打印

This commit is contained in:
2025-10-03 00:54:22 +08:00
parent bff7f73d8b
commit 73480005eb
6 changed files with 63 additions and 3 deletions
+8
View File
@@ -124,6 +124,14 @@ func parseFunctions(lines []string, exportedFunctions map[string]bool) []ErlangF
inFunction = false
currentFunction = ErlangFunction{}
}
// 函数结束条件:行以 ; 结束,且括号和花括号匹配
if strings.HasSuffix(trimmedLine, ";") && braceCount == 0 && parenCount == 0 {
currentFunction.EndLine = i + 1
functions = append(functions, currentFunction.ParseComments())
inFunction = false
currentFunction = ErlangFunction{}
}
} else {
// 不在函数中时,遇到非注释行就清空注释缓存
if trimmedLine != "" && !strings.HasPrefix(trimmedLine, "%") {
+19
View File
@@ -51,3 +51,22 @@ func FprintfArgsMap(layer int, out io.Writer, argsMap map[string]any) error {
}
return nil
}
// FindPathByWd 返回目录基于执行目录
func FindPathByWd(path string) (string, error) {
return FindPathByBasePath(os.Getwd, path)
}
// FindPathByExecutable 返回目录基于exe路径
func FindPathByExecutable(path string) (string, error) {
return FindPathByBasePath(os.Executable, path)
}
func FindPathByBasePath(basefun func() (basePath string, err error), path string) (string, error) {
basePath, err := basefun()
if err != nil {
return "", err
}
path = filepath.Join(filepath.Dir(basePath), path)
return path, nil
}