memmove, fprintf.

This commit is contained in:
Ruben Ayrapetyan 2014-07-10 17:55:21 +04:00
parent 76e579d4e1
commit 4cb5fb646e
4 changed files with 42 additions and 10 deletions

View File

@ -134,7 +134,7 @@ get_char (size_t i)
if (token_start == buffer_start)
fatal (ERR_BUFFER_SIZE);
/* Move parsed token and tail of buffer to head. */
memmove (buffer_start, token_start, tail_size + token_size);
__memmove (buffer_start, token_start, tail_size + token_size);
/* Adjust pointers. */
token_start = buffer_start;
buffer = buffer_start + token_size;
@ -148,7 +148,7 @@ get_char (size_t i)
}
else
{
memmove (buffer_start, buffer, tail_size);
__memmove (buffer_start, buffer, tail_size);
buffer = buffer_start;
error = fread (buffer + tail_size, 1, BUFFER_SIZE - tail_size, file);
if (error == 0)
@ -690,7 +690,7 @@ lexer_next_token (void)
return (token) { .type = TOK_NEWLINE, .data.none = NULL };
else
return
#ifdef __HOST
#ifdef JERRY_NDEBUG
lexer_next_token_private ();
#else
lexer_next_token ();
@ -785,7 +785,7 @@ lexer_next_token (void)
// if (tok.type == TOK_CLOSE_BRACE)
{
// if (i == 300)
fprintf (lexer_debug_log, "lexer_next_token(%d): type=0x%x, data=%p\n", i, tok.type, tok.data.none);
__fprintf (lexer_debug_log, "lexer_next_token(%d): type=0x%x, data=%p\n", i, tok.type, tok.data.none);
i++;
}
return tok;
@ -797,7 +797,7 @@ lexer_save_token (token tok)
{
#ifdef __HOST
// if (tok.type == TOK_CLOSE_BRACE)
fprintf (lexer_debug_log, "lexer_save_token(%d): type=0x%x, data=%p\n", i, tok.type, tok.data.none);
__fprintf (lexer_debug_log, "lexer_save_token(%d): type=0x%x, data=%p\n", i, tok.type, tok.data.none);
#endif
saved_token = tok;
}

View File

@ -212,7 +212,7 @@ next_token_must_be (token_type tt)
if (tok.type != tt)
{
#ifdef __HOST
printf ("next_token_must_be: 0x%x\n", tt);
__printf ("next_token_must_be: 0x%x\n", tt);
#endif
fatal (ERR_PARSER);
}
@ -1390,6 +1390,6 @@ parser_init (void)
{
scope_index = 1;
#ifdef __HOST
debug_file = fopen ("parser.log", "w");
debug_file = __fopen ("parser.log", "w");
#endif
}

View File

@ -84,6 +84,36 @@ __memcpy(void *s1, /**< destination */
return s1;
} /* __memcpy */
/**
* memmove
*
* @return the dest pointer's value
*/
void *
__memmove(void *s1, /**< destination */
const void *s2, /**< source */
size_t n) /**< bytes number */
{
uint8_t *dest_p = s1;
const uint8_t *src_p = s2;
if ( dest_p < src_p )
{ /* from begin to end */
for ( size_t index = 0; index < n; index++ )
{
dest_p[ index ] = src_p[ index ];
}
} else if ( dest_p > src_p )
{ /* from end to begin */
for ( size_t index = 1; index <= n; index++ )
{
dest_p[ n - index ] = src_p[ n - index ];
}
}
return s1;
} /* __memmove */
/** Compare two strings. return an integer less than, equal to, or greater than zero
if s1 is found, respectively, to be less than, to match, or be greater than s2. */
int

View File

@ -23,16 +23,17 @@
typedef void FILE;
extern void *__memset (void *s, int c, size_t n);
extern void* __memset (void *s, int c, size_t n);
extern int __memcmp (const void *s1, const void *s2, size_t n);
extern void *__memcpy (void *s1, const void *s2, size_t n);
extern void* __memcpy (void *s1, const void *s2, size_t n);
extern void* __memmove (void *dest, const void *src, size_t n);
extern int __printf (const char *format, ...);
extern int __putchar (int);
extern void __noreturn __exit (int);
extern int __strcmp (const char *, const char *);
extern int __strncmp (const char *, const char *, size_t);
extern char *__strncpy (char *, const char *, size_t);
extern char* __strncpy (char *, const char *, size_t);
extern float __strtof (const char *, char **);
extern size_t __strlen (const char *);
@ -47,6 +48,7 @@ extern FILE* __fopen(const char *path, const char *mode);
extern int __fclose(FILE *fp);
extern size_t __fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
extern size_t __fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
extern int __fprintf(FILE *stream, const char *format, ...);
#define DBL_MANT_DIG ( 52)
#define DBL_DIG ( 10)