假设您要将常量 100 更改为预处理程序符号 MAXSIZE。选择第六个菜单项 Change this text string,然后输入 \100。必须使用反斜杠将 1 转义,原因是它对 cscope 具有特殊意义(菜单上的第 1 项)。现在按回车键。cscope 将提示您输入新文本字符串。键入 MAXSIZE。
cscope 函数: 更改文本字符串:
cscope Press the ? key for help Find this C symbol: Find this global definition: Find functions called by this function: Find functions calling this function: Find this text string: Change this text string: \100 Find this egrep pattern: Find this file: Find files #including this file: To: MAXSIZE |
cscope 显示包含指定文本字符串的行,并等待您选择要更改其中文本的行。
cscope 函数: 提示要更改的行:
cscope Press the ? key for help Find this C symbol: Find this global definition: Find functions called by this function: Find functions calling this function: Find this text string: Change this text string: \100 Find this egrep pattern: Find this file: Find files #including this file: To: MAXSIZE |
您知道列表中第 1、2 和 3 行(列出的源文件的第 4、26 和 8 行)中的常量 100 应更改为 MAXSIZE。您还知道 read.c 中的 0100 和 err.c 中的 100.0(列表中的第 4 行和第 5 行)不应更改。使用以下单键命令选择要更改的行:
表 8–3 用于选择要更改的行的命令|
1-9 |
标记要更改的行或去标记。 |
|
* |
标记要更改的所有显示行或去标记。 |
|
空格 |
显示下一组行。 |
|
+ |
显示下一组行。 |
|
– |
显示上一组行。 |
|
a |
标记要更改的所有行。 |
|
^d |
更改标记的行并退出。 |
|
Esc |
退出而不更改标记的行。 |
在本例中,输入 1、2 和 3。您键入的数字不会输出在屏幕上。相反,cscope 通过在列表中您要更改的每个列表项的行号后面输出 >(大于)符号来标记这些项。
cscope 函数: 标记要更改的行:
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 */
Find this C symbol:
Find this global definition:
Find functions called by this function:
Find functions calling this function:
Find this text string:
Change this text string:
Find this egrep pattern:
Find this file:
Find files #including this file:
Select lines to change (press the ? key for help):
|
现在键入 ^d 更改所选行。cscope 将显示已更改的行并提示您继续执行。
cscope 函数: 显示已更改的文本行:
Changed lines:
char s[MAXSIZE];
for (i = 0; i < MAXSIZE; i++)
if (c < MAXSIZE) {
Press the RETURN key to continue:
|
当您响应此提示而按回车键时,cscope 将刷新屏幕,从而使其恢复到您选择要更改的行之前的状态。
下一步是为新符号 MAXSIZE 添加 #define。由于将要显示 #define 的头文件不在其行得到显示的文件之列,因此您必须通过键入 ! 退回到 shell。shell 提示符出现在屏幕底部。然后进入编辑器,并添加 #define。
cscope 函数: 退出到 Shell:
Text string: 100
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 */
Find this C symbol:
Find this global definition:
Find functions called by this function:
Find functions calling this function:
Find this text string:
Change this text string:
Find this egrep pattern:
Find this file:
Find files #including this file:
$ vi defs.h
|
要恢复 cscope 会话,请退出编辑器并键入 ^d 以退出 shell。