rightPad pads the input with spaces on the right-hand-side to make it have at least width n. It treats tabs as enough spaces that lead to the next 8-aligned tab-stop.
(s string, n int)
| 1085 | // at least width n. It treats tabs as enough spaces that lead to the next |
| 1086 | // 8-aligned tab-stop. |
| 1087 | func rightPad(s string, n int) string { |
| 1088 | var str strings.Builder |
| 1089 | |
| 1090 | // Convert tabs to spaces as we go so padding works regardless of what prefix |
| 1091 | // is placed before the result. |
| 1092 | column := 0 |
| 1093 | for _, c := range s { |
| 1094 | column++ |
| 1095 | if c == '\t' { |
| 1096 | str.WriteRune(' ') |
| 1097 | for column%8 != 0 { |
| 1098 | column++ |
| 1099 | str.WriteRune(' ') |
| 1100 | } |
| 1101 | } else { |
| 1102 | str.WriteRune(c) |
| 1103 | } |
| 1104 | } |
| 1105 | for column < n { |
| 1106 | column++ |
| 1107 | str.WriteRune(' ') |
| 1108 | } |
| 1109 | return str.String() |
| 1110 | } |
| 1111 | |
| 1112 | func canonicalizeFileName(fname string) string { |
| 1113 | fname = strings.TrimPrefix(fname, "/proc/self/cwd/") |
searching dependent graphs…