mes: Run indent.
for i in $(find . -name '*.h' -o -name '*.c'); do indent $i --no-tabs --no-space-after-casts; done
This commit is contained in:
parent
dac4283f7d
commit
c13941261e
|
@ -32,11 +32,11 @@
|
|||
#include <sys/types.h>
|
||||
|
||||
#if _ALLOCA_UNSIGNED
|
||||
void * alloca (unsigned size);
|
||||
void *alloca (unsigned size);
|
||||
#elif _ALLOCA_CHAR
|
||||
char * alloca (int);
|
||||
char *alloca (int);
|
||||
#else
|
||||
void * alloca (size_t size);
|
||||
void *alloca (size_t size);
|
||||
#endif
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
|
|
22
include/ar.h
22
include/ar.h
|
@ -36,20 +36,20 @@
|
|||
`struct ar_hdr', and as many bytes of member file data as its `ar_size'
|
||||
member indicates, for each member file. */
|
||||
|
||||
#define ARMAG "!<arch>\n" /* String that begins an archive file. */
|
||||
#define SARMAG 8 /* Size of that string. */
|
||||
#define ARMAG "!<arch>\n" /* String that begins an archive file. */
|
||||
#define SARMAG 8 /* Size of that string. */
|
||||
|
||||
#define ARFMAG "`\n" /* String in ar_fmag at end of each header. */
|
||||
#define ARFMAG "`\n" /* String in ar_fmag at end of each header. */
|
||||
|
||||
struct ar_hdr
|
||||
{
|
||||
char ar_name[16]; /* Member file name, sometimes / terminated. */
|
||||
char ar_date[12]; /* File date, decimal seconds since Epoch. */
|
||||
char ar_uid[6], ar_gid[6]; /* User and group IDs, in ASCII decimal. */
|
||||
char ar_mode[8]; /* File mode, in ASCII octal. */
|
||||
char ar_size[10]; /* File size, in ASCII decimal. */
|
||||
char ar_fmag[2]; /* Always contains ARFMAG. */
|
||||
};
|
||||
{
|
||||
char ar_name[16]; /* Member file name, sometimes / terminated. */
|
||||
char ar_date[12]; /* File date, decimal seconds since Epoch. */
|
||||
char ar_uid[6], ar_gid[6]; /* User and group IDs, in ASCII decimal. */
|
||||
char ar_mode[8]; /* File mode, in ASCII octal. */
|
||||
char ar_size[10]; /* File size, in ASCII decimal. */
|
||||
char ar_fmag[2]; /* Always contains ARFMAG. */
|
||||
};
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include_next <assert.h>
|
||||
#else // ! WITH_GLIBC
|
||||
#define assert(x) ((x) ? (void)0 : assert_fail (#x))
|
||||
void assert_fail (char* s);
|
||||
void assert_fail (char *s);
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
#endif // __MES_ASSERT_H
|
||||
|
|
|
@ -41,18 +41,18 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
int __getdirentries (int filedes, char *buffer, size_t nbytes, off_t *basep);
|
||||
int __getdirentries (int filedes, char *buffer, size_t nbytes, off_t * basep);
|
||||
|
||||
struct dirent
|
||||
{
|
||||
ino_t d_ino;
|
||||
off_t d_off;
|
||||
unsigned short int d_reclen;
|
||||
{
|
||||
ino_t d_ino;
|
||||
off_t d_off;
|
||||
unsigned short int d_reclen;
|
||||
#if 0
|
||||
unsigned char d_type;
|
||||
unsigned char d_type;
|
||||
#endif
|
||||
char d_name[256]; /* We must not include limits.h! */
|
||||
};
|
||||
char d_name[256]; /* We must not include limits.h! */
|
||||
};
|
||||
|
||||
/* Open a directory stream on NAME.
|
||||
Return a DIR stream on the directory, or NULL if it could not be opened. */
|
||||
|
@ -60,16 +60,16 @@ DIR *opendir (char const *name);
|
|||
|
||||
/* Close the directory stream DIRP.
|
||||
Return 0 if successful, -1 if not. */
|
||||
int closedir (DIR *dirp);
|
||||
int closedir (DIR * dirp);
|
||||
|
||||
/* Read a directory entry from DIRP.
|
||||
Return a pointer to a `struct dirent' describing the entry,
|
||||
or NULL for EOF or error. The storage returned may be overwritten
|
||||
by a later readdir call on the same DIR stream. */
|
||||
struct dirent *readdir (DIR *dirp);
|
||||
struct dirent *readdir (DIR * dirp);
|
||||
|
||||
/* Rewind DIRP to the beginning of the directory. */
|
||||
extern void rewinddir (DIR *dirp);
|
||||
extern void rewinddir (DIR * dirp);
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
|
|
|
@ -37,16 +37,16 @@
|
|||
|
||||
/* Directory stream type. */
|
||||
struct __dirstream
|
||||
{
|
||||
int fd; /* File descriptor. */
|
||||
{
|
||||
int fd; /* File descriptor. */
|
||||
|
||||
char *data; /* Directory block. */
|
||||
size_t allocation; /* Space allocated for the block. */
|
||||
size_t size; /* Total valid data in the block. */
|
||||
size_t offset; /* Current offset into the block. */
|
||||
char *data; /* Directory block. */
|
||||
size_t allocation; /* Space allocated for the block. */
|
||||
size_t size; /* Total valid data in the block. */
|
||||
size_t offset; /* Current offset into the block. */
|
||||
|
||||
off_t filepos; /* Position of next entry to read. */
|
||||
};
|
||||
off_t filepos; /* Position of next entry to read. */
|
||||
};
|
||||
|
||||
typedef struct __dirstream DIR;
|
||||
|
||||
|
|
|
@ -26,4 +26,3 @@
|
|||
#endif // (WITH_GLIBC)
|
||||
|
||||
#endif // __MES_FEATURES_H
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#if WITH_GLIBC
|
||||
#undef __MES_GRP_H
|
||||
#include_next <pwd.h>
|
||||
#else // ! WITH_GLIBC
|
||||
#else // ! WITH_GLIBC
|
||||
|
||||
struct group
|
||||
{
|
||||
|
@ -38,6 +38,6 @@ void setgrent (void);
|
|||
struct group *getgrgid (gid_t gid);
|
||||
struct group *getgrnam (char const *name);
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
#endif // __MES_GRP_H
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include_next <libgen.h>
|
||||
|
||||
#else // ! WITH_GLIBC
|
||||
char* dirname (char*);
|
||||
char *dirname (char *);
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
#endif // __MES_LIBGEN_H
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#endif
|
||||
// *INDENT-ON*
|
||||
|
||||
char * setlocale (int category, char const *locale);
|
||||
char *setlocale (int category, char const *locale);
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#if WITH_GLIBC
|
||||
#undef __MES_MATH_H
|
||||
#include_next <math.h>
|
||||
#else // ! WITH_GLIBC
|
||||
#else // ! WITH_GLIBC
|
||||
|
||||
double atan2 (double y, double x);
|
||||
double ceil (double x);
|
||||
|
@ -39,6 +39,6 @@ double pow (double base, double power);
|
|||
double sin (double x);
|
||||
double sqrt (double x);
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
#endif // __MES_MATH_H
|
||||
|
|
|
@ -79,12 +79,12 @@ int __stdin;
|
|||
int __stdout;
|
||||
int __stderr;
|
||||
|
||||
int eputs (char const* s);
|
||||
int puts (char const* s);
|
||||
int oputs (char const* s);
|
||||
int eputs (char const *s);
|
||||
int puts (char const *s);
|
||||
int oputs (char const *s);
|
||||
|
||||
#if !WITH_GLIBC
|
||||
size_t strlen (char const* s);
|
||||
size_t strlen (char const *s);
|
||||
ssize_t _write ();
|
||||
ssize_t write (int filedes, void const *buffer, size_t size);
|
||||
#endif // !WITH_GLIBC
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <mes/lib-mini.h>
|
||||
|
||||
int __mes_debug ();
|
||||
double abtod (char const** p, int base);
|
||||
long abtol (char const** p, int base);
|
||||
double abtod (char const **p, int base);
|
||||
long abtol (char const **p, int base);
|
||||
char *dtoab (double number, int base, int signed_p);
|
||||
char *itoa (int number);
|
||||
char *ltoa (long number);
|
||||
|
@ -37,7 +37,7 @@ int atoi (char const *s);
|
|||
int eputc (int c);
|
||||
int fdgetc (int fd);
|
||||
int fdputc (int c, int fd);
|
||||
int fdputs (char const* s, int fd);
|
||||
int fdputs (char const *s, int fd);
|
||||
int fdungetc (int c, int fd);
|
||||
int _fdungetc_p (int fd);
|
||||
int isdigit (int c);
|
||||
|
@ -47,7 +47,7 @@ int mes_open (char const *file_name, int flags, int mask);
|
|||
int _open2 (char const *file_name, int flags);
|
||||
int _open3 (char const *file_name, int flags, int mask);
|
||||
int oputc (int c);
|
||||
int oputs (char const* s);
|
||||
int oputs (char const *s);
|
||||
char *search_path (char const *file_name);
|
||||
|
||||
#endif //__MES_LIB_H
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#if WITH_GLIBC
|
||||
#undef __MES_PWD_H
|
||||
#include_next <pwd.h>
|
||||
#else // ! WITH_GLIBC
|
||||
#else // ! WITH_GLIBC
|
||||
|
||||
struct passwd
|
||||
{
|
||||
|
@ -36,9 +36,9 @@ struct passwd
|
|||
char *pw_shell;
|
||||
};
|
||||
|
||||
struct passwd * getpwuid ();
|
||||
struct passwd *getpwuid ();
|
||||
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
#endif // __MES_PWD_H
|
||||
|
|
|
@ -118,7 +118,7 @@ typedef struct siginfo_t
|
|||
#if __MESC__
|
||||
typedef long sighandler_t;
|
||||
#else
|
||||
typedef void (*sighandler_t)(int);
|
||||
typedef void (*sighandler_t) (int);
|
||||
#endif
|
||||
|
||||
struct sigaction
|
||||
|
@ -199,14 +199,14 @@ struct _libc_fpstate
|
|||
typedef struct _libc_fpstate *fpregset_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gregset_t gregs;
|
||||
/* Due to Linux's history we have to use a pointer here. The SysV/i386
|
||||
ABI requires a struct with the values. */
|
||||
fpregset_t fpregs;
|
||||
unsigned long int oldmask;
|
||||
unsigned long int cr2;
|
||||
} mcontext_t;
|
||||
{
|
||||
gregset_t gregs;
|
||||
/* Due to Linux's history we have to use a pointer here. The SysV/i386
|
||||
ABI requires a struct with the values. */
|
||||
fpregset_t fpregs;
|
||||
unsigned long int oldmask;
|
||||
unsigned long int cr2;
|
||||
} mcontext_t;
|
||||
|
||||
/* Userlevel context. */
|
||||
typedef struct ucontext
|
||||
|
@ -221,20 +221,21 @@ typedef struct ucontext
|
|||
#endif // !__i386__
|
||||
|
||||
int kill (pid_t pid, int signum);
|
||||
int sigaction (int signum, struct sigaction const *act, struct sigaction *oldact);
|
||||
int sigaddset (sigset_t *set, int signum);
|
||||
int sigaction (int signum, struct sigaction const *act,
|
||||
struct sigaction *oldact);
|
||||
int sigaddset (sigset_t * set, int signum);
|
||||
#if __MESC__
|
||||
void* signal (int signum, void * action);
|
||||
void *signal (int signum, void *action);
|
||||
#else
|
||||
sighandler_t signal (int signum, sighandler_t action);
|
||||
#endif
|
||||
int sigemptyset (sigset_t *set);
|
||||
int sigemptyset (sigset_t * set);
|
||||
#ifndef SIG_BLOCK
|
||||
#define SIG_BLOCK 0
|
||||
#define SIG_UNBLOCK 1
|
||||
#define SIG_SETMASK 2
|
||||
#endif
|
||||
int sigprocmask (int how, sigset_t const *set, sigset_t *oldset);
|
||||
int sigprocmask (int how, sigset_t const *set, sigset_t * oldset);
|
||||
|
||||
#endif //! WITH_GLIBC
|
||||
|
||||
|
|
|
@ -31,15 +31,15 @@
|
|||
#define __FOO_VARARGS 1
|
||||
#endif
|
||||
|
||||
typedef char* va_list;
|
||||
typedef char *va_list;
|
||||
#define va_start(ap, last) (void)((ap) = (char*)(&(last) + 1))
|
||||
#define va_arg(ap, type) (type)(((long*)((ap) = ((ap) + sizeof (void*))))[-1])
|
||||
#define va_end(ap) (void)((ap) = 0)
|
||||
#define va_copy(dest, src) dest = src
|
||||
|
||||
int vfprintf (FILE *stream, char const *template, va_list ap);
|
||||
int vfscanf (FILE *stream, char const *template, va_list ap);
|
||||
int vprintf (char const* format, va_list ap);
|
||||
int vfprintf (FILE * stream, char const *template, va_list ap);
|
||||
int vfscanf (FILE * stream, char const *template, va_list ap);
|
||||
int vprintf (char const *format, va_list ap);
|
||||
int vsprintf (char *str, char const *format, va_list ap);
|
||||
int vsnprintf (char *str, size_t size, char const *format, va_list ap);
|
||||
int vsscanf (char const *s, char const *template, va_list ap);
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
#else // ! WITH_GLIBC
|
||||
|
||||
#ifndef _IOFBF
|
||||
#define _IOFBF 0 /* Fully buffered. */
|
||||
#define _IOLBF 1 /* Line buffered. */
|
||||
#define _IONBF 2 /* No buffering. */
|
||||
#define _IOFBF 0 /* Fully buffered. */
|
||||
#define _IOLBF 1 /* Line buffered. */
|
||||
#define _IONBF 2 /* No buffering. */
|
||||
#endif
|
||||
|
||||
#ifndef BUFSIZ
|
||||
|
@ -58,37 +58,37 @@
|
|||
FILE *fdopen (int fd, char const *mode);
|
||||
FILE *fopen (char const *file_name, char const *mode);
|
||||
int eputc (int c);
|
||||
int eputs (char const* s);
|
||||
int fclose (FILE *stream);
|
||||
int feof (FILE *stream);
|
||||
int ferror (FILE *stream);
|
||||
int fflush (FILE *stream);
|
||||
int fgetc (FILE* stream);
|
||||
char *fgets (char *s, int size, FILE *stream);
|
||||
int fprintf (FILE *stream, char const *format, ...);
|
||||
int fpurge (FILE *stream);
|
||||
int fputc (int c, FILE *stream);
|
||||
int fputs (char const* s, FILE *stream);
|
||||
int fscanf (FILE *stream, char const *template, ...);
|
||||
int fseek (FILE *stream, long offset, int whence);
|
||||
int getc (FILE *stream);
|
||||
int eputs (char const *s);
|
||||
int fclose (FILE * stream);
|
||||
int feof (FILE * stream);
|
||||
int ferror (FILE * stream);
|
||||
int fflush (FILE * stream);
|
||||
int fgetc (FILE * stream);
|
||||
char *fgets (char *s, int size, FILE * stream);
|
||||
int fprintf (FILE * stream, char const *format, ...);
|
||||
int fpurge (FILE * stream);
|
||||
int fputc (int c, FILE * stream);
|
||||
int fputs (char const *s, FILE * stream);
|
||||
int fscanf (FILE * stream, char const *template, ...);
|
||||
int fseek (FILE * stream, long offset, int whence);
|
||||
int getc (FILE * stream);
|
||||
int getchar (void);
|
||||
char *getlogin (void);
|
||||
int printf (char const* format, ...);
|
||||
int putc (int c, FILE* stream);
|
||||
int printf (char const *format, ...);
|
||||
int putc (int c, FILE * stream);
|
||||
int putchar (int c);
|
||||
int puts (char const* s);
|
||||
int puts (char const *s);
|
||||
int remove (char const *file_name);
|
||||
void rewind (FILE *stream);
|
||||
int setvbuf (FILE *stream, char *buf, int mode, size_t size);
|
||||
int snprintf(char *str, size_t size, char const *format, ...);
|
||||
int sprintf (char *str, char const* format, ...);
|
||||
void rewind (FILE * stream);
|
||||
int setvbuf (FILE * stream, char *buf, int mode, size_t size);
|
||||
int snprintf (char *str, size_t size, char const *format, ...);
|
||||
int sprintf (char *str, char const *format, ...);
|
||||
int sscanf (char const *str, char const *format, ...);
|
||||
int ungetc (int c, FILE* stream);
|
||||
long ftell (FILE *stream);
|
||||
size_t fread (void *ptr, size_t size, size_t count, FILE *stream);
|
||||
size_t freadahead (FILE *fp);
|
||||
size_t fwrite (void const *ptr, size_t size, size_t count, FILE *stream);
|
||||
int ungetc (int c, FILE * stream);
|
||||
long ftell (FILE * stream);
|
||||
size_t fread (void *ptr, size_t size, size_t count, FILE * stream);
|
||||
size_t freadahead (FILE * fp);
|
||||
size_t fwrite (void const *ptr, size_t size, size_t count, FILE * stream);
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#endif
|
||||
#undef __MES_STDLIB_H
|
||||
#include_next <stdlib.h>
|
||||
#else // ! WITH_GLIBC
|
||||
#else // ! WITH_GLIBC
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <alloca.h>
|
||||
|
@ -35,15 +35,16 @@ void abort (void);
|
|||
double atof (char const *s);
|
||||
int atoi (char const *s);
|
||||
int atexit (void (*function) (void));
|
||||
void * calloc (size_t nmemb, size_t size);
|
||||
void *calloc (size_t nmemb, size_t size);
|
||||
void _exit (int status);
|
||||
void exit (int status);
|
||||
void free (void *ptr);
|
||||
char* getenv (char const* s);
|
||||
int setenv (char const* s, char const* v, int overwrite_p);
|
||||
char *getenv (char const *s);
|
||||
int setenv (char const *s, char const *v, int overwrite_p);
|
||||
void unsetenv (char const *name);
|
||||
void *malloc (size_t);
|
||||
void qsort (void *base, size_t nmemb, size_t size, int (*compar)(void const *, void const *));
|
||||
void qsort (void *base, size_t nmemb, size_t size,
|
||||
int (*compar) (void const *, void const *));
|
||||
int rand (void);
|
||||
void *realloc (void *p, size_t size);
|
||||
double strtod (char const *string, char **tailptr);
|
||||
|
@ -62,7 +63,8 @@ unsigned long long strtoull (char const *string, char **tailptr, int base);
|
|||
typedef int (*comparison_fn_t) (void const *, void const *);
|
||||
#endif
|
||||
|
||||
void * bsearch (void const *key, void const *array, size_t count, size_t size, comparison_fn_t compare);
|
||||
void *bsearch (void const *key, void const *array, size_t count, size_t size,
|
||||
comparison_fn_t compare);
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
|
|
|
@ -31,26 +31,26 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
void * memchr (void const *block, int c, size_t size);
|
||||
void *memchr (void const *block, int c, size_t size);
|
||||
void *memcpy (void *dest, void const *src, size_t n);
|
||||
void *memmove (void *dest, void const *src, size_t n);
|
||||
void *memset (void *s, int c, size_t n);
|
||||
void * memchr (void const *block, int c, size_t size);
|
||||
void *memchr (void const *block, int c, size_t size);
|
||||
int memcmp (void const *s1, void const *s2, size_t n);
|
||||
|
||||
char *strcat (char *dest, char const *src);
|
||||
char *strchr (char const *s, int c);
|
||||
int strcasecmp (char const *s1, char const *s2);
|
||||
int strcmp (char const*, char const*);
|
||||
int strcmp (char const *, char const *);
|
||||
char *strcpy (char *dest, char const *src);
|
||||
size_t strlen (char const*);
|
||||
size_t strlen (char const *);
|
||||
char *strncpy (char *to, char const *from, size_t size);
|
||||
int strncmp (char const*, char const*, size_t);
|
||||
int strncmp (char const *, char const *, size_t);
|
||||
char *strrchr (char const *s, int c);
|
||||
char *strstr (char const *haystack, char const *needle);
|
||||
char *strtok (char *new_string, char const *delimiters);
|
||||
char * strlwr (char *string);
|
||||
char * strupr (char *string);
|
||||
char *strlwr (char *string);
|
||||
char *strupr (char *string);
|
||||
|
||||
|
||||
char *strerror (int errnum);
|
||||
|
|
|
@ -26,4 +26,3 @@
|
|||
#endif // (WITH_GLIBC)
|
||||
|
||||
#endif // __MES_STRINGS_H
|
||||
|
||||
|
|
|
@ -26,4 +26,3 @@
|
|||
#endif // (WITH_GLIBC)
|
||||
|
||||
#endif // __MES_SYS_CDEFS_H
|
||||
|
||||
|
|
|
@ -33,4 +33,3 @@ int ioctl (int fd, unsigned long request, ...);
|
|||
#endif // ! WITH_GLIBC
|
||||
|
||||
#endif // __MES_SYS_IOCTL_H
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
#define PROT_WRITE 2
|
||||
#define PROT_EXEC 4
|
||||
|
||||
void *mmap (void *address, size_t length, int protect, int flags, int filedes, off_t offset);
|
||||
void *mmap (void *address, size_t length, int protect, int flags, int filedes,
|
||||
off_t offset);
|
||||
int mprotect (void *addr, size_t len, int prot);
|
||||
int munmap (void *addr, size_t length);
|
||||
|
||||
|
|
|
@ -23,9 +23,8 @@
|
|||
#if WITH_GLIBC
|
||||
#undef __MES_SYS_SELECT_H
|
||||
#include_next <sys/select.h>
|
||||
#else //! WITH_GLIBC
|
||||
#else //! WITH_GLIBC
|
||||
typedef int fd_set;
|
||||
#endif //! WITH_GLIBC
|
||||
|
||||
#endif // __MES_SYS_SELECT_H
|
||||
|
||||
|
|
|
@ -26,4 +26,3 @@
|
|||
#endif // (WITH_GLIBC)
|
||||
|
||||
#endif // __MES_SYS_TIMEB_H
|
||||
|
||||
|
|
|
@ -26,4 +26,3 @@
|
|||
#endif // (WITH_GLIBC)
|
||||
|
||||
#endif // __MES_SYS_UCONTEXT_H
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct user_fpregs_struct
|
|||
long int fcs;
|
||||
long int foo;
|
||||
long int fos;
|
||||
long int st_space [20];
|
||||
long int st_space[20];
|
||||
};
|
||||
|
||||
struct user_fpxregs_struct
|
||||
|
@ -51,8 +51,8 @@ struct user_fpxregs_struct
|
|||
long int fos;
|
||||
long int mxcsr;
|
||||
long int reserved;
|
||||
long int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
|
||||
long int xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
|
||||
long int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
|
||||
long int xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
|
||||
long int padding[56];
|
||||
};
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ typedef long int clockid_t;
|
|||
typedef long int time_t;
|
||||
#endif
|
||||
|
||||
struct tm {
|
||||
struct tm
|
||||
{
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
|
@ -61,7 +62,7 @@ struct tm *localtime (time_t const *timep);
|
|||
struct tm *gmtime (time_t const *time);
|
||||
int mktime (struct tm *broken_time);
|
||||
|
||||
time_t time (time_t *tloc);
|
||||
time_t time (time_t * tloc);
|
||||
|
||||
#endif // ! WITH_GLIBC
|
||||
|
||||
|
|
|
@ -83,9 +83,9 @@ ssize_t read (int fd, void *buffer, size_t size);
|
|||
ssize_t readlink (char const *file_name, char *buffer, size_t size);
|
||||
#if __SBRK_CHAR_PTRDIFF
|
||||
/* xmalloc in binutils <= 2.10.1 uses this old prototype */
|
||||
char * sbrk (ptrdiff_t delta);
|
||||
char *sbrk (ptrdiff_t delta);
|
||||
#else
|
||||
void * sbrk (intptr_t delta);
|
||||
void *sbrk (intptr_t delta);
|
||||
#endif
|
||||
int symlink (char const *old_name, char const *new_name);
|
||||
int unlink (char const *file_name);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
void
|
||||
assert_fail (char* s)
|
||||
assert_fail (char *s)
|
||||
{
|
||||
eputs ("assert fail: ");
|
||||
eputs (s);
|
||||
|
|
|
@ -23,5 +23,6 @@
|
|||
int
|
||||
isspace (int c)
|
||||
{
|
||||
return (c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r' || c == ' ');
|
||||
return (c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'
|
||||
|| c == ' ');
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
int
|
||||
__getdirentries (int filedes, char *buffer, size_t nbytes, off_t *basep)
|
||||
__getdirentries (int filedes, char *buffer, size_t nbytes, off_t * basep)
|
||||
{
|
||||
if (basep)
|
||||
*basep = lseek (filedes, (off_t) 0, SEEK_CUR);
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
/* Close the directory stream DIRP.
|
||||
Return 0 if successful, -1 if not. */
|
||||
int
|
||||
closedir (DIR *dirp)
|
||||
closedir (DIR * dirp)
|
||||
{
|
||||
int filedes;
|
||||
|
||||
|
|
|
@ -47,12 +47,12 @@ opendir (char const *name)
|
|||
if (name[0] == '\0')
|
||||
{
|
||||
/* POSIX.1-1990 says an empty name gets ENOENT;
|
||||
but `open' might like it fine. */
|
||||
but `open' might like it fine. */
|
||||
errno = ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
fd = open (name, O_RDONLY|O_DIRECTORY);
|
||||
fd = open (name, O_RDONLY | O_DIRECTORY);
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
|
||||
|
@ -73,7 +73,7 @@ opendir (char const *name)
|
|||
errno = save_errno;
|
||||
return 0;
|
||||
}
|
||||
dirp->data = (char *) (dirp + 1);
|
||||
dirp->data = (char *)(dirp + 1);
|
||||
dirp->allocation = allocation;
|
||||
dirp->fd = fd;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
/* Read a directory entry from DIRP. */
|
||||
struct dirent *
|
||||
readdir (DIR *dirp)
|
||||
readdir (DIR * dirp)
|
||||
{
|
||||
struct dirent *dp;
|
||||
int saved_errno = errno;
|
||||
|
@ -44,42 +44,43 @@ readdir (DIR *dirp)
|
|||
size_t reclen;
|
||||
|
||||
if (dirp->offset >= dirp->size)
|
||||
{
|
||||
/* We've emptied out our buffer. Refill it. */
|
||||
{
|
||||
/* We've emptied out our buffer. Refill it. */
|
||||
|
||||
size_t maxread;
|
||||
ssize_t bytes;
|
||||
size_t maxread;
|
||||
ssize_t bytes;
|
||||
|
||||
maxread = dirp->allocation;
|
||||
maxread = dirp->allocation;
|
||||
|
||||
#if 0
|
||||
off_t base;
|
||||
bytes = __getdirentries (dirp->fd, dirp->data, maxread, &base);
|
||||
off_t base;
|
||||
bytes = __getdirentries (dirp->fd, dirp->data, maxread, &base);
|
||||
#else
|
||||
bytes = getdents (dirp->fd, dirp->data, maxread);
|
||||
#endif
|
||||
if (bytes <= 0)
|
||||
{
|
||||
/* Don't modifiy errno when reaching EOF. */
|
||||
if (bytes == 0)
|
||||
if (bytes <= 0)
|
||||
{
|
||||
/* Don't modifiy errno when reaching EOF. */
|
||||
if (bytes == 0)
|
||||
errno = saved_errno;
|
||||
dp = 0;
|
||||
break;
|
||||
}
|
||||
dirp->size = (size_t) bytes;
|
||||
dp = 0;
|
||||
break;
|
||||
}
|
||||
dirp->size = (size_t)bytes;
|
||||
|
||||
/* Reset the offset into the buffer. */
|
||||
dirp->offset = 0;
|
||||
}
|
||||
/* Reset the offset into the buffer. */
|
||||
dirp->offset = 0;
|
||||
}
|
||||
|
||||
dp = (struct dirent *) &dirp->data[dirp->offset];
|
||||
dp = (struct dirent *)&dirp->data[dirp->offset];
|
||||
|
||||
reclen = dp->d_reclen;
|
||||
dirp->offset += reclen;
|
||||
dirp->filepos = dp->d_off;
|
||||
|
||||
/* Skip deleted files. */
|
||||
} while (dp->d_ino == 0);
|
||||
}
|
||||
while (dp->d_ino == 0);
|
||||
|
||||
return dp;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include <stub/pclose.c>
|
||||
#include <stub/popen.c>
|
||||
#include <string/rindex.c>
|
||||
#include <stdio/rewind.c> // for gcc-4.6.4; could be stubbed
|
||||
#include <stdio/rewind.c> // for gcc-4.6.4; could be stubbed
|
||||
#include <stub/setbuf.c>
|
||||
#include <stub/system.c>
|
||||
#include <string/strerror.c>
|
||||
|
@ -70,8 +70,8 @@
|
|||
#include <stub/sys_siglist.c>
|
||||
#include <stub/umask.c>
|
||||
#include <stub/utime.c>
|
||||
#include <stdio/fscanf.c> // for gcc-4.6.4; could be stubbed
|
||||
#include <stdio/vfscanf.c> // dependency of fscanf
|
||||
#include <stdio/fscanf.c> // for gcc-4.6.4; could be stubbed
|
||||
#include <stdio/vfscanf.c> // dependency of fscanf
|
||||
#include <ctype/isascii.c>
|
||||
#include <stdlib/bsearch.c>
|
||||
#include <stub/gmtime.c>
|
||||
|
|
|
@ -61,8 +61,8 @@ int errno;
|
|||
#include <ctype/isupper.c>
|
||||
#include <ctype/tolower.c>
|
||||
#include <ctype/toupper.c>
|
||||
#include <mes/abtod.c> // implementation instead of stub for GNU gawk
|
||||
#include <mes/dtoab.c> // implementation instead of stub for GNU gawk
|
||||
#include <mes/abtod.c> // implementation instead of stub for GNU gawk
|
||||
#include <mes/dtoab.c> // implementation instead of stub for GNU gawk
|
||||
#include <mes/search-path.c>
|
||||
#include <posix/execvp.c>
|
||||
#include <stdio/fclose.c>
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
#include <stub/pclose.c>
|
||||
#include <stub/popen.c>
|
||||
#include <string/rindex.c>
|
||||
#include <stdio/rewind.c> // for gcc-4.6.4; could be stubbed
|
||||
#include <stdio/rewind.c> // for gcc-4.6.4; could be stubbed
|
||||
#include <stub/setbuf.c>
|
||||
#include <stub/system.c>
|
||||
#include <string/strerror.c>
|
||||
|
@ -87,8 +87,8 @@
|
|||
#include <stub/sys_siglist.c>
|
||||
#include <stub/umask.c>
|
||||
#include <stub/utime.c>
|
||||
#include <stdio/fscanf.c> // for gcc-4.6.4; could be stubbed
|
||||
#include <stdio/vfscanf.c> // dependency of fscanf
|
||||
#include <stdio/fscanf.c> // for gcc-4.6.4; could be stubbed
|
||||
#include <stdio/vfscanf.c> // dependency of fscanf
|
||||
#include <ctype/isascii.c>
|
||||
#include <stdlib/bsearch.c>
|
||||
#include <stub/gmtime.c>
|
||||
|
|
|
@ -57,7 +57,7 @@ mes_open (char const *file_name, int flags, int mask)
|
|||
if (r > 2)
|
||||
__ungetc_buf[r] = -1;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
#include <mes/eputs.c>
|
||||
#include <mes/oputs.c>
|
||||
|
|
|
@ -37,7 +37,7 @@ __moddi3 (double a, double b)
|
|||
if (__mes_debug () && !stub)
|
||||
eputs ("__moddi3 stub\n");
|
||||
stub = 1;
|
||||
return ((int) a %(int)b);
|
||||
return ((int)a % (int)b);
|
||||
}
|
||||
|
||||
unsigned long long
|
||||
|
@ -120,7 +120,7 @@ long
|
|||
int
|
||||
#else // !__TINYCC_
|
||||
long long
|
||||
#endif // !__TINYCC_
|
||||
#endif // !__TINYCC_
|
||||
__fixdfdi (double a1)
|
||||
{
|
||||
static int stub = 0;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
int
|
||||
execve (char const* file_name, char *const argv[], char *const env[])
|
||||
execve (char const *file_name, char *const argv[], char *const env[])
|
||||
{
|
||||
return _sys_call3 (SYS_execve, (long)file_name, (long)argv, (long)env);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
*/
|
||||
|
||||
void *
|
||||
mmap (void* addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
return _sys_call6 (SYS_mmap, (long)addr, (long)len, (int)prot, (int)flags, (int)fd, (long)offset);
|
||||
return _sys_call6 (SYS_mmap, (long)addr, (long)len, (int)prot, (int)flags,
|
||||
(int)fd, (long)offset);
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
*/
|
||||
|
||||
int
|
||||
nanosleep (const struct timespec *requested_time,
|
||||
struct timespec *remaining)
|
||||
nanosleep (const struct timespec *requested_time, struct timespec *remaining)
|
||||
{
|
||||
return _sys_call2 (SYS_nanosleep, (long)requested_time, (long)remaining);
|
||||
}
|
||||
|
|
|
@ -21,17 +21,25 @@
|
|||
ssize_t
|
||||
read (int filedes, void *buffer, size_t size)
|
||||
{
|
||||
ssize_t bytes = _sys_call3 (SYS_read, (int)filedes, (long)buffer, (long)size);
|
||||
ssize_t bytes =
|
||||
_sys_call3 (SYS_read, (int)filedes, (long)buffer, (long)size);
|
||||
if (__mes_debug () > 3)
|
||||
{
|
||||
if (bytes == 1)
|
||||
{
|
||||
eputs ("read fd="); eputs (itoa ((int)filedes)); eputs (" c="); eputc (*(char*)buffer); eputs ("\n");
|
||||
eputs ("read fd=");
|
||||
eputs (itoa ((int)filedes));
|
||||
eputs (" c=");
|
||||
eputc (*(char *)buffer);
|
||||
eputs ("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
eputs ("read fd="); eputs (itoa ((int)filedes));
|
||||
eputs (" bytes="); eputs (itoa (bytes)); eputs ("\n");
|
||||
eputs ("read fd=");
|
||||
eputs (itoa ((int)filedes));
|
||||
eputs (" bytes=");
|
||||
eputs (itoa (bytes));
|
||||
eputs ("\n");
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
*/
|
||||
|
||||
int
|
||||
setitimer (int which, struct itimerval const *new,
|
||||
struct itimerval *old)
|
||||
setitimer (int which, struct itimerval const *new, struct itimerval *old)
|
||||
{
|
||||
return _sys_call3 (SYS_setitimer, (long)which, (long)new, (long)old);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ _restorer (void)
|
|||
}
|
||||
#endif
|
||||
|
||||
# define __sigmask(sig) \
|
||||
#define __sigmask(sig) \
|
||||
(((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
|
||||
|
||||
sighandler_t
|
||||
|
@ -35,15 +35,17 @@ signal (int signum, sighandler_t action)
|
|||
#if __i386__
|
||||
return _sys_call2 (SYS_signal, signum, action);
|
||||
#else
|
||||
static struct sigaction setup_action = {-1};
|
||||
static struct sigaction old = {0};
|
||||
static struct sigaction setup_action = { -1 };
|
||||
static struct sigaction old = { 0 };
|
||||
|
||||
setup_action.sa_handler = action;
|
||||
setup_action.sa_restorer = _restorer;
|
||||
setup_action.sa_mask = __sigmask (signum);
|
||||
old.sa_handler = SIG_DFL;
|
||||
setup_action.sa_flags = SA_RESTORER | SA_RESTART;
|
||||
int r = _sys_call4 (SYS_rt_sigaction, signum, &setup_action, &old, sizeof (sigset_t));
|
||||
int r =
|
||||
_sys_call4 (SYS_rt_sigaction, signum, &setup_action, &old,
|
||||
sizeof (sigset_t));
|
||||
if (r)
|
||||
return 0;
|
||||
return old.sa_handler;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
int
|
||||
sigprocmask (int how, sigset_t const *set, sigset_t *oldset)
|
||||
sigprocmask (int how, sigset_t const *set, sigset_t * oldset)
|
||||
{
|
||||
#if __i386__
|
||||
return _sys_call3 (SYS_sigprocmask, (long)how, (long)set, (long)oldset);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <time.h>
|
||||
|
||||
time_t
|
||||
time (time_t *result)
|
||||
time (time_t * result)
|
||||
{
|
||||
return _sys_call1 (SYS_time, (long)result);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ __sys_call4 (int sys_call, int one, int two, int three, int four)
|
|||
}
|
||||
|
||||
int
|
||||
__sys_call6 (int sys_call, int one, int two, int three, int four, int five, int six)
|
||||
__sys_call6 (int sys_call, int one, int two, int three, int four, int five,
|
||||
int six)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !0x08");
|
||||
asm ("mov____%ebp,%ebx");
|
||||
|
@ -146,7 +147,8 @@ _sys_call4 (int sys_call, int one, int two, int three, int four)
|
|||
}
|
||||
|
||||
int
|
||||
_sys_call6 (int sys_call, int one, int two, int three, int four, int five, int six)
|
||||
_sys_call6 (int sys_call, int one, int two, int three, int four, int five,
|
||||
int six)
|
||||
{
|
||||
return __sys_call6 (sys_call, one, two, three, four, five, six);
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ _start ()
|
|||
asm ("mov____$i8,%rax !2");
|
||||
asm ("mov____%rax,0x32 &__stderr");
|
||||
|
||||
#if 0 //MES_CCAMD64
|
||||
asm ("add____$i32,%rbp %0x80"); // FIXME: corresponds to x86_64/as.scm function-preamble-fu
|
||||
#if 0 //MES_CCAMD64
|
||||
asm ("add____$i32,%rbp %0x80"); // FIXME: corresponds to x86_64/as.scm function-preamble-fu
|
||||
#endif
|
||||
asm ("mov____%rbp,%rax");
|
||||
asm ("add____$i8,%rax !8");
|
||||
|
@ -47,7 +47,7 @@ _start ()
|
|||
|
||||
// FIXME: 64-bit addresses...
|
||||
asm ("mov____%rax,0x32 &environ");
|
||||
#if 0 //MES_CCAMD64
|
||||
#if 0 //MES_CCAMD64
|
||||
asm ("mov____%rax,%rdx"); // amd
|
||||
#else
|
||||
asm ("push___%rax"); // bootstrap
|
||||
|
@ -55,7 +55,7 @@ _start ()
|
|||
|
||||
asm ("mov____%rbp,%rax");
|
||||
asm ("add____$i8,%rax !16");
|
||||
#if 0 //MES_CCAMD64
|
||||
#if 0 //MES_CCAMD64
|
||||
asm ("mov____%rax,%rsi"); // amd
|
||||
#else
|
||||
asm ("push___%rax"); // bootstrap
|
||||
|
@ -64,7 +64,7 @@ _start ()
|
|||
asm ("mov____%rbp,%rax");
|
||||
asm ("add____$i8,%rax !8");
|
||||
asm ("mov____(%rax),%rax");
|
||||
#if 0 //MES_CCAMD64
|
||||
#if 0 //MES_CCAMD64
|
||||
asm ("mov____%rax,%rdi"); // amd
|
||||
#else
|
||||
asm ("push___%rax"); // bootstrap
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
|
||||
long
|
||||
//__sys_call (long one, long two, long three, long four)
|
||||
__sys_call (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||
__sys_call (long sys_call, long one, long two, long three, long four,
|
||||
long five, long six)
|
||||
{
|
||||
#if 1 // !MES_CCAMD64
|
||||
#if 1 // !MES_CCAMD64
|
||||
// asm ("mov____0x8(%rbp),%rdi !0x10");
|
||||
// asm ("mov____0x8(%rbp),%rsi !0x18");
|
||||
// asm ("mov____0x8(%rbp),%rdx !0x20");
|
||||
|
@ -125,7 +126,8 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
|||
}
|
||||
|
||||
long
|
||||
_sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||
_sys_call6 (long sys_call, long one, long two, long three, long four,
|
||||
long five, long six)
|
||||
{
|
||||
// long rax = sys_call;
|
||||
// long r = __sys_call6 (one, two, three, four, five, six);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
void
|
||||
_exit (int status)
|
||||
{
|
||||
#if 1 // !MES_CCAMD64
|
||||
#if 1 // !MES_CCAMD64
|
||||
asm ("mov____0x8(%rbp),%rdi !0x10");
|
||||
#endif
|
||||
|
||||
|
@ -32,7 +32,7 @@ _exit (int status)
|
|||
void
|
||||
_write (int filedes, void const *buffer, size_t size)
|
||||
{
|
||||
#if 1 // !MES_CCAMD64
|
||||
#if 1 // !MES_CCAMD64
|
||||
asm ("mov____0x8(%rbp),%rdi !0x10");
|
||||
asm ("mov____0x8(%rbp),%rsi !0x18");
|
||||
asm ("mov____0x8(%rbp),%rdx !0x20");
|
||||
|
|
|
@ -45,9 +45,9 @@ abtod (char const **p, int base)
|
|||
d = i + f / dbase;
|
||||
if (e < 0)
|
||||
while (e++)
|
||||
d = d / dbase;
|
||||
while (e--)
|
||||
d = d * dbase;
|
||||
d = d / dbase;
|
||||
while (e--)
|
||||
d = d * dbase;
|
||||
*p = s;
|
||||
return sign_p ? -d : d;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <mes/lib.h>
|
||||
|
||||
int
|
||||
eputs (char const* s)
|
||||
eputs (char const *s)
|
||||
{
|
||||
int i = strlen (s);
|
||||
write (__stderr, s, i);
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
#include <limits.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
int __ungetc_buf[RLIMIT_NOFILE+1] = {0};
|
||||
int __ungetc_buf[RLIMIT_NOFILE + 1] = { 0 };
|
||||
|
||||
void
|
||||
__ungetc_init ()
|
||||
{
|
||||
if (__ungetc_buf[RLIMIT_NOFILE] == 0)
|
||||
memset (__ungetc_buf, -1, (RLIMIT_NOFILE+1)*sizeof (int));
|
||||
memset (__ungetc_buf, -1, (RLIMIT_NOFILE + 1) * sizeof (int));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -46,7 +46,7 @@ fdgetc (int fd)
|
|||
if (r < 1)
|
||||
return -1;
|
||||
i = c;
|
||||
}
|
||||
}
|
||||
if (i < 0)
|
||||
i += 256;
|
||||
|
||||
|
|
|
@ -23,6 +23,6 @@
|
|||
int
|
||||
fdputc (int c, int fd)
|
||||
{
|
||||
write (fd, (char*)&c, 1);
|
||||
write (fd, (char *)&c, 1);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <mes/lib.h>
|
||||
|
||||
int
|
||||
fdputs (char const* s, int fd)
|
||||
fdputs (char const *s, int fd)
|
||||
{
|
||||
int i = strlen (s);
|
||||
write (fd, s, i);
|
||||
|
|
|
@ -36,14 +36,15 @@ ntoab (long x, int base, int signed_p)
|
|||
}
|
||||
|
||||
do
|
||||
{
|
||||
long i = u % base;
|
||||
*p-- = i > 9 ? 'a' + i - 10 : '0' + i;
|
||||
u = u / base;
|
||||
} while (u);
|
||||
{
|
||||
long i = u % base;
|
||||
*p-- = i > 9 ? 'a' + i - 10 : '0' + i;
|
||||
u = u / base;
|
||||
}
|
||||
while (u);
|
||||
|
||||
if (sign_p && *(p + 1) != '0')
|
||||
*p-- = '-';
|
||||
|
||||
return p+1;
|
||||
return p + 1;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <mes/lib.h>
|
||||
|
||||
int
|
||||
oputs (char const* s)
|
||||
oputs (char const *s)
|
||||
{
|
||||
int i = strlen (s);
|
||||
write (__stdout, s, i);
|
||||
|
|
|
@ -27,7 +27,9 @@ search_path (char const *file_name)
|
|||
char *path = getenv ("PATH");
|
||||
if (__mes_debug ())
|
||||
{
|
||||
eputs ("\n search-path: "); eputs (file_name); eputs ("\n");
|
||||
eputs ("\n search-path: ");
|
||||
eputs (file_name);
|
||||
eputs ("\n");
|
||||
}
|
||||
while (*path)
|
||||
{
|
||||
|
@ -38,7 +40,9 @@ search_path (char const *file_name)
|
|||
buf[end - path] = 0;
|
||||
if (__mes_debug ())
|
||||
{
|
||||
eputs (" dir: "); eputs (buf); eputs ("\n");
|
||||
eputs (" dir: ");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
}
|
||||
if (buf[end - path] != '/')
|
||||
strcat (buf, "/");
|
||||
|
@ -47,7 +51,9 @@ search_path (char const *file_name)
|
|||
{
|
||||
if (__mes_debug ())
|
||||
{
|
||||
eputs (" found: "); eputs (buf); eputs ("\n");
|
||||
eputs (" found: ");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ alarm (unsigned int seconds)
|
|||
new.it_interval.tv_usec = 0;
|
||||
new.it_interval.tv_sec = 0;
|
||||
new.it_value.tv_usec = 0;
|
||||
new.it_value.tv_sec = (long int) seconds;
|
||||
new.it_value.tv_sec = (long int)seconds;
|
||||
if (setitimer (ITIMER_REAL, &new, &old) < 0)
|
||||
return 0;
|
||||
return old.it_value.tv_sec;
|
||||
|
|
|
@ -25,7 +25,7 @@ int
|
|||
vexec (char const *file_name, va_list ap)
|
||||
{
|
||||
char *arg = va_arg (ap, char const *);
|
||||
char *argv[1000]; // POSIX minimum 4096
|
||||
char *argv[1000]; // POSIX minimum 4096
|
||||
int i = 0;
|
||||
|
||||
argv[i++] = file_name;
|
||||
|
@ -35,7 +35,11 @@ vexec (char const *file_name, va_list ap)
|
|||
arg = va_arg (ap, char const *);
|
||||
if (__mes_debug () > 2)
|
||||
{
|
||||
eputs ("arg["); eputs (itoa (i)); eputs ("]: "); eputs (argv[i-1]); eputs ("\n");
|
||||
eputs ("arg[");
|
||||
eputs (itoa (i));
|
||||
eputs ("]: ");
|
||||
eputs (argv[i - 1]);
|
||||
eputs ("\n");
|
||||
}
|
||||
}
|
||||
argv[i] = 0;
|
||||
|
@ -52,7 +56,9 @@ execl (char const *file_name, char const *arg, ...)
|
|||
va_start (ap, arg);
|
||||
if (__mes_debug () > 2)
|
||||
{
|
||||
eputs ("execl "); eputs (file_name); eputs ("\n");
|
||||
eputs ("execl ");
|
||||
eputs (file_name);
|
||||
eputs ("\n");
|
||||
}
|
||||
r = vexec (file_name, ap);
|
||||
va_end (ap);
|
||||
|
|
|
@ -31,7 +31,9 @@ execlp (char const *file_name, char const *arg, ...)
|
|||
file_name = search_path (file_name);
|
||||
if (__mes_debug () > 2)
|
||||
{
|
||||
eputs ("execlp "); eputs (file_name ? file_name : "0"); eputs ("\n");
|
||||
eputs ("execlp ");
|
||||
eputs (file_name ? file_name : "0");
|
||||
eputs ("\n");
|
||||
}
|
||||
if (!file_name)
|
||||
{
|
||||
|
|
|
@ -33,11 +33,17 @@ execvp (char const *file_name, char *const argv[])
|
|||
}
|
||||
if (__mes_debug ())
|
||||
{
|
||||
eputs (" EXEC: "); eputs (file_name); eputs ("\n");
|
||||
eputs (" EXEC: ");
|
||||
eputs (file_name);
|
||||
eputs ("\n");
|
||||
int i = 0;
|
||||
while (argv[i])
|
||||
{
|
||||
eputs (" arg["); eputs (itoa (i)); eputs ("]: "); eputs (argv[i]); eputs ("\n");
|
||||
eputs (" arg[");
|
||||
eputs (itoa (i));
|
||||
eputs ("]: ");
|
||||
eputs (argv[i]);
|
||||
eputs ("\n");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
char *
|
||||
getenv (char const* s)
|
||||
getenv (char const *s)
|
||||
{
|
||||
char **p = environ;
|
||||
int length = strlen (s);
|
||||
|
|
|
@ -58,8 +58,8 @@ static char *nextchar;
|
|||
for unrecognized options. */
|
||||
|
||||
int opterr = 1;
|
||||
|
||||
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
|
@ -68,8 +68,8 @@ int opterr = 1;
|
|||
|
||||
static int first_nonopt;
|
||||
static int last_nonopt;
|
||||
|
||||
|
||||
|
||||
/* Scan elements of ARGV (whose length is ARGC) for option characters
|
||||
given in OPTSTRING.
|
||||
|
||||
|
@ -127,7 +127,8 @@ static int last_nonopt;
|
|||
|
||||
int
|
||||
_getopt_internal (int argc, char *const
|
||||
*argv, char const *optstring, struct option const *longopts, int *longind, int long_only)
|
||||
*argv, char const *optstring, struct option const *longopts,
|
||||
int *longind, int long_only)
|
||||
{
|
||||
int option_index;
|
||||
|
||||
|
@ -148,33 +149,32 @@ _getopt_internal (int argc, char *const
|
|||
if (nextchar == NULL || *nextchar == '\0')
|
||||
{
|
||||
/* If we have done all the ARGV-elements, stop the scan
|
||||
and back over any non-options that we skipped and permuted. */
|
||||
and back over any non-options that we skipped and permuted. */
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
/* Set the next-arg-index to point at the non-options
|
||||
that we previously skipped, so the caller will digest them. */
|
||||
if (first_nonopt != last_nonopt)
|
||||
optind = first_nonopt;
|
||||
return EOF;
|
||||
}
|
||||
{
|
||||
/* Set the next-arg-index to point at the non-options
|
||||
that we previously skipped, so the caller will digest them. */
|
||||
if (first_nonopt != last_nonopt)
|
||||
optind = first_nonopt;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* If we have come to a non-option and did not permute it,
|
||||
either stop the scan or describe it to the caller and pass it by. */
|
||||
either stop the scan or describe it to the caller and pass it by. */
|
||||
|
||||
if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
|
||||
return EOF;
|
||||
|
||||
/* We have found another option-ARGV-element.
|
||||
Start decoding its characters. */
|
||||
Start decoding its characters. */
|
||||
|
||||
nextchar = (argv[optind] + 1
|
||||
+ (longopts != NULL && argv[optind][1] == '-'));
|
||||
+ (longopts != NULL && argv[optind][1] == '-'));
|
||||
}
|
||||
|
||||
if (longopts != NULL
|
||||
&& ((argv[optind][0] == '-'
|
||||
&& (argv[optind][1] == '-' || long_only))))
|
||||
&& ((argv[optind][0] == '-' && (argv[optind][1] == '-' || long_only))))
|
||||
{
|
||||
const struct option *p;
|
||||
char *s = nextchar;
|
||||
|
@ -184,116 +184,115 @@ _getopt_internal (int argc, char *const
|
|||
int indfound;
|
||||
|
||||
while (*s && *s != '=')
|
||||
s++;
|
||||
s++;
|
||||
|
||||
/* Test all options for either exact match or abbreviated matches. */
|
||||
for (p = longopts, option_index = 0; p->name;
|
||||
p++, option_index++)
|
||||
if (!strncmp (p->name, nextchar, s - nextchar))
|
||||
{
|
||||
if (s - nextchar == strlen (p->name))
|
||||
{
|
||||
/* Exact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
exact = 1;
|
||||
break;
|
||||
}
|
||||
else if (pfound == NULL)
|
||||
{
|
||||
/* First nonexact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else
|
||||
/* Second nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
for (p = longopts, option_index = 0; p->name; p++, option_index++)
|
||||
if (!strncmp (p->name, nextchar, s - nextchar))
|
||||
{
|
||||
if (s - nextchar == strlen (p->name))
|
||||
{
|
||||
/* Exact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
exact = 1;
|
||||
break;
|
||||
}
|
||||
else if (pfound == NULL)
|
||||
{
|
||||
/* First nonexact match found. */
|
||||
pfound = p;
|
||||
indfound = option_index;
|
||||
}
|
||||
else
|
||||
/* Second nonexact match found. */
|
||||
ambig = 1;
|
||||
}
|
||||
|
||||
if (ambig && !exact)
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `%s' is ambiguous\n",
|
||||
argv[0], argv[optind]);
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `%s' is ambiguous\n",
|
||||
argv[0], argv[optind]);
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
|
||||
if (pfound != NULL)
|
||||
{
|
||||
option_index = indfound;
|
||||
optind++;
|
||||
if (*s)
|
||||
{
|
||||
/* Don't test has_arg with >, because some C compilers don't
|
||||
allow it to be used on enums. */
|
||||
if (pfound->has_arg)
|
||||
optarg = s + 1;
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
"%s: option `--%s' doesn't allow an argument\n",
|
||||
argv[0], pfound->name);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
"%s: option `%c%s' doesn't allow an argument\n",
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
else if (pfound->has_arg == 1)
|
||||
{
|
||||
if (optind < argc)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `%s' requires an argument\n",
|
||||
argv[0], argv[optind - 1]);
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
if (longind != NULL)
|
||||
*longind = option_index;
|
||||
if (pfound->flag)
|
||||
{
|
||||
*(pfound->flag) = pfound->val;
|
||||
return 0;
|
||||
}
|
||||
return pfound->val;
|
||||
}
|
||||
{
|
||||
option_index = indfound;
|
||||
optind++;
|
||||
if (*s)
|
||||
{
|
||||
/* Don't test has_arg with >, because some C compilers don't
|
||||
allow it to be used on enums. */
|
||||
if (pfound->has_arg)
|
||||
optarg = s + 1;
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind - 1][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr,
|
||||
"%s: option `--%s' doesn't allow an argument\n",
|
||||
argv[0], pfound->name);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr,
|
||||
"%s: option `%c%s' doesn't allow an argument\n",
|
||||
argv[0], argv[optind - 1][0], pfound->name);
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
else if (pfound->has_arg == 1)
|
||||
{
|
||||
if (optind < argc)
|
||||
optarg = argv[optind++];
|
||||
else
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `%s' requires an argument\n",
|
||||
argv[0], argv[optind - 1]);
|
||||
nextchar += strlen (nextchar);
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
if (longind != NULL)
|
||||
*longind = option_index;
|
||||
if (pfound->flag)
|
||||
{
|
||||
*(pfound->flag) = pfound->val;
|
||||
return 0;
|
||||
}
|
||||
return pfound->val;
|
||||
}
|
||||
/* Can't find it as a long option. If this is not getopt_long_only,
|
||||
or the option starts with '--' or is not a valid short
|
||||
option, then it's an error.
|
||||
Otherwise interpret it as a short option. */
|
||||
or the option starts with '--' or is not a valid short
|
||||
option, then it's an error.
|
||||
Otherwise interpret it as a short option. */
|
||||
if (!long_only || argv[optind][1] == '-'
|
||||
|| strchr (optstring, *nextchar) == NULL)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr, "%s: unrecognized option `--%s'\n",
|
||||
argv[0], nextchar);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
|
||||
argv[0], argv[optind][0], nextchar);
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
|| strchr (optstring, *nextchar) == NULL)
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (argv[optind][1] == '-')
|
||||
/* --option */
|
||||
fprintf (stderr, "%s: unrecognized option `--%s'\n",
|
||||
argv[0], nextchar);
|
||||
else
|
||||
/* +option or -option */
|
||||
fprintf (stderr, "%s: unrecognized option `%c%s'\n",
|
||||
argv[0], argv[optind][0], nextchar);
|
||||
}
|
||||
nextchar += strlen (nextchar);
|
||||
optind++;
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
/* Look at and handle the next option-character. */
|
||||
|
@ -308,53 +307,54 @@ _getopt_internal (int argc, char *const
|
|||
|
||||
if (temp == NULL || c == ':')
|
||||
{
|
||||
if (opterr)
|
||||
{
|
||||
if (c < 040 || c >= 0177)
|
||||
fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
|
||||
argv[0], c);
|
||||
else
|
||||
fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
|
||||
}
|
||||
return '?';
|
||||
if (opterr)
|
||||
{
|
||||
if (c < 040 || c >= 0177)
|
||||
fprintf (stderr,
|
||||
"%s: unrecognized option, character code 0%o\n",
|
||||
argv[0], c);
|
||||
else
|
||||
fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
|
||||
}
|
||||
return '?';
|
||||
}
|
||||
if (temp[1] == ':')
|
||||
{
|
||||
if (temp[2] == ':')
|
||||
{
|
||||
/* This is an option that accepts an argument optionally. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
optarg = 0;
|
||||
nextchar = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an option that requires an argument. */
|
||||
if (*nextchar != 0)
|
||||
{
|
||||
optarg = nextchar;
|
||||
/* If we end this ARGV-element by taking the rest as an arg,
|
||||
we must advance to the next element now. */
|
||||
optind++;
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `-%c' requires an argument\n",
|
||||
argv[0], c);
|
||||
c = '?';
|
||||
}
|
||||
else
|
||||
/* We already incremented `optind' once;
|
||||
increment it again when taking next ARGV-elt as argument. */
|
||||
optarg = argv[optind++];
|
||||
nextchar = NULL;
|
||||
}
|
||||
if (temp[2] == ':')
|
||||
{
|
||||
/* This is an option that accepts an argument optionally. */
|
||||
if (*nextchar != '\0')
|
||||
{
|
||||
optarg = nextchar;
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
optarg = 0;
|
||||
nextchar = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an option that requires an argument. */
|
||||
if (*nextchar != 0)
|
||||
{
|
||||
optarg = nextchar;
|
||||
/* If we end this ARGV-element by taking the rest as an arg,
|
||||
we must advance to the next element now. */
|
||||
optind++;
|
||||
}
|
||||
else if (optind == argc)
|
||||
{
|
||||
if (opterr)
|
||||
fprintf (stderr, "%s: option `-%c' requires an argument\n",
|
||||
argv[0], c);
|
||||
c = '?';
|
||||
}
|
||||
else
|
||||
/* We already incremented `optind' once;
|
||||
increment it again when taking next ARGV-elt as argument. */
|
||||
optarg = argv[optind++];
|
||||
nextchar = NULL;
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ int
|
|||
getopt (int argc, char *const *argv, char const *options)
|
||||
{
|
||||
return _getopt_internal (argc, argv, options,
|
||||
(const struct option *) 0, (int *) 0, 0);
|
||||
(const struct option *)0, (int *)0, 0);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
setenv (char const* s, char const* v, int overwrite_p)
|
||||
setenv (char const *s, char const *v, int overwrite_p)
|
||||
{
|
||||
char **p = environ;
|
||||
int length = strlen (s);
|
||||
|
|
|
@ -23,5 +23,5 @@
|
|||
pid_t
|
||||
wait (int *status_ptr)
|
||||
{
|
||||
return waitpid (-1, status_ptr, 0);
|
||||
return waitpid (-1, status_ptr, 0);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void
|
||||
clearerr (FILE *stream)
|
||||
clearerr (FILE * stream)
|
||||
{
|
||||
errno = 0;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fclose (FILE *stream)
|
||||
fclose (FILE * stream)
|
||||
{
|
||||
int fd = (int)stream;
|
||||
return close (fd);
|
||||
|
|
|
@ -23,5 +23,5 @@
|
|||
FILE *
|
||||
fdopen (int fd, char const *mode)
|
||||
{
|
||||
return (FILE*)fd;
|
||||
return (FILE *) fd;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
feof (FILE *stream)
|
||||
feof (FILE * stream)
|
||||
{
|
||||
char c = fgetc (stream);
|
||||
if (c != EOF)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
ferror (FILE *stream)
|
||||
ferror (FILE * stream)
|
||||
{
|
||||
int fd = (int)stream;
|
||||
if (fd == -1)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fflush (FILE *stream)
|
||||
fflush (FILE * stream)
|
||||
{
|
||||
int filedes = (int)stream;
|
||||
if (filedes < 3)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fgetc (FILE *stream)
|
||||
fgetc (FILE * stream)
|
||||
{
|
||||
return fdgetc ((long)stream);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
char *
|
||||
fgets (char *s, int count, FILE *stream)
|
||||
fgets (char *s, int count, FILE * stream)
|
||||
{
|
||||
return fdgets (s, count, (int)stream);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fileno (FILE *stream)
|
||||
fileno (FILE * stream)
|
||||
{
|
||||
return (int)stream;
|
||||
}
|
||||
|
|
|
@ -28,13 +28,16 @@
|
|||
#define open _open3
|
||||
#endif
|
||||
|
||||
FILE*
|
||||
FILE *
|
||||
fopen (char const *file_name, char const *opentype)
|
||||
{
|
||||
if (__mes_debug ())
|
||||
{
|
||||
eputs ("fopen "); eputs (file_name);
|
||||
eputs (" "); eputs (opentype); eputs ("\n");
|
||||
eputs ("fopen ");
|
||||
eputs (file_name);
|
||||
eputs (" ");
|
||||
eputs (opentype);
|
||||
eputs ("\n");
|
||||
}
|
||||
|
||||
int fd;
|
||||
|
@ -47,7 +50,8 @@ fopen (char const *file_name, char const *opentype)
|
|||
flags |= O_APPEND;
|
||||
fd = open (file_name, flags, mode);
|
||||
}
|
||||
else if (opentype[0] == 'w' || opentype[0] == 'a' || !strcmp (opentype, "r+"))
|
||||
else if (opentype[0] == 'w' || opentype[0] == 'a'
|
||||
|| !strcmp (opentype, "r+"))
|
||||
{
|
||||
char *plus_p = strchr (opentype, '+');
|
||||
int flags = plus_p ? O_RDWR | O_CREAT : O_WRONLY | O_CREAT | O_TRUNC;
|
||||
|
@ -58,7 +62,9 @@ fopen (char const *file_name, char const *opentype)
|
|||
|
||||
if (__mes_debug ())
|
||||
{
|
||||
eputs (" => fd="); eputs (itoa (fd)); eputs ("\n");
|
||||
eputs (" => fd=");
|
||||
eputs (itoa (fd));
|
||||
eputs ("\n");
|
||||
}
|
||||
|
||||
if (!fd)
|
||||
|
@ -68,7 +74,7 @@ fopen (char const *file_name, char const *opentype)
|
|||
}
|
||||
if (fd < 0)
|
||||
fd = 0;
|
||||
return (FILE*)fd;
|
||||
return (FILE *) fd;
|
||||
}
|
||||
|
||||
#undef open
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fprintf (FILE *stream, char const *format, ...)
|
||||
fprintf (FILE * stream, char const *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, format);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fputc (int c, FILE* stream)
|
||||
fputc (int c, FILE * stream)
|
||||
{
|
||||
return fdputc (c, (int)stream);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fputs (char const* s, FILE* stream)
|
||||
fputs (char const *s, FILE * stream)
|
||||
{
|
||||
return fdputs (s, (long)stream);
|
||||
}
|
||||
|
|
|
@ -22,19 +22,19 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
_fungetc_p (FILE *stream)
|
||||
_fungetc_p (FILE * stream)
|
||||
{
|
||||
return _fdungetc_p ((int)stream);
|
||||
}
|
||||
|
||||
size_t
|
||||
fread (void *data, size_t size, size_t count, FILE *stream)
|
||||
fread (void *data, size_t size, size_t count, FILE * stream)
|
||||
{
|
||||
if (! size || !count)
|
||||
if (!size || !count)
|
||||
return 0;
|
||||
|
||||
size_t todo = size * count;
|
||||
char *buf = (char*)data;
|
||||
char *buf = (char *)data;
|
||||
|
||||
int bytes = 0;
|
||||
while (_fungetc_p (stream) && todo-- && ++bytes)
|
||||
|
@ -50,19 +50,24 @@ fread (void *data, size_t size, size_t count, FILE *stream)
|
|||
|
||||
if (__mes_debug ())
|
||||
{
|
||||
eputs ("fread fd="); eputs (itoa ((int)stream));
|
||||
eputs (" bytes="); eputs (itoa (bytes)); eputs ("\n");
|
||||
eputs ("fread fd=");
|
||||
eputs (itoa ((int)stream));
|
||||
eputs (" bytes=");
|
||||
eputs (itoa (bytes));
|
||||
eputs ("\n");
|
||||
static char buf[4096];
|
||||
if (bytes > 0 && bytes < sizeof (buf))
|
||||
{
|
||||
strncpy (buf, data, bytes);
|
||||
buf[bytes] = 0;
|
||||
eputs ("fread buf="); eputs (buf); eputs ("\n");
|
||||
eputs ("fread buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (bytes > 0)
|
||||
return bytes/size;
|
||||
return bytes / size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
FILE *
|
||||
freopen (char const *file_name, char const *opentype, FILE *stream)
|
||||
freopen (char const *file_name, char const *opentype, FILE * stream)
|
||||
{
|
||||
fclose (stream);
|
||||
return fopen (file_name, opentype);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
FILE *
|
||||
freopen (char const *file_name, char const *opentype, FILE *stream)
|
||||
freopen (char const *file_name, char const *opentype, FILE * stream)
|
||||
{
|
||||
fclose (stream);
|
||||
return fopen (file_name, opentype);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fscanf (FILE *stream, char const *template, ...)
|
||||
fscanf (FILE * stream, char const *template, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, template);
|
||||
|
|
|
@ -22,13 +22,16 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
fseek (FILE *stream, long offset, int whence)
|
||||
fseek (FILE * stream, long offset, int whence)
|
||||
{
|
||||
off_t pos = lseek ((int)stream, offset, whence);
|
||||
if (__mes_debug ())
|
||||
{
|
||||
eputs ("fread fd="); eputs (itoa ((int)stream));
|
||||
eputs (" =>"); eputs (itoa (pos)); eputs ("\n");
|
||||
eputs ("fread fd=");
|
||||
eputs (itoa ((int)stream));
|
||||
eputs (" =>");
|
||||
eputs (itoa (pos));
|
||||
eputs ("\n");
|
||||
}
|
||||
if (pos >= 0)
|
||||
return 0;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
long
|
||||
ftell (FILE *stream)
|
||||
ftell (FILE * stream)
|
||||
{
|
||||
return lseek ((int)stream, 0, SEEK_CUR);
|
||||
}
|
||||
|
|
|
@ -22,24 +22,29 @@
|
|||
#include <stdio.h>
|
||||
|
||||
size_t
|
||||
fwrite (void const *data, size_t size, size_t count, FILE *stream)
|
||||
fwrite (void const *data, size_t size, size_t count, FILE * stream)
|
||||
{
|
||||
if (__mes_debug () > 1)
|
||||
{
|
||||
eputs ("fwrite "); eputs (itoa ((int)stream));
|
||||
eputs (" "); eputs (itoa (size)); eputs ("\n");
|
||||
eputs ("fwrite ");
|
||||
eputs (itoa ((int)stream));
|
||||
eputs (" ");
|
||||
eputs (itoa (size));
|
||||
eputs ("\n");
|
||||
}
|
||||
|
||||
if (! size || !count)
|
||||
if (!size || !count)
|
||||
return 0;
|
||||
int bytes = write ((int)stream, data, size * count);
|
||||
|
||||
if (__mes_debug () > 2)
|
||||
{
|
||||
eputs (" => "); eputs (itoa (bytes)); eputs ("\n");
|
||||
eputs (" => ");
|
||||
eputs (itoa (bytes));
|
||||
eputs ("\n");
|
||||
}
|
||||
|
||||
if (bytes > 0)
|
||||
return bytes/size;
|
||||
return bytes / size;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
getc (FILE *stream)
|
||||
getc (FILE * stream)
|
||||
{
|
||||
return fdgetc ((long)stream);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
printf (char const* format, ...)
|
||||
printf (char const *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int r;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
putc (int c, FILE* stream)
|
||||
putc (int c, FILE * stream)
|
||||
{
|
||||
return fdputc (c, (long)stream);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@
|
|||
int
|
||||
putchar (int c)
|
||||
{
|
||||
write (STDOUT, (char*)&c, 1);
|
||||
write (STDOUT, (char *)&c, 1);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void
|
||||
rewind (FILE *stream)
|
||||
rewind (FILE * stream)
|
||||
{
|
||||
fseek (stream, 0, SEEK_SET);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
snprintf (char *str, size_t size, char const *format, ...)
|
||||
snprintf (char *str, size_t size, char const *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int r;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
sprintf (char *str, char const* format, ...)
|
||||
sprintf (char *str, char const *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int r;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
ungetc (int c, FILE *stream)
|
||||
ungetc (int c, FILE * stream)
|
||||
{
|
||||
return fdungetc (c, (long)stream);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <string.h>
|
||||
|
||||
int
|
||||
vfprintf (FILE* f, char const* format, va_list ap)
|
||||
vfprintf (FILE * f, char const *format, va_list ap)
|
||||
{
|
||||
int fd = (long)f;
|
||||
char const *p = format;
|
||||
|
@ -118,9 +118,7 @@ vfprintf (FILE* f, char const* format, va_list ap)
|
|||
case 'X':
|
||||
{
|
||||
long d = va_arg (ap, long);
|
||||
int base = c == 'o' ? 8
|
||||
: c == 'x' || c == 'X' ? 16
|
||||
: 10;
|
||||
int base = c == 'o' ? 8 : c == 'x' || c == 'X' ? 16 : 10;
|
||||
char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X');
|
||||
if (c == 'X')
|
||||
strupr (s);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
vfscanf (FILE *stream, char const *template, va_list ap)
|
||||
vfscanf (FILE * stream, char const *template, va_list ap)
|
||||
{
|
||||
char r = fgetc (stream);
|
||||
char const *t = template;
|
||||
|
@ -61,7 +61,7 @@ vfscanf (FILE *stream, char const *template, va_list ap)
|
|||
r = fgetc (stream);
|
||||
if (!skip_p)
|
||||
{
|
||||
char *c = va_arg (ap, char*);
|
||||
char *c = va_arg (ap, char *);
|
||||
*c = r;
|
||||
count++;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ vfscanf (FILE *stream, char const *template, va_list ap)
|
|||
case 'i':
|
||||
case 'u':
|
||||
{
|
||||
int *d = skip_p ? 0 : va_arg (ap, int*);
|
||||
int *d = skip_p ? 0 : va_arg (ap, int *);
|
||||
char buf[20];
|
||||
char *q = buf;
|
||||
if (r == '+' || r == '-')
|
||||
|
@ -102,7 +102,7 @@ vfscanf (FILE *stream, char const *template, va_list ap)
|
|||
case 'E':
|
||||
case 'G':
|
||||
{
|
||||
float *f = skip_p ? 0 : va_arg (ap, float*);
|
||||
float *f = skip_p ? 0 : va_arg (ap, float *);
|
||||
char buf[20];
|
||||
char *q = buf;
|
||||
if (r == '+' || r == '-')
|
||||
|
@ -129,7 +129,7 @@ vfscanf (FILE *stream, char const *template, va_list ap)
|
|||
}
|
||||
case 's':
|
||||
{
|
||||
char *s = skip_p ? 0 : va_arg (ap, char*);
|
||||
char *s = skip_p ? 0 : va_arg (ap, char *);
|
||||
while (r && !isspace (r) && (length == -1 || length--))
|
||||
{
|
||||
if (!skip_p)
|
||||
|
@ -145,7 +145,7 @@ vfscanf (FILE *stream, char const *template, va_list ap)
|
|||
}
|
||||
case '[':
|
||||
{
|
||||
char *s = skip_p ? 0 : va_arg (ap, char*);
|
||||
char *s = skip_p ? 0 : va_arg (ap, char *);
|
||||
char set[1024];
|
||||
int i = 0;
|
||||
int not_in_set_p = 0;
|
||||
|
@ -162,7 +162,7 @@ vfscanf (FILE *stream, char const *template, va_list ap)
|
|||
if (*t == '-')
|
||||
{
|
||||
char end = *t++;
|
||||
for (char x=set[i-1] + 1; x < end; x++)
|
||||
for (char x = set[i - 1] + 1; x < end; x++)
|
||||
set[i++] = x;
|
||||
}
|
||||
else
|
||||
|
@ -180,11 +180,11 @@ vfscanf (FILE *stream, char const *template, va_list ap)
|
|||
*s++ = r;
|
||||
r = fgetc (stream);
|
||||
}
|
||||
if (!skip_p)
|
||||
{
|
||||
count++;
|
||||
*s = 0;
|
||||
}
|
||||
if (!skip_p)
|
||||
{
|
||||
count++;
|
||||
*s = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int
|
||||
vprintf (char const* format, va_list ap)
|
||||
vprintf (char const *format, va_list ap)
|
||||
{
|
||||
return vfprintf (stdout, format, ap);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <string.h>
|
||||
|
||||
int
|
||||
vsnprintf (char *str, size_t size, char const* format, va_list ap)
|
||||
vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
||||
{
|
||||
char const *p = format;
|
||||
int count = 0;
|
||||
|
@ -123,9 +123,7 @@ vsnprintf (char *str, size_t size, char const* format, va_list ap)
|
|||
case 'X':
|
||||
{
|
||||
long d = va_arg (ap, long);
|
||||
int base = c == 'o' ? 8
|
||||
: c == 'x' || c == 'X' ? 16
|
||||
: 10;
|
||||
int base = c == 'o' ? 8 : c == 'x' || c == 'X' ? 16 : 10;
|
||||
char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X');
|
||||
if (c == 'X')
|
||||
strupr (s);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
vsprintf (char *str, char const* format, va_list ap)
|
||||
vsprintf (char *str, char const *format, va_list ap)
|
||||
{
|
||||
return vsnprintf (str, LONG_MAX, format, ap);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue