mirror of
https://github.com/cc65/cc65.git
synced 2025-01-08 20:31:31 +00:00
Fix open flags, minor optimization
git-svn-id: svn://svn.cc65.org/cc65/trunk@1526 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
fc81b379d8
commit
a3c8336725
@ -15,14 +15,11 @@
|
||||
static unsigned char amode_to_bmode (const char* mode)
|
||||
/* Convert ASCII mode (like for fopen) to binary mode (for open) */
|
||||
{
|
||||
char c;
|
||||
char flag = 0;
|
||||
unsigned char binmode = 0;
|
||||
unsigned char binmode;
|
||||
|
||||
c = *mode++;
|
||||
switch(c) {
|
||||
switch (*mode++) {
|
||||
case 'w':
|
||||
binmode = O_WRONLY;
|
||||
binmode = O_WRONLY | O_CREAT | O_TRUNC;
|
||||
break;
|
||||
case 'r':
|
||||
binmode = O_RDONLY;
|
||||
@ -34,19 +31,23 @@ static unsigned char amode_to_bmode (const char* mode)
|
||||
return 0; /* invalid char */
|
||||
}
|
||||
|
||||
while (c = *mode++) {
|
||||
switch(c) {
|
||||
while (1) {
|
||||
switch (*mode++) {
|
||||
case '+':
|
||||
binmode = (binmode & ~15) | O_RDWR;
|
||||
/* always to r/w in addition to anything already set */
|
||||
binmode |= O_RDWR;
|
||||
break;
|
||||
case 'b':
|
||||
/* currently ignored */
|
||||
break;
|
||||
case '\0':
|
||||
/* end of mode string reached */
|
||||
return binmode;
|
||||
default:
|
||||
return 0; /* invalid char */
|
||||
/* invalid char in mode string */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return binmode;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user