DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
C programmer's productivity tools

Changing a text string

If you select the sixth item in the task menu, "Change this text string", cscope accepts a search string, prompts you for new text and displays the lines containing the old text. You can select the lines you want changed with any of the following single-key commands:

Commands for selecting lines to be changed

1-9 mark or unmark the line to be changed
* mark or unmark all displayed lines to be changed
space display next lines
+ display next lines
- display previous lines
a mark all lines to be changed
<Ctrl>d change the marked lines and exit
<Esc> exit without changing the marked lines
Suppose you want to change a constant, `100', to a preprocessor symbol, MAXSIZE. Select the menu item "Change this text string" and enter \100.


NOTE: The 1 must be preceded by a ``\'' (backslash) because it has a special meaning (item 1 on the menu) to cscope.

Now press <Return>; cscope will prompt you for the new text string. Type MAXSIZE. This process is illustrated in the following example:

   cscope                               Press the ? key for help
   

List references to this C symbol: Edit this function or #define: List functions called by this function: List functions calling this function: List lines containing this text string: Change this text string: 100 List file names containing this text string: To: MAXSIZE

The lines containing the particular text string are displayed; cscope waits for you to specify the lines in which you want the text to be changed.
   Change "100" to "MAXSIZE"
   

File Line 1 init.c 4 char s[100]; 2 init.c 26 for (i = 0; i < 100; i++) 3 find.c 8 if (c < 100) { 4 read.c 12 f = (bb & 0100); 5 err.c 19 p = total/100.0; /* get percentage */

List references to this C symbol: Edit this function or #define: List functions called by this function: List functions calling this function: List lines containing this text string: Change this text string: List file names containing this text string: Select lines to change (press the ? key for help):

Occurrences of 100 in lines 1, 2, and 3 of the list (from lines 4, 26, and 8 of the program) are to be changed to MAXSIZE. The occurrences of 100 in read.c and err.c (lines 4 and 5 of the list) have a different meaning; in these lines, 100 should not be changed. Enter 1, 2, and 3.

The numbers you type are not printed on the screen. Instead, cscope prints a ``>'' (greater than) symbol after each number of the list that you type. For example, after you type 1, a > symbol is printed after the number 1 in the list (and before the line ``init.c 4 char s[100];''), as shown in the following example:

   Change "100" to "MAXSIZE"
   

File Line 1>init.c 4 char s[100]; 2>init.c 26 for (i = 0; i < 100; i++) 3>find.c 8 if (c < 100) { 4 read.c 12 f = (bb & 0100); 5 err.c 19 p = total/100.0; /* get percentage */

List references to this C symbol: Edit this function or #define: List functions called by this function: List functions calling this function: List lines containing this text string: Change this text string: List file names containing this text string: Select lines to change (press the ? key for help):

After selecting lines, type <Ctrl>d to change them. Then cscope displays the lines that have been changed:
   Changed lines:
                
       char s[MAXSIZE];
       for (i = 0; i < MAXSIZE; i++)
           if (c < MAXSIZE) {
   

Type any character to continue:

When you type a character in response to this prompt, cscope will pause and redraw the screen before allowing you to continue with the session.

The next step is to add the #define for the new symbol MAXSIZE. Escape to the shell by typing an exclamation mark ``!''. The shell prompt will appear at the bottom of the screen. Then enter the editor and add the #define. To resume the cscope session, quit the editor and type <Ctrl>d to exit the shell.


Next topic: Adding an argument to a function
Previous topic: Examples of using cscope

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003