Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  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:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
  28. *               DESCRIBE IT HERE!
  29. *
  30. ****************************************************************************/
  31.  
  32.  
  33. #include "variety.h"
  34. #include <string.h>
  35.  
  36. #ifdef  M_I86
  37.  
  38. extern  char _WCFAR *_fast_strrchr( const char _WCFAR *, char );
  39.  
  40. #pragma aux    _fast_strrchr = \
  41.         0xb9 0xff 0xff  /* mov cx,ffffh */ \
  42.         0x30 0xc0       /* xor al,al */ \
  43.         0xf2 0xae       /* repne scasb */ \
  44.         0xf7 0xd1       /* not cx */ \
  45.         0x4f            /* dec di */ \
  46.         0x88 0xd8       /* mov al,bl */ \
  47.         0xfd            /* std */ \
  48.         0xf2 0xae       /* repne scasb */ \
  49.         0xfc            /* cld */ \
  50.         0x75 0x04       /* jne L1 */ \
  51.         0x89 0xf9       /* mov cx,di */ \
  52.         0x41            /* inc cx */ \
  53.         0xa9            /* hide 2 bytes */ \
  54.         0x8e 0xc1       /* L1: mov es,cx */ \
  55.         parm caller [es di] [bl] \
  56.         value [es cx] \
  57.         modify exact [es cx ax di];
  58. #endif
  59.  
  60. /* Locate the last occurrence of c in the string pointed to by s.
  61.    The terminating null character is considered to be part of the string.
  62.    If the character c is not found, NULL is returned.
  63. */
  64.  
  65. _WCRTLINK char _WCFAR *_fstrrchr( const char _WCFAR *s, int c )
  66.     {
  67. #if defined(M_I86)
  68.         return( _fast_strrchr( s, c ) );
  69. #else
  70.         char _WCFAR *p;
  71.  
  72.         p = NULL;       /* assume c will not be found */
  73.         do {
  74.             if( *s == c ) p = (char _WCFAR *)s;
  75.         } while( *s++ != '\0' );
  76.         return( p );
  77. #endif
  78.     }
  79.