Update type and method references to use qualified names

master
Aadhavan Srinivasan 3 days ago
parent c3c3829ac9
commit c5a43c47f0

@ -78,7 +78,7 @@ func main() {
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
out := bufio.NewWriter(os.Stdout) out := bufio.NewWriter(os.Stdout)
regComp, err := Compile(re, flagsToCompile...) regComp, err := greg.Compile(re, flagsToCompile...)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
@ -119,14 +119,14 @@ func main() {
panic(err) panic(err)
} }
} }
matchIndices := make([]Match, 0) matchIndices := make([]greg.Match, 0)
if matchNumFlagEnabled { if matchNumFlagEnabled {
tmp, err := FindNthMatch(regComp, test_str, *matchNum) tmp, err := greg.FindNthMatch(regComp, test_str, *matchNum)
if err == nil { if err == nil {
matchIndices = append(matchIndices, tmp) matchIndices = append(matchIndices, tmp)
} }
} else { } else {
matchIndices = FindAllMatches(regComp, test_str) matchIndices = greg.FindAllMatches(regComp, test_str)
} }
if *printMatchesFlag { if *printMatchesFlag {
@ -137,7 +137,7 @@ func main() {
fmt.Fprintf(out, "Line %d:\n", lineNum) fmt.Fprintf(out, "Line %d:\n", lineNum)
} }
for _, m := range matchIndices { for _, m := range matchIndices {
fmt.Fprintf(out, "%s\n", m.toString()) fmt.Fprintf(out, "%s\n", m.ToString())
} }
err := out.Flush() err := out.Flush()
if err != nil { if err != nil {
@ -150,7 +150,7 @@ func main() {
// This should make checking O(1) instead of O(n) // This should make checking O(1) instead of O(n)
indicesToPrint := new_uniq_arr[int]() indicesToPrint := new_uniq_arr[int]()
for _, idx := range matchIndices { for _, idx := range matchIndices {
indicesToPrint.add(genRange(idx[0].startIdx, idx[0].endIdx)...) indicesToPrint.add(genRange(idx[0].StartIdx, idx[0].EndIdx)...)
} }
// If we are inverting, then we should print the indices which _didn't_ match // If we are inverting, then we should print the indices which _didn't_ match
// in color. // in color.
@ -185,9 +185,9 @@ func main() {
for i := range test_str { for i := range test_str {
inMatchIndex := false inMatchIndex := false
for _, m := range matchIndices { for _, m := range matchIndices {
if i == m[0].startIdx { if i == m[0].StartIdx {
fmt.Fprintf(out, "%s", *substituteText) fmt.Fprintf(out, "%s", *substituteText)
i = m[0].endIdx i = m[0].EndIdx
inMatchIndex = true inMatchIndex = true
break break
} }
@ -203,7 +203,7 @@ func main() {
// Newline after every match - only if -o is enabled and -v is disabled. // Newline after every match - only if -o is enabled and -v is disabled.
if *onlyFlag && !(*invertFlag) { if *onlyFlag && !(*invertFlag) {
for _, idx := range matchIndices { for _, idx := range matchIndices {
if i+1 == idx[0].endIdx { // End index is one more than last index of match if i+1 == idx[0].EndIdx { // End index is one more than last index of match
fmt.Fprintf(out, "\n") fmt.Fprintf(out, "\n")
break break
} }

Loading…
Cancel
Save