| OLD | NEW |
| 1 #include <fcntl.h> | 1 #include <fcntl.h> |
| 2 #include <string.h> | 2 #include <string.h> |
| 3 | 3 |
| 4 int __fmodeflags(const char *mode) | 4 int __fmodeflags(const char* mode) { |
| 5 { | 5 int flags; |
| 6 » int flags; | 6 if (strchr(mode, '+')) |
| 7 » if (strchr(mode, '+')) flags = O_RDWR; | 7 flags = O_RDWR; |
| 8 » else if (*mode == 'r') flags = O_RDONLY; | 8 else if (*mode == 'r') |
| 9 » else flags = O_WRONLY; | 9 flags = O_RDONLY; |
| 10 » if (strchr(mode, 'x')) flags |= O_EXCL; | 10 else |
| 11 » if (strchr(mode, 'e')) flags |= O_CLOEXEC; | 11 flags = O_WRONLY; |
| 12 » if (*mode != 'r') flags |= O_CREAT; | 12 if (strchr(mode, 'x')) |
| 13 » if (*mode == 'w') flags |= O_TRUNC; | 13 flags |= O_EXCL; |
| 14 » if (*mode == 'a') flags |= O_APPEND; | 14 if (strchr(mode, 'e')) |
| 15 » return flags; | 15 flags |= O_CLOEXEC; |
| 16 if (*mode != 'r') |
| 17 flags |= O_CREAT; |
| 18 if (*mode == 'w') |
| 19 flags |= O_TRUNC; |
| 20 if (*mode == 'a') |
| 21 flags |= O_APPEND; |
| 22 return flags; |
| 16 } | 23 } |
| OLD | NEW |