| skipped 22 lines |
23 | 23 | | // import "github.com/pkg/profile" |
24 | 24 | | |
25 | 25 | | var placeholder *regexp.Regexp |
| 26 | + | var numericPrefix *regexp.Regexp |
26 | 27 | | var activeTempFiles []string |
27 | 28 | | |
28 | 29 | | const ellipsis string = ".." |
29 | 30 | | |
30 | 31 | | func init() { |
31 | 32 | | placeholder = regexp.MustCompile(`\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\+?f?nf?})`) |
| 33 | + | numericPrefix = regexp.MustCompile(`^[[:punct:]]*([0-9]+)`) |
32 | 34 | | activeTempFiles = []string{} |
33 | 35 | | } |
34 | 36 | | |
| skipped 1326 lines |
1361 | 1363 | | |
1362 | 1364 | | // Ascii to positive integer |
1363 | 1365 | | func atopi(s string) int { |
1364 | | - | n, e := strconv.Atoi(strings.ReplaceAll(s, "'", "")) |
| 1366 | + | matches := numericPrefix.FindStringSubmatch(s) |
| 1367 | + | if len(matches) < 2 { |
| 1368 | + | return 0 |
| 1369 | + | } |
| 1370 | + | n, e := strconv.Atoi(matches[1]) |
1365 | 1371 | | if e != nil || n < 1 { |
1366 | 1372 | | return 0 |
1367 | 1373 | | } |
| skipped 964 lines |