mescc: Support binutils-2.30: fopen fix.

* lib/libc+tcc.c (fopen): Set O_APPEND for 'a'.
This commit is contained in:
Jan Nieuwenhuizen 2018-06-10 13:33:30 +02:00
parent c349f6fdd8
commit 18194b1ae4
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -210,9 +210,10 @@ fopen (char const *file_name, char const *opentype)
if ((opentype[0] == 'a' || !strcmp (opentype, "r+")) if ((opentype[0] == 'a' || !strcmp (opentype, "r+"))
&& !access (file_name, O_RDONLY)) && !access (file_name, O_RDONLY))
{ {
fd = open (file_name, O_RDWR, mode); int flags = O_RDWR;
if (opentype[0] == 'a') if (opentype[0] == 'a')
lseek (fd, 0, SEEK_END); 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+"))
{ {