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_strncat( char _WCFAR *, const char _WCFAR *, size_t );
  39.  
  40. #pragma aux _fast_strncat = \
  41.         0x1e            /* push ds    */\
  42.         0x96            /* xchg si,ax */\
  43.         0x8e 0xd8       /* mov ds,ax  */\
  44.         0x57            /* push di    */\
  45.         0xb9 0xff 0xff  /* mov cx,ffffh */\
  46.         0x31 0xc0       /* xor ax,ax  */\
  47.         0xf2 0xae       /* repne scasb */\
  48.         0x4f            /* dec di     */\
  49.         0x89 0xd1       /* mov cx,dx  */\
  50.         0xac            /* L1: lodsb  */\
  51.         0xaa            /* stosb      */\
  52.         0x84 0xc0       /* test al,al */\
  53.         0xe0 0xfa       /* loopne L1  */\
  54.         0x74 0x03       /* je L2      */\
  55.         0x26 0x88 0x25  /* mov es:[di],ah */\
  56.         0x58            /* L2: pop ax */\
  57.         0x1f            /* pop ds     */\
  58.         parm caller     [es di] [si ax] [dx]\
  59.         value           [es ax] \
  60.         modify exact    [ax cx si di];
  61. #endif
  62.  
  63. /* concatenate t to the end of dst */
  64.  
  65. _WCRTLINK char _WCFAR *_fstrncat( char _WCFAR *dst, const char _WCFAR *t, size_t n )
  66.     {
  67. #ifdef M_I86
  68.         if( n ) {
  69.             return( _fast_strncat( dst, t, n ) );
  70.         }
  71.         return( dst );
  72. #else
  73.         char _WCFAR *s;
  74.  
  75.         s = _fmemchr( dst, '\0', ~0 );
  76.         while( n != 0 ) {
  77.             *s = *t;
  78.             if( *s == '\0' ) break;
  79.             ++s;
  80.             ++t;
  81.             --n;
  82.         }
  83.         *s = '\0';
  84.         return( dst );
  85. #endif
  86.     }
  87.