diff options
Diffstat (limited to 'v4.0/src/INC/KSTRING.C')
| -rw-r--r-- | v4.0/src/INC/KSTRING.C | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/v4.0/src/INC/KSTRING.C b/v4.0/src/INC/KSTRING.C new file mode 100644 index 0000000..b59f717 --- /dev/null +++ b/v4.0/src/INC/KSTRING.C | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | #include "internat.h" | ||
| 2 | #include <dos.h> | ||
| 3 | #define NULL 0 | ||
| 4 | #define TRUE 0xffff | ||
| 5 | #define FALSE 0 | ||
| 6 | #define KANJI TRUE | ||
| 7 | char haveinttab = FALSE; | ||
| 8 | /* | ||
| 9 | * ECS Support - This module provides support for international >7FH and | ||
| 10 | * TWO-BYTE character sets. The toupper routine uses the DOS MAP_CASE call. | ||
| 11 | * In addition, STRING.C contains a default_tab containing a default lead | ||
| 12 | * byte table for two byte character sets. If single byte operation is | ||
| 13 | * desired, modify this table as follows: ="\000". If this utility | ||
| 14 | * is run on a DOS with Function 63H support, the default table will | ||
| 15 | * be replaced by the table in the DOS. The lbtbl_ptr is the far ptr to | ||
| 16 | * which ever table is in use. | ||
| 17 | */ | ||
| 18 | long lbtbl_ptr; | ||
| 19 | char *default_tab="\201\237\340\374\000\000"; | ||
| 20 | char have_lbtbl = FALSE; | ||
| 21 | |||
| 22 | struct InterTbl Currtab; | ||
| 23 | |||
| 24 | int toupper(c) | ||
| 25 | int c; | ||
| 26 | { | ||
| 27 | union REGS regs ; | ||
| 28 | |||
| 29 | if(!haveinttab) { | ||
| 30 | regs.x.ax = 0x3800 ; | ||
| 31 | regs.x.dx = (unsigned) &Currtab ; | ||
| 32 | intdos (®s, ®s) ; /* INIT the table */ | ||
| 33 | |||
| 34 | haveinttab = TRUE; | ||
| 35 | } | ||
| 36 | |||
| 37 | return(IToupper(c,Currtab.casecall)); | ||
| 38 | |||
| 39 | } | ||
| 40 | |||
| 41 | char *strupr(string) | ||
| 42 | char *string; | ||
| 43 | { | ||
| 44 | register char *p1; | ||
| 45 | |||
| 46 | p1 = string; | ||
| 47 | while (*p1 != NULL) { | ||
| 48 | /* | ||
| 49 | * A note about the following " & 0xFF" stuff. This is | ||
| 50 | * to prevent the damn C compiler from converting bytes | ||
| 51 | * to words with the CBW instruction which is NOT correct | ||
| 52 | * for routines like toupper | ||
| 53 | */ | ||
| 54 | #ifdef KANJI | ||
| 55 | if(testkanj(*p1 & 0xFF)) | ||
| 56 | p1 += 2 ; | ||
| 57 | else | ||
| 58 | *p1++ = toupper(*p1 & 0xFF); | ||
| 59 | #else | ||
| 60 | *p1++ = toupper(*p1 & 0xFF); | ||
| 61 | #endif | ||
| 62 | } | ||
| 63 | return(string); | ||
| 64 | } | ||
| 65 | |||
| 66 | char *strpbrk(string1,string2) | ||
| 67 | char *string1; | ||
| 68 | char *string2; | ||
| 69 | { | ||
| 70 | register char *p1; | ||
| 71 | |||
| 72 | while (*string1 != NULL) { | ||
| 73 | /* | ||
| 74 | * A note about the following " & 0xFF" stuff. This is | ||
| 75 | * to prevent the damn C compiler from converting bytes | ||
| 76 | * to words with the CBW instruction which is NOT correct | ||
| 77 | * for routines like toupper | ||
| 78 | */ | ||
| 79 | #ifdef KANJI | ||
| 80 | if(testkanj(*string1 & 0xFF)) | ||
| 81 | string1 += 2 ; | ||
| 82 | else { | ||
| 83 | #endif | ||
| 84 | p1 = string2; | ||
| 85 | while (*p1 != NULL) { | ||
| 86 | if(*p1++ == *string1) | ||
| 87 | return(string1); | ||
| 88 | } | ||
| 89 | string1++; | ||
| 90 | #ifdef KANJI | ||
| 91 | } | ||
| 92 | #endif | ||
| 93 | |||
| 94 | } | ||
| 95 | return(NULL); /* no matches found */ | ||
| 96 | } | ||
| 97 | |||
| 98 | #ifdef KANJI | ||
| 99 | testkanj(c) | ||
| 100 | unsigned char c; | ||
| 101 | { | ||
| 102 | long *p1; | ||
| 103 | union REGS regs ; | ||
| 104 | int i; | ||
| 105 | |||
| 106 | p1 = (long *)&lbtbl_ptr ; | ||
| 107 | if (!have_lbtbl ) { | ||
| 108 | (char far *)lbtbl_ptr = (char far *)default_tab ; /* Load offset in pointer */ | ||
| 109 | get_lbtbl( p1 ); | ||
| 110 | have_lbtbl=TRUE; | ||
| 111 | } | ||
| 112 | |||
| 113 | if ( test_ecs( c, lbtbl_ptr )) | ||
| 114 | return(TRUE); | ||
| 115 | else | ||
| 116 | return(FALSE); | ||
| 117 | } | ||
| 118 | #endif | ||