Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.8 KiB

  1. /*
  2. ** ULcase Z extension
  3. **
  4. ** History:
  5. ** 30-Mar-1988 Broken out of "myext"
  6. ** 12-Sep-1988 mz Made WhenLoaded match declaration
  7. */
  8. #include <ctype.h>
  9. #include "zext.h"
  10. #ifndef TRUE
  11. #define TRUE -1
  12. #define FALSE 0
  13. #endif
  14. #ifndef NULL
  15. #define NULL ((char *) 0)
  16. #endif
  17. flagType pascal ulcase (ARG *, int, int, int);
  18. /*************************************************************************
  19. **
  20. ** ucase
  21. ** convert arg to upper case.
  22. */
  23. flagType pascal EXTERNAL
  24. ucase (
  25. CMDDATA argData,
  26. ARG far *pArg,
  27. flagType fMeta
  28. )
  29. {
  30. (void)argData;
  31. (void)fMeta;
  32. return ulcase (pArg, 'a', 'z', 'A'-'a');
  33. }
  34. /*************************************************************************
  35. **
  36. ** lcase
  37. ** convert arg to lower case.
  38. */
  39. flagType pascal EXTERNAL
  40. lcase (
  41. CMDDATA argData,
  42. ARG far *pArg,
  43. flagType fMeta
  44. )
  45. {
  46. (void)argData;
  47. (void)fMeta;
  48. return ulcase (pArg, 'A', 'Z', 'a'-'A');
  49. }
  50. /*
  51. ** ulcase
  52. ** convert arg case.
  53. */
  54. flagType pascal ulcase (pArg, cLow, cHigh, cAdj)
  55. ARG *pArg; /* argument data */
  56. int cLow; /* low char of range to check for */
  57. int cHigh; /* high char of range to check for */
  58. int cAdj; /* adjustment to make */
  59. {
  60. PFILE pFile;
  61. COL xStart;
  62. LINE yStart;
  63. COL xEnd;
  64. LINE yEnd;
  65. int i;
  66. COL xT;
  67. char buf[BUFLEN];
  68. pFile = FileNameToHandle ("", "");
  69. switch (pArg->argType) {
  70. case NOARG: /* case switch entire line */
  71. xStart = 0;
  72. xEnd = 32765;
  73. yStart = yEnd = pArg->arg.noarg.y;
  74. break;
  75. case NULLARG: /* case switch to EOL */
  76. xStart = pArg->arg.nullarg.x;
  77. xEnd = 32765;
  78. yStart = yEnd = pArg->arg.nullarg.y;
  79. break;
  80. case LINEARG: /* case switch line range */
  81. xStart = 0;
  82. xEnd = 32765;
  83. yStart = pArg->arg.linearg.yStart;
  84. yEnd = pArg->arg.linearg.yEnd;
  85. break;
  86. case BOXARG: /* case switch box */
  87. xStart = pArg->arg.boxarg.xLeft;
  88. xEnd = pArg->arg.boxarg.xRight;
  89. yStart = pArg->arg.boxarg.yTop;
  90. yEnd = pArg->arg.boxarg.yBottom;
  91. break;
  92. }
  93. while (yStart <= yEnd) {
  94. i = GetLine (yStart, buf, pFile);
  95. xT = xStart; /* start at begin of box*/
  96. while ((xT <= i) && (xT <= xEnd)) { /* while in box */
  97. if ((int)buf[xT] >= cLow && (int)buf[xT] <= cHigh)
  98. buf[xT] += (char)cAdj;
  99. xT++;
  100. }
  101. PutLine (yStart++, buf, pFile);
  102. }
  103. return TRUE;
  104. }
  105. /*
  106. ** WhenLoaded
  107. ** Executed when these extensions get loaded.
  108. */
  109. void ulcaseWhenLoaded () {
  110. return;
  111. }