Ignore:
Timestamp:
Feb 12, 2019, 1:15:47 PM (5 years ago)
Author:
alain
Message:

1) Fix a bug in KSH : after the "load" command,

the [ksh] prompt is now printed after completion
of the loaded application.

2) Fix a bug in vmm_handle_cow() : the copy-on-write

use now a hal_remote_memcpy() to replicate the page content.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/mini-libc/string.c

    r473 r619  
    8080
    8181
    82 ///////////////////////////
    83 char * strcpy (char * dest,
     82//////////////////////////
     83char * strcpy (char * dst,
    8484               char * src )
    8585{
    86         char *src_ptr = src;
    87         char *dst_ptr = dest;
    88 
    89         while(*src_ptr) *(dst_ptr++) = *(src_ptr++);
    90 
    91         *dst_ptr = 0;
    92         return dest;
    93 }
    94 
    95 ////////////////////////////////////
    96 char * strncpy( char         * dest,
     86        while( *src )
     87    {
     88        *(dst) = *(src);
     89        dst++;
     90        src++;
     91    }
     92       
     93    // set NUL terminating character
     94        *dst = 0;
     95
     96        return dst;
     97}
     98
     99///////////////////////////////////
     100char * strncpy( char         * dst,
    97101                char         * src,
    98                 unsigned int   n )
     102                unsigned int   count )
    99103{
    100104        unsigned int i;
    101105
    102         for (i = 0; (i < n) && (src[i] != '\0') ; i++) dest[i] = src[i];
    103 
    104         for (; i < n; i++) dest[i] = '\0';
    105 
    106         return dest;
     106    // copy at most count characters
     107        for (i = 0 ; (i < count) && (src[i] != '\0') ; i++) dst[i] = src[i];
     108
     109    // complete with NUL characters
     110        for ( ; i < count ; i++) dst[i] = '\0';
     111
     112        return dst;
    107113}
    108114
Note: See TracChangeset for help on using the changeset viewer.