Skip to content

Commit e4809df

Browse files
committed
Always use real tag (not "latest") for source links
1 parent 72a6e54 commit e4809df

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

Diff for: scripts/build_web_db.py

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def main() -> int:
122122
# Add special "latest" tag as a copy of the highest tag
123123
latest = max(abi_index, key=tag_to_tuple)
124124
abi_index['latest'] = abi_index[latest].copy()
125+
abi_index['latest']['real_tag'] = latest
125126
copytree(abidir / latest, abidir / 'latest')
126127

127128
with (rootdir / 'index.json').open('w') as f:

Diff for: www/index.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ function favoriteArch(archs) {
197197
return archs[0]
198198
}
199199

200+
function realTag(arch, bits, abi, tag) {
201+
// Convert special "latest" tag to real tag, leave others alone
202+
if (tag === 'latest')
203+
return db[arch][bits][abi]['latest']['real_tag']
204+
return tag
205+
}
206+
200207
function fillArchOptions(archs) {
201208
clearOptions(archSelectEl)
202209
archs.forEach(([arch, bits, abi]) => {
@@ -312,7 +319,7 @@ function toggleCollapseColumn(e) {
312319
localStorage.setItem('collapsedColumns', tableEl.dataset.collapse)
313320
}
314321

315-
function fillRow(row, tag, sc, maxArgs) {
322+
function fillRow(row, realTag, sc, maxArgs) {
316323
const cells = [
317324
document.createElement('td'), document.createElement('td'),
318325
document.createElement('td'), document.createElement('td'),
@@ -349,7 +356,7 @@ function fillRow(row, tag, sc, maxArgs) {
349356
const link = document.createElement('a')
350357
link.target = '_blank'
351358
link.title = 'View in Bootlin Elixir cross referencer'
352-
link.href = `https://elixir.bootlin.com/linux/${tag}/source/${sc.file}#L${sc.line}`
359+
link.href = `https://elixir.bootlin.com/linux/${realTag}/source/${sc.file}#L${sc.line}`
353360
link.textContent = `${sc.file}:${sc.line}`
354361
loc.appendChild(link)
355362
}
@@ -444,7 +451,7 @@ function fillRow(row, tag, sc, maxArgs) {
444451
}
445452
}
446453

447-
function fillTable(syscallTable, tag) {
454+
function fillTable(syscallTable, realTag) {
448455
const numReg = syscallTable.kernel.abi.calling_convention.syscall_nr
449456
const argRegs = syscallTable.kernel.abi.calling_convention.parameters
450457
const maxArgs = syscallTable.syscalls.reduce((acc, sc) => Math.max(acc, sc.signature?.length || 0), 0)
@@ -490,7 +497,7 @@ function fillTable(syscallTable, tag) {
490497

491498
for (const sc of syscallTable.syscalls) {
492499
const row = document.createElement('tr')
493-
fillRow(row, tag, sc, maxArgs)
500+
fillRow(row, realTag, sc, maxArgs)
494501
tableEl.appendChild(row)
495502
}
496503

@@ -502,11 +509,12 @@ function toggleCompactSignature() {
502509
if (updateInProgress)
503510
return
504511

505-
const tag = getSelection().pop()
512+
const selection = getSelection()
513+
const [arch, bits, abi, tag] = selection
506514
compactSignature = !compactSignature
507515
localStorage.setItem('compactSignature', compactSignature)
508516
// Could be optimized... but I could also not care less for now
509-
fillTable(currentSyscallTable, tag)
517+
fillTable(currentSyscallTable, realTag(arch, bits, abi, tag))
510518
}
511519

512520
async function update(pushHistoryState) {
@@ -516,7 +524,7 @@ async function update(pushHistoryState) {
516524
const newTitle = `Linux syscall table: ${tag}, ${getArchSelectionText()}`
517525

518526
currentSyscallTable = await fetchSyscallTable(arch, bits, abi, tag)
519-
fillTable(currentSyscallTable, tag)
527+
fillTable(currentSyscallTable, realTag(arch, bits, abi, tag))
520528

521529
// Some stats at the bottom of the table
522530
const n_syscalls = currentSyscallTable.syscalls.length

0 commit comments

Comments
 (0)