mescc: Support binutils-2.10.1: opentype `r+'.

* lib/libc+tcc.c (fopen): Support opentype `r+'.
This commit is contained in:
Jan Nieuwenhuizen 2018-06-10 07:51:10 +02:00
parent 831bd71a14
commit 3ba5b23dab
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -189,12 +189,14 @@ fopen (char const *file_name, char const *opentype)
{
int fd;
int mode = 0600;
if (opentype[0] == 'a' && !access (file_name, O_RDONLY))
if ((opentype[0] == 'a' || !strcmp (opentype, "r+"))
&& !access (file_name, O_RDONLY))
{
fd = open (file_name, O_RDWR, mode);
lseek (fd, 0, SEEK_END);
if (opentype[0] == 'a')
lseek (fd, 0, SEEK_END);
}
else if (opentype[0] == 'w' || opentype[0] == 'a')
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;