Software /
code /
prosody
Annotate
tools/tb2err @ 13063:414952def2d3
tools/tb2err: Drop use of lua-any since it should run fine on any Lua
Dependencies--; \o/
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 08 Apr 2023 12:53:19 +0200 |
parent | 11191:13e2ac7b5798 |
child | 13064:b172db27ffed |
rev | line source |
---|---|
13063
414952def2d3
tools/tb2err: Drop use of lua-any since it should run fine on any Lua
Kim Alvefur <zash@zash.se>
parents:
11191
diff
changeset
|
1 #!/usr/bin/env lua |
11191
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 -- traceback to errors.err for vim -q |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local path_sep = package.config:sub(1,1); |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 for line in io.lines() do |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local src, err = line:match("%s*(%S+)(:%d+: .*)") |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 if src then |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 src = src:gsub("\\", path_sep); |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 local cut = src:match("/()core/") |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 or src:match("/()net/") |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 or src:match("/()util/") |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 or src:match("/()modules/") |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 or src:match("/()plugins/") |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 or src:match("/()prosody[ctl]*$") |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 if cut then |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 src = src:sub(cut); |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 end |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 src = src:gsub("^modules/", "plugins/") |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 io.write(src, err, "\n"); |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 end |
13e2ac7b5798
tools/tb2err: Formats Lua traceback in errors.err format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 end |