|
|
1.1 ! root 1: /************************************************************************* ! 2: * This program is copyright (C) 1985, 1986 by Jonathan Payne. It is * ! 3: * provided to you without charge for use only on a licensed Unix * ! 4: * system. You may copy JOVE provided that this notice is included with * ! 5: * the copy. You may not sell copies of this program or versions * ! 6: * modified for use on microcomputer systems, unless the copies are * ! 7: * included with a Unix system distribution and the source is provided. * ! 8: *************************************************************************/ ! 9: ! 10: #include "jove.h" ! 11: #include "ctype.h" ! 12: ! 13: CapChar() ! 14: { ! 15: register int num, ! 16: restore = 0; ! 17: Bufpos b; ! 18: ! 19: DOTsave(&b); ! 20: ! 21: if (exp < 0) { ! 22: restore++; ! 23: exp = -exp; ! 24: num = exp; ! 25: BackChar(); /* Cap previous EXP chars */ ! 26: } else ! 27: num = exp; ! 28: ! 29: exp = 1; /* So all the commands are done once */ ! 30: ! 31: while (num--) { ! 32: if (upper(&linebuf[curchar])) { ! 33: modify(); ! 34: makedirty(curline); ! 35: } ! 36: if (eolp()) { ! 37: if (curline->l_next == 0) ! 38: break; ! 39: SetLine(curline->l_next); ! 40: } ! 41: else ! 42: curchar++; ! 43: } ! 44: if (restore) ! 45: SetDot(&b); ! 46: } ! 47: ! 48: CapWord() ! 49: { ! 50: register int num, ! 51: restore = 0; ! 52: Bufpos b; ! 53: ! 54: DOTsave(&b); ! 55: ! 56: if (exp < 0) { ! 57: restore++; ! 58: exp = -exp; ! 59: num = exp; ! 60: BackWord(); /* Cap previous EXP words */ ! 61: } else ! 62: num = exp; ! 63: ! 64: exp = 1; /* So all the commands are done once */ ! 65: ! 66: while (num--) { ! 67: to_word(1); /* Go to the beginning of the next word. */ ! 68: if (eobp()) ! 69: break; ! 70: if (upper(&linebuf[curchar])) { ! 71: modify(); ! 72: makedirty(curline); ! 73: } ! 74: curchar++; ! 75: while (!eolp() && isword(linebuf[curchar])) { ! 76: if (lower(&linebuf[curchar])) { ! 77: modify(); ! 78: makedirty(curline); ! 79: } ! 80: curchar++; ! 81: } ! 82: } ! 83: if (restore) ! 84: SetDot(&b); ! 85: } ! 86: ! 87: case_word(up) ! 88: { ! 89: Bufpos before; ! 90: ! 91: DOTsave(&before); ! 92: ForWord(); /* This'll go backward if negative argument. */ ! 93: case_reg(before.p_line, before.p_char, curline, curchar, up); ! 94: } ! 95: ! 96: static ! 97: upper(c) ! 98: register char *c; ! 99: { ! 100: if (islower(*c)) { ! 101: *c -= ' '; ! 102: return 1; ! 103: } ! 104: return 0; ! 105: } ! 106: ! 107: static ! 108: lower(c) ! 109: register char *c; ! 110: { ! 111: if (isupper(*c)) { ! 112: *c += ' '; ! 113: return 1; ! 114: } ! 115: return 0; ! 116: } ! 117: ! 118: case_reg(line1, char1, line2, char2, up) ! 119: Line *line1, ! 120: *line2; ! 121: int char1; ! 122: { ! 123: (void) fixorder(&line1, &char1, &line2, &char2); ! 124: DotTo(line1, char1); ! 125: ! 126: exp = 1; ! 127: for (;;) { ! 128: if (curline == line2 && curchar == char2) ! 129: break; ! 130: if (!eolp()) ! 131: if ((up) ? upper(&linebuf[curchar]) : lower(&linebuf[curchar])) { ! 132: makedirty(curline); ! 133: modify(); ! 134: } ! 135: ForChar(); ! 136: } ! 137: } ! 138: ! 139: CasRegLower() ! 140: { ! 141: CaseReg(0); ! 142: } ! 143: ! 144: CasRegUpper() ! 145: { ! 146: CaseReg(1); ! 147: } ! 148: ! 149: CaseReg(up) ! 150: { ! 151: register Mark *mp = CurMark(); ! 152: Bufpos savedot; ! 153: ! 154: DOTsave(&savedot); ! 155: case_reg(curline, curchar, mp->m_line, mp->m_char, up); ! 156: SetDot(&savedot); ! 157: } ! 158: ! 159: UppWord() ! 160: { ! 161: case_word(1); ! 162: } ! 163: ! 164: LowWord() ! 165: { ! 166: case_word(0); ! 167: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.