1: /***************************************************************************
2: * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne. JOVE *
3: * is provided to you without charge, and with no warranty. You may give *
4: * away copies of JOVE, including sources, provided that this notice is *
5: * included in all the files. *
6: ***************************************************************************/
7:
8: #include "jove.h"
9: #include "ctype.h"
10:
11: #ifdef MAC
12: # undef private
13: # define private
14: #endif
15:
16: #ifdef LINT_ARGS
17: private int
18: #if !(defined(IBMPC) || defined(MAC))
19: lower(char *),
20: #endif
21: upper(char *);
22: #else
23: private int
24: #if !(defined(IBMPC) || defined(MAC))
25: lower(),
26: #endif
27: upper();
28: #endif /* LINT_ARGS */
29:
30: #ifdef MAC
31: # undef private
32: # define private static
33: #endif
34:
35: void
36: CapChar()
37: {
38: register int num,
39: restore = NO;
40: Bufpos b;
41:
42: DOTsave(&b);
43:
44: num = arg_value();
45: if (num < 0) {
46: restore = YES;
47: num = -num;
48: b_char(num); /* Cap previous EXP chars */
49: }
50: while (num--) {
51: if (upper(&linebuf[curchar])) {
52: modify();
53: makedirty(curline);
54: }
55: if (eolp()) {
56: if (curline->l_next == 0)
57: break;
58: SetLine(curline->l_next);
59: } else
60: curchar += 1;
61: }
62: if (restore)
63: SetDot(&b);
64: }
65:
66: void
67: CapWord()
68: {
69: register int num,
70: restore = NO;
71: Bufpos b;
72:
73: DOTsave(&b);
74: num = arg_value();
75: if (num < 0) {
76: restore = YES;
77: num = -num;
78: b_word(num); /* Cap previous EXP words */
79: }
80: while (num--) {
81: to_word(1); /* Go to the beginning of the next word. */
82: if (eobp())
83: break;
84: if (upper(&linebuf[curchar])) {
85: modify();
86: makedirty(curline);
87: }
88: curchar += 1;
89: while (!eolp() && isword(linebuf[curchar])) {
90: if (lower(&linebuf[curchar])) {
91: modify();
92: makedirty(curline);
93: }
94: curchar += 1;
95: }
96: }
97: if (restore)
98: SetDot(&b);
99: }
100:
101: void
102: case_word(up)
103: {
104: Bufpos before;
105:
106: DOTsave(&before);
107: ForWord(); /* this'll go backward if negative argument */
108: case_reg(before.p_line, before.p_char, curline, curchar, up);
109: }
110:
111: private int
112: upper(c)
113: register char *c;
114: {
115: if (islower(*c)) {
116: #ifndef ASCII /* check for IBM extended character set */
117: if (*c <= 127)
118: #endif /* ASCII */
119: *c -= ' ';
120: #ifdef IBMPC /* ... and change Umlaute */
121: else
122: switch (*c) {
123: case 129: *c = 154; break; /* ue */
124: case 132: *c = 142; break; /* ae */
125: case 148: *c = 153; break; /* oe */
126: }
127: #endif /* IBMPC */
128: #ifdef MAC
129: else *c = CaseEquiv[*c];
130: #endif
131: return 1;
132: }
133: return 0;
134: }
135:
136: #if !(defined(IBMPC) || defined(MAC))
137: private
138: #endif
139: int
140: lower(c)
141: char *c;
142: {
143: if (isupper(*c)) {
144: #ifndef ASCII
145: if (*c <= 127)
146: #endif /* ASCII */
147: *c += ' ';
148: #ifdef IBMPC
149: else
150: switch (*c) {
151: case 142: *c = 132; break; /* Ae */
152: case 153: *c = 148; break; /* Oe */
153: case 154: *c = 129; break; /* Ue */
154: }
155: #endif /* IBMPC */
156: #ifdef MAC
157: else {
158: int n;
159:
160: for(n = 128; n < 256; n++) {
161: if((CaseEquiv[n] == *c) && islower(n)) {
162: *c = n;
163: break;
164: }
165: }
166: if(n > 255) return(0);
167: }
168: #endif /* MAC */
169: return 1;
170: }
171: return 0;
172: }
173:
174: void
175: case_reg(line1, char1, line2, char2, up)
176: Line *line1,
177: *line2;
178: int char1;
179: {
180: (void) fixorder(&line1, &char1, &line2, &char2);
181: DotTo(line1, char1);
182:
183: for (;;) {
184: if (curline == line2 && curchar == char2)
185: break;
186: if (!eolp())
187: if ((up) ? upper(&linebuf[curchar]) : lower(&linebuf[curchar])) {
188: makedirty(curline);
189: modify();
190: }
191: f_char(1);
192: }
193: }
194:
195: void
196: CasRegLower()
197: {
198: CaseReg(0);
199: }
200:
201: void
202: CasRegUpper()
203: {
204: CaseReg(1);
205: }
206:
207: void
208: CaseReg(up)
209: {
210: register Mark *mp = CurMark();
211: Bufpos savedot;
212:
213: DOTsave(&savedot);
214: case_reg(curline, curchar, mp->m_line, mp->m_char, up);
215: SetDot(&savedot);
216: }
217:
218: void
219: UppWord()
220: {
221: case_word(1);
222: }
223:
224: void
225: LowWord()
226: {
227: case_word(0);
228: }
Defined functions
Defined variables
Defined macros