summaryrefslogtreecommitdiff
path: root/v4.0/src/INC/STRING.C
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/INC/STRING.C')
-rw-r--r--v4.0/src/INC/STRING.C94
1 files changed, 94 insertions, 0 deletions
diff --git a/v4.0/src/INC/STRING.C b/v4.0/src/INC/STRING.C
new file mode 100644
index 0000000..3a2d74a
--- /dev/null
+++ b/v4.0/src/INC/STRING.C
@@ -0,0 +1,94 @@
1#include "types.h"
2#include "internat.h"
3#include <dos.h>
4
5/* #define KANJI TRUE */
6
7char haveinttab = FALSE;
8
9struct InterTbl Currtab;
10
11int toupper(c)
12int c;
13{
14 union REGS regs ;
15
16 if(!haveinttab) {
17 regs.x.ax = 0x3800 ;
18 regs.x.dx = (unsigned) &Currtab ;
19 intdos (&regs, &regs) ; /* INIT the table */
20
21 haveinttab = TRUE;
22 }
23
24 return(IToupper(c,Currtab.casecall));
25
26}
27
28char *strupr(string)
29char *string;
30{
31 register char *p1;
32
33 p1 = string;
34 while (*p1 != NULL) {
35 /*
36 * A note about the following " & 0xFF" stuff. This is
37 * to prevent the damn C compiler from converting bytes
38 * to words with the CBW instruction which is NOT correct
39 * for routines like toupper
40 */
41#ifdef KANJI
42 if(testkanj(*p1 & 0xFF))
43 p1 += 2 ;
44 else
45 *p1++ = toupper(*p1 & 0xFF);
46#else
47 *p1++ = toupper(*p1 & 0xFF);
48#endif
49 }
50 return(string);
51}
52
53char *strpbrk(string1,string2)
54char *string1;
55char *string2;
56{
57 register char *p1;
58
59 while (*string1 != NULL) {
60 /*
61 * A note about the following " & 0xFF" stuff. This is
62 * to prevent the damn C compiler from converting bytes
63 * to words with the CBW instruction which is NOT correct
64 * for routines like toupper
65 */
66#ifdef KANJI
67 if(testkanj(*string1 & 0xFF))
68 string1 += 2 ;
69 else {
70#endif
71 p1 = string2;
72 while (*p1 != NULL) {
73 if(*p1++ == *string1)
74 return(string1);
75 }
76 string1++;
77#ifdef KANJI
78 }
79#endif
80
81 }
82 return(NULL); /* no matches found */
83}
84
85#ifdef KANJI
86testkanj(c)
87unsigned char c;
88{
89 if((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xFC))
90 return(TRUE);
91 else
92 return(FALSE);
93}
94#endif