Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
359 | serge | 1 | /**************************************************************************** |
2 | * |
||
3 | * Open Watcom Project |
||
4 | * |
||
5 | * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. |
||
6 | * |
||
7 | * ======================================================================== |
||
8 | * |
||
9 | * This file contains Original Code and/or Modifications of Original |
||
10 | * Code as defined in and that are subject to the Sybase Open Watcom |
||
11 | * Public License version 1.0 (the 'License'). You may not use this file |
||
12 | * except in compliance with the License. BY USING THIS FILE YOU AGREE TO |
||
13 | * ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is |
||
14 | * provided with the Original Code and Modifications, and is also |
||
15 | * available at www.sybase.com/developer/opensource. |
||
16 | * |
||
17 | * The Original Code and all software distributed under the License are |
||
18 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
||
19 | * EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM |
||
20 | * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF |
||
21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR |
||
22 | * NON-INFRINGEMENT. Please see the License for the specific language |
||
23 | * governing rights and limitations under the License. |
||
24 | * |
||
25 | * ======================================================================== |
||
26 | * |
||
27 | * Description: Implementation of strchr() and wcschr(). |
||
28 | * |
||
29 | ****************************************************************************/ |
||
30 | |||
31 | |||
32 | #include "variety.h" |
||
33 | #include "widechar.h" |
||
34 | #include |
||
35 | #include |
||
36 | #include "riscstr.h" |
||
37 | |||
38 | #if defined(M_I86) && !defined(__WIDECHAR__) |
||
39 | |||
40 | extern char * _scan1(); |
||
41 | |||
42 | /* use scan1 to find the char we are looking for */ |
||
43 | |||
44 | #if defined(__SMALL_DATA__) |
||
45 | #pragma aux _scan1 = 0xad /* L1:lodsw */\ |
||
46 | 0x38 0xd0 /* cmp al,dl */\ |
||
47 | 0x74 0x20 /* je L3 */\ |
||
48 | 0x84 0xc0 /* test al,al*/\ |
||
49 | 0x74 0x19 /* je L2 */\ |
||
50 | 0x38 0xd4 /* cmp ah,dl */\ |
||
51 | 0x74 0x19 /* je L4 */\ |
||
52 | 0x84 0xe4 /* test ah,ah*/\ |
||
53 | 0x74 0x11 /* je L2 */\ |
||
54 | 0xad /* lodsw */\ |
||
55 | 0x38 0xd0 /* cmp al,dl */\ |
||
56 | 0x74 0x0f /* je L3 */\ |
||
57 | 0x84 0xc0 /* test al,al*/\ |
||
58 | 0x74 0x08 /* je L2 */\ |
||
59 | 0x38 0xd4 /* cmp ah,dl */\ |
||
60 | 0x74 0x08 /* je L4 */\ |
||
61 | 0x84 0xe4 /* test ah,ah*/\ |
||
62 | 0x75 0xde /* jne L1 */\ |
||
63 | 0x31 0xf6 /* L2:xor si,si */\ |
||
64 | 0xa9 /* test ax,... */\ |
||
65 | 0x4e /* L3:dec si */\ |
||
66 | 0x4e /* L4:dec si */\ |
||
67 | parm caller [si] [dl]\ |
||
68 | value [si]\ |
||
69 | modify [ax si]; |
||
70 | #else |
||
71 | #pragma aux _scan1 = \ |
||
72 | 0x1e /* push ds */ \ |
||
73 | 0x8e 0xd9 /* mov ds,cx */ \ |
||
74 | 0x8c 0xda /* mov dx,ds */\ |
||
75 | 0xad /* L1:lodsw */\ |
||
76 | 0x38 0xd8 /* cmp al,bl */\ |
||
77 | 0x74 0x22 /* je L3 */\ |
||
78 | 0x84 0xc0 /* test al,al*/\ |
||
79 | 0x74 0x19 /* je L2 */\ |
||
80 | 0x38 0xdc /* cmp ah,bl */\ |
||
81 | 0x74 0x1b /* je L4 */\ |
||
82 | 0x84 0xe4 /* test ah,ah*/\ |
||
83 | 0x74 0x11 /* je L2 */\ |
||
84 | 0xad /* lodsw */\ |
||
85 | 0x38 0xd8 /* cmp al,bl */\ |
||
86 | 0x74 0x11 /* je L3 */\ |
||
87 | 0x84 0xc0 /* test al,al*/\ |
||
88 | 0x74 0x08 /* je L2 */\ |
||
89 | 0x38 0xdc /* cmp ah,bl */\ |
||
90 | 0x74 0x0a /* je L4 */\ |
||
91 | 0x84 0xe4 /* test ah,ah*/\ |
||
92 | 0x75 0xde /* jne L1 */\ |
||
93 | 0x31 0xf6 /* L2:xor si,si*/\ |
||
94 | 0x89 0xf2 /* mov dx,si */\ |
||
95 | 0xa9 /* test ax,... */\ |
||
96 | 0x4e /* L3:dec si */\ |
||
97 | 0x4e /* L4:dec si */\ |
||
98 | 0x1f /* pop ds */ \ |
||
99 | parm caller [cx si] [bl]\ |
||
100 | value [dx si]\ |
||
101 | modify [ax dx si]; |
||
102 | #endif |
||
103 | #endif |
||
104 | |||
105 | |||
106 | /* locate the first occurrence of c in the initial n characters of the |
||
107 | string pointed to by s. The terminating null character is considered |
||
108 | to be part of the string. |
||
109 | If the character c is not found, NULL is returned. |
||
110 | */ |
||
111 | #undef strchr |
||
112 | |||
113 | |||
114 | #if defined(__RISCSTR__) && defined(__WIDECHAR__) |
||
115 | _WCRTLINK CHAR_TYPE *__simple_wcschr( const CHAR_TYPE *s, INTCHAR_TYPE c ) |
||
116 | #else |
||
117 | _WCRTLINK CHAR_TYPE *__F_NAME(strchr,wcschr)( const CHAR_TYPE *s, INTCHAR_TYPE c ) |
||
118 | #endif |
||
119 | { |
||
120 | CHAR_TYPE cc = c; |
||
121 | do { |
||
122 | if( *s == cc ) return( (CHAR_TYPE *)s ); |
||
123 | } while( *s++ != NULLCHAR ); |
||
124 | return( NULL ); |
||
125 | } |