1 #include <exec/types.h>
7 /* StackSwap is not used (or required) for NG systems (at least not MorphOS), thus dummy */
12 /* Let MorphOS know that this is a native MorphOS ELF and not PowerUP binary */
14 const LONG __READONLY__ __abox__ __USED__
= 1;
18 ;-----------------------------------------------------------------------------
19 ; ULONG divide (ULONG d0, UWORD d1)
20 ;-----------------------------------------------------------------------------
22 ULONG
divide(ULONG d0
, UWORD d1
)
25 /* NOTE: I doubt anything depends on this, but lets simulate 68k divu overflow anyway - Piru */
26 if (q
> 65535UL) return d0
;
27 return ((d0
% d1
) << 16) | q
;
31 ;-----------------------------------------------------------------------------
32 ; void ctodstr(cstring *a0, dstring *a1)
34 ; converts cstring a0 to dstring a1
35 ;-----------------------------------------------------------------------------
37 void ctodstr(const unsigned char *a0
, unsigned char *a1
)
39 unsigned char *lenp
= a1
++;
41 while ((*a1
++ = *a0
++))
46 /* SAS/C compatibility routines - only included if not SAS/C */
49 int stcu_d(char *out
, unsigned int val
)
52 char *p
= &tmp
[sizeof(tmp
)];
57 *--p
= '0' + (val
% 10);
61 for (len
= 0; (*out
++ = *p
++); len
++)
67 * Note: Since the value converted in directory.c is always positive without sign,
68 * I disabled the sign support. - Piru
70 int stcd_i(const char *in
, int *ivalue
)
72 const char *orig_in
= in
;
76 /*if (*in == '-' || *in == '+')
81 if (*in
< '0' || *in
> '9')
83 v
= v
* 10 + (*in
++ - '0');
85 /* *ivalue = (n ? (v == 0 ? -2147483648L : -v) : v);*/
87 return (in
- orig_in
);
90 /* SAS/C function - similar to strcpy but return ptr to terminating \0 */
91 char *stpcpy(char *dst
, const char *src
)
93 while ((*dst
++ = *src
++))
101 ;-----------------------------------------------------------------------------
102 ; void intltoupper(dstr *a0)
104 ; converts dstring a0 to uppercase in international mode
106 ;-----------------------------------------------------------------------------
108 void intltoupper(unsigned char *a0
)
110 unsigned char len
= *a0
++;
126 unsigned char c
= *a0
++;
127 if ((c
>= 0x61 && c
<= 0x7a) ||
128 (c
>= 0xe0 && c
<= 0xf6) ||
129 (c
>= 0xf8 && c
<= 0xfe))
138 ;-----------------------------------------------------------------------------
139 ; bool intlcmp(dstr *a0, dstr *a1)
141 ; compares dstring a with dstring b in international mode.
142 ; a0 must be 'uppercased' as follows:
144 ; 0x00 - 0x60 -> 0x00 - 0x60
145 ; 0x61 - 0x7a -> 0x41 - 0x5a diff 0x20
146 ; 0x7b - 0xdf -> 0x7b - 0xdf
147 ; 0xe0 - 0xf6 -> 0xc0 - 0xd6 diff 0x20
149 ; 0xf8 - 0xfe -> 0xd8 - 0xde diff 0x20
152 ; So if match then (d0 = d1) \/ (d1-d0 = 0x20)
153 ;-----------------------------------------------------------------------------
155 int intlcmp(const unsigned char *a0
, const unsigned char *a1
)
157 unsigned char len
= *a0
++;
159 return 0; /* different size, can't match */
163 unsigned char c
= *a0
++;
164 unsigned char d
= *a1
++;
165 if ((d
- c
) > d
) return 0; /* carry set */
166 if (c
== d
) continue;
167 if (d
- c
!= 0x20) return 0;
179 if (!((c
>= 0x41 && c
<= 0x5a) ||
180 (c
>= 0xc0 && c
<= 0xd6) ||
181 (c
>= 0xd8 && c
<= 0xde)))
191 ;-----------------------------------------------------------------------------
192 ; bool intlcdcmp(cstr *a0, dstr *a1)
194 ; compares cstring a with dstring b in international mode.
195 ; a0 must be 'uppercased' as follows:
197 ; 0x00 - 0x60 -> 0x00 - 0x60
198 ; 0x61 - 0x7a -> 0x41 - 0x5a diff 0x20
199 ; 0x7b - 0xdf -> 0x7b - 0xdf
200 ; 0xe0 - 0xf6 -> 0xc0 - 0xd6 diff 0x20
202 ; 0xf8 - 0xfe -> 0xd8 - 0xde diff 0x20
205 ; So if match then (d0 = d1) \/ (d1-d0 = 0x20)
206 ;-----------------------------------------------------------------------------
208 int intlcdcmp(const unsigned char *a0
, const unsigned char *a1
)
210 unsigned char len
= *a1
++;
212 return *a0
== '\0'; /* zero length string */
216 unsigned char c
= *a0
++;
218 if (c
== '\0') return 0;
220 if ((d
- c
) > d
) return 0; /* carry set */
221 if (c
== d
) continue;
222 if (d
- c
!= 0x20) return 0;
234 if (!((c
>= 0x41 && c
<= 0x5a) ||
235 (c
>= 0xc0 && c
<= 0xd6) ||
236 (c
>= 0xd8 && c
<= 0xde)))