mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 04:30:10 +00:00
Fixed the return code of fgetpos and ftell.
Made lots of functions __fastcall__. git-svn-id: svn://svn.cc65.org/cc65/trunk@2615 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
8400fb848a
commit
6966ccda7e
@ -13,7 +13,13 @@
|
||||
|
||||
|
||||
|
||||
FILE* fdopen (int handle, const char* /*mode*/)
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
FILE* __fastcall__ fdopen (int handle, const char* /*mode*/)
|
||||
{
|
||||
FILE* f;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
|
||||
|
||||
int fgetc (FILE* f)
|
||||
int __fastcall__ fgetc (FILE* f)
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
|
@ -5,15 +5,23 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int fgetpos(FILE* f, fpos_t *pos)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
int __fastcall__ fgetpos (FILE* f, fpos_t* pos)
|
||||
{
|
||||
*pos = ftell (f);
|
||||
|
||||
if (*pos != -1)
|
||||
return 0;
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,13 @@
|
||||
|
||||
|
||||
|
||||
char* fgets (char* s, unsigned size, FILE* f)
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
char* __fastcall__ fgets (char* s, unsigned size, FILE* f)
|
||||
{
|
||||
int i = 0;
|
||||
int c;
|
||||
|
@ -12,7 +12,13 @@
|
||||
|
||||
|
||||
|
||||
int fputc (int c, FILE* f)
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
int __fastcall__ fputc (int c, FILE* f)
|
||||
{
|
||||
/* Check if the file is open or if there is an error condition */
|
||||
if ((f->f_flags & _FOPEN) == 0 || (f->f_flags & (_FERROR | _FEOF)) != 0) {
|
||||
|
@ -13,7 +13,13 @@
|
||||
|
||||
|
||||
|
||||
FILE* freopen (const char* name, const char* mode, FILE* f)
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
FILE* __fastcall__ freopen (const char* name, const char* mode, FILE* f)
|
||||
{
|
||||
/* Check if the file is open, if so, close it */
|
||||
if ((f->f_flags & _FOPEN) == 0) {
|
||||
|
@ -5,24 +5,32 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "_file.h"
|
||||
|
||||
|
||||
|
||||
int fseek(FILE* f, long offset, int whence)
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
int __fastcall__ fseek (FILE* f, long offset, int whence)
|
||||
{
|
||||
long res;
|
||||
|
||||
/* Is the file open? */
|
||||
if ((f->f_flags & _FOPEN) == 0) {
|
||||
_errno = EINVAL; /* File not open */
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = lseek(f->f_fd, offset, whence);
|
||||
if (res == -1L) return 1;
|
||||
if (res == -1L) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,20 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int fsetpos(FILE* f, const fpos_t *pos)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
int __fastcall__ fsetpos (FILE* f, const fpos_t *pos)
|
||||
{
|
||||
return fseek (f, (fpos_t)*pos, SEEK_SET);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,13 +5,21 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "_file.h"
|
||||
|
||||
|
||||
long ftell(FILE* f)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
long __fastcall__ ftell (FILE* f)
|
||||
{
|
||||
long pos;
|
||||
|
||||
|
@ -7,13 +7,17 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* This is usually declared as a macro */
|
||||
#undef getchar
|
||||
#undef getchar /* This is usually declared as a macro */
|
||||
|
||||
|
||||
|
||||
int getchar (void)
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
int __fastcall__ getchar (void)
|
||||
{
|
||||
return fgetc (stdin);
|
||||
}
|
||||
|
@ -11,7 +11,13 @@
|
||||
|
||||
|
||||
|
||||
char* gets (char* s)
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
char* __fastcall__ gets (char* s)
|
||||
{
|
||||
int c;
|
||||
int i = 0;
|
||||
@ -49,3 +55,4 @@ char* gets (char* s)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -7,13 +7,17 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* This is usually declared as a macro */
|
||||
#undef putchar
|
||||
#undef putchar /* This is usually declared as a macro */
|
||||
|
||||
|
||||
|
||||
int putchar (int c)
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
int __fastcall__ putchar (int c)
|
||||
{
|
||||
return fputc (c, stdout);
|
||||
}
|
||||
|
@ -13,7 +13,13 @@
|
||||
|
||||
|
||||
|
||||
int puts (const char* s)
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
int __fastcall__ puts (const char* s)
|
||||
{
|
||||
static char nl = '\n';
|
||||
|
||||
|
@ -5,12 +5,21 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void rewind(FILE* f)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
void __fastcall__ rewind (FILE* f)
|
||||
{
|
||||
fseek(f, 0L, SEEK_SET);
|
||||
clearerr(f);
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "_scanf.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -31,7 +31,7 @@ static char get (struct indesc* d)
|
||||
|
||||
|
||||
|
||||
int vsscanf (const char* str, const char* format, va_list ap)
|
||||
int __fastcall__ vsscanf (const char* str, const char* format, va_list ap)
|
||||
/* Standard C function */
|
||||
{
|
||||
struct indesc id;
|
||||
|
Loading…
Reference in New Issue
Block a user