mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix strncmp, fread and fwrite in jerry-libc.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
parent
630a1e8eba
commit
30277153b9
@ -197,6 +197,12 @@ int
|
||||
strncmp (const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (s1 == NULL)
|
||||
{
|
||||
if (s2 != NULL)
|
||||
|
||||
@ -322,7 +322,7 @@ ftell (FILE * fp) /**< stream pointer */
|
||||
/**
|
||||
* fread
|
||||
*
|
||||
* @return number of bytes read
|
||||
* @return number of elements read
|
||||
*/
|
||||
size_t
|
||||
fread (void *ptr, /**< address of buffer to read to */
|
||||
@ -333,6 +333,11 @@ fread (void *ptr, /**< address of buffer to read to */
|
||||
long int ret;
|
||||
size_t bytes_read = 0;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
ret = syscall_3 (__NR_read,
|
||||
@ -344,13 +349,13 @@ fread (void *ptr, /**< address of buffer to read to */
|
||||
}
|
||||
while (bytes_read != size * nmemb && ret != 0);
|
||||
|
||||
return bytes_read;
|
||||
return bytes_read / size;
|
||||
} /* fread */
|
||||
|
||||
/**
|
||||
* fwrite
|
||||
*
|
||||
* @return number of bytes written
|
||||
* @return number of elements written
|
||||
*/
|
||||
size_t
|
||||
fwrite (const void *ptr, /**< data to write */
|
||||
@ -360,6 +365,11 @@ fwrite (const void *ptr, /**< data to write */
|
||||
{
|
||||
size_t bytes_written = 0;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
long int ret = syscall_3 (__NR_write,
|
||||
@ -371,7 +381,7 @@ fwrite (const void *ptr, /**< data to write */
|
||||
}
|
||||
while (bytes_written != size * nmemb);
|
||||
|
||||
return bytes_written;
|
||||
return bytes_written / size;
|
||||
} /* fwrite */
|
||||
|
||||
// FIXME
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user