gentoo/net-analyzer/termshark/files/2.4.0-column-titles.patch
Holger Hoffstätte 4ce4f6c95f
net-analyzer/termshark: fix tests with wireshark-4.6.0
Also add a small simplification/peformance fix.

Closes: https://bugs.gentoo.org/964258
Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Part-of: https://github.com/gentoo/gentoo/pull/44556
Closes: https://github.com/gentoo/gentoo/pull/44556
Signed-off-by: Sam James <sam@gentoo.org>
2025-11-12 09:40:35 +00:00

51 lines
1.6 KiB
Diff

https://github.com/gcla/termshark/pull/170
From: Gilbert Ramirez <gram@alumni.rice.edu>
Date: Sun, 19 Oct 2025 10:55:04 -0500
Subject: [PATCH] Issue 169: With Wireshark 4.6.0, the column-title glossary changed
A third column is now possible, so the column-format initializer
needs to handle it. Also, since the output is a simple
tab-separated-value format, we don't need regular expressions to
parse it. We only need to split on tab characters.
--- a/pkg/shark/columnformat.go
+++ b/pkg/shark/columnformat.go
@@ -8,7 +8,6 @@ import (
"bufio"
"fmt"
"os/exec"
- "regexp"
"strconv"
"strings"
"sync"
@@ -239,8 +238,6 @@ func (w *ColumnsFromTshark) InitFromCache() error {
}
func (w *ColumnsFromTshark) InitNoCache() error {
- re := regexp.MustCompile("\\s+")
-
cmd := exec.Command(termshark.TSharkBin(), []string{"-G", "column-formats"}...)
out, err := cmd.StdoutPipe()
@@ -254,11 +251,17 @@ func (w *ColumnsFromTshark) InitNoCache() error {
scanner := bufio.NewScanner(out)
for scanner.Scan() {
- fields := re.Split(scanner.Text(), 2)
- if len(fields) == 2 && strings.HasPrefix(fields[0], "%") {
+ fields := strings.Split(scanner.Text(), "\t")
+
+ // Column 0: The format
+ // Column 1: The title of the column
+ // Column 2: The display filter field (optional)
+ if (len(fields) == 2 || len(fields) == 3) && strings.HasPrefix(fields[0], "%") {
+ // Remove trailing whitespace, if any
+ columnTitle := strings.TrimRight(fields[1], " ")
w.fields = append(w.fields, PsmlColumnSpec{
Field: PsmlField{Token: fields[0]},
- Name: fields[1],
+ Name: columnTitle,
})
}
}