Changeset 619 for trunk/libs/mini-libc


Ignore:
Timestamp:
Feb 12, 2019, 1:15:47 PM (3 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.


Location:
trunk/libs/mini-libc
Files:
2 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
  • trunk/libs/mini-libc/string.h

    r445 r619  
    7070 * @ return 0 if s1 == s2 / return 1 if s1 > s2 / return -1 if s1 < s2
    7171 *******************************************************************************************/
    72 int strncmp ( const char * s1,
    73               const char * s2,
     72int strncmp ( const char     * s1,
     73              const char     * s2,
    7474              unsigned int     n );
    7575
     
    8484
    8585/********************************************************************************************
    86  * This function copies <n> characters from the <sr> buffer to the <dst> buffer.
     86 * This function copies <count> characters from the <src> buffer to the <dst> buffer.
    8787 ********************************************************************************************
    8888 * @ dst   : pointer on destination buffer.
    8989 * @ src   : pointer on source buffer.
    90  * @ n    : number of characters to be copied.
     90 * @ count : number of characters to be copied.
    9191 *******************************************************************************************/
    9292char * strncpy ( char         * dst,
    9393                 char         * src,
    94                  unsigned int   n );
     94                 unsigned int   count );
    9595
    9696/********************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.