5.2 Example 2

In this example, let us assume that I wrote a subroutine and invoked it from many points in the program. let us assume that I made a consistent mistake and forgot to use the address of (the & operator) of the second parameter. However, this mistake is made only if the second parameter is ‘var1’. How do we search for this particular pattern. Oh, let us assume the name of the subroutine is ‘f1’.

In Vi, we can use the following command to look for this pattern: /f1[ \t]*(.*,[ \t]*var1[ \t]*,.*). Let us disect this command a little:

This can potentially be very useful because I may have a lot of invocations of f1, of which only 2% use var1 as the second parameter. Note that if part of the code is already fixed by using &var1 instead of var1, the search pattern ignores those fixed occurances!