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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Post-process adb scripts to move increment and decrement around.
31 * The reason is that at the start of each +/ line, adb prints out
32 * the current location. If the line then increments or decrements
33 * dot before printing the user may be confused. So we move the
34 * increment or decrement to the preceeding line.
42 #define BUFSIZE 1024 /* gross enough to never be exceeded (we hope) */
44 char buf1
[BUFSIZE
], buf2
[BUFSIZE
];
46 static char *scanpastnum(char *);
47 static int goodstart(char *);
52 char *cur
, *last
, *cp1
, *cp2
, *ep
, *t
;
58 while (gets(cur
) != NULL
) {
59 if (goodstart(cur
) && goodstart(last
)) {
61 * Scan cur for initial increment.
62 * Ignore quoted strings, tabbing, adb newlines.
67 /* scan past quoted string */
68 while (*++cp1
&& *cp1
!= '"')
73 if (*cp1
>= '0' && *cp1
<= '9') {
74 cp2
= scanpastnum(cp1
);
78 if (*cp2
== 't' || *cp2
== 'n' ||
80 /* ok to skip over this one */
88 * Cp1 now points at the first non-quoted string and
89 * non adb tab specification.
90 * Now determine if it's an increment or decrement.
92 cp2
= scanpastnum(cp1
);
93 if (*cp2
== '+' || *cp2
== '-') {
95 * This is what we were hoping to find.
96 * Move increment or decrement into last.
99 ep
= last
+ strlen(last
);
101 strncpy(ep
, cp1
, len
);
104 * Remove it from cur.
110 * Prepare for next iteration.
122 * Cp points at a digit.
123 * Return pointer to next char that isn't a digit.
126 scanpastnum(char *cp1
)
130 for (cp2
= cp1
; isdigit(*cp2
); cp2
++)
136 * Check whether a line has a good starting string.
137 * We need ./ or +/ at the beginning to even think
138 * of doing this motion stuff.
143 if (*cp
== '.' || *cp
== '+') {