4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1999 by Sun Microsystems, Inc.
28 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI"
34 * cscope - interactive C symbol cross-reference
36 * file editing functions
39 #include <curses.h> /* KEY_BREAK and refresh */
45 /* edit this displayed reference */
50 char file
[PATHLEN
+ 1]; /* file name */
51 char linenum
[NUMLEN
+ 1]; /* line number */
53 /* verify that there is a references found file */
54 if (refsfound
== NULL
) {
57 /* get the selected line */
58 seekline(i
+ topline
);
60 /* get the file name and line number */
61 if (fscanf(refsfound
, "%s%*s%s", file
, linenum
) == 2) {
62 edit(file
, linenum
); /* edit it */
64 seekline(topline
); /* restore the line pointer */
67 /* edit all references */
72 char file
[PATHLEN
+ 1]; /* file name */
73 char linenum
[NUMLEN
+ 1]; /* line number */
76 /* verify that there is a references found file */
77 if (refsfound
== NULL
) {
80 /* get the first line */
83 /* get each file name and line number */
84 while (fscanf(refsfound
, "%s%*s%s%*[^\n]", file
, linenum
) == 2) {
85 edit(file
, linenum
); /* edit it */
86 if (editallprompt
== YES
) {
87 putmsg("Type ^D to stop editing all lines, "
88 "or any other character to continue: ");
89 if ((c
= mygetch()) == EOF
|| c
== ctrl('D') ||
90 c
== ctrl('Z') || c
== KEY_BREAK
) {
91 /* needed for interrupt on first time */
100 /* call the editor */
103 edit(char *file
, char *linenum
)
105 char msg
[MSGLEN
+ 1]; /* message */
106 char plusnum
[NUMLEN
+ 2]; /* line number option */
109 (void) sprintf(msg
, "%s +%s %s", editor
, linenum
, file
);
111 (void) sprintf(plusnum
, "+%s", linenum
);
113 /* if this is the more or page commands */
114 if (strcmp(s
= basename(editor
), "more") == 0 ||
115 strcmp(s
, "page") == 0) {
117 * get it to pause after displaying a file smaller
118 * than the screen length
120 (void) execute(editor
, editor
, plusnum
, file
, "/dev/null",
123 (void) execute(editor
, editor
, plusnum
, file
, (char *)NULL
);