am ebf37e38: Merge "Switch to OpenBSD flags.c."
				
					
				
			* commit 'ebf37e38861e376ae47c72d45ab8de6703dd18f0': Switch to OpenBSD flags.c.
This commit is contained in:
		@@ -241,7 +241,6 @@ libc_upstream_freebsd_src_files := \
 | 
				
			|||||||
    upstream-freebsd/lib/libc/gen/sleep.c \
 | 
					    upstream-freebsd/lib/libc/gen/sleep.c \
 | 
				
			||||||
    upstream-freebsd/lib/libc/gen/usleep.c \
 | 
					    upstream-freebsd/lib/libc/gen/usleep.c \
 | 
				
			||||||
    upstream-freebsd/lib/libc/stdio/fclose.c \
 | 
					    upstream-freebsd/lib/libc/stdio/fclose.c \
 | 
				
			||||||
    upstream-freebsd/lib/libc/stdio/flags.c \
 | 
					 | 
				
			||||||
    upstream-freebsd/lib/libc/stdio/fopen.c \
 | 
					    upstream-freebsd/lib/libc/stdio/fopen.c \
 | 
				
			||||||
    upstream-freebsd/lib/libc/stdlib/abs.c \
 | 
					    upstream-freebsd/lib/libc/stdlib/abs.c \
 | 
				
			||||||
    upstream-freebsd/lib/libc/stdlib/getopt_long.c \
 | 
					    upstream-freebsd/lib/libc/stdlib/getopt_long.c \
 | 
				
			||||||
@@ -399,6 +398,7 @@ libc_upstream_openbsd_src_files := \
 | 
				
			|||||||
    upstream-openbsd/lib/libc/stdio/fgetws.c \
 | 
					    upstream-openbsd/lib/libc/stdio/fgetws.c \
 | 
				
			||||||
    upstream-openbsd/lib/libc/stdio/fileno.c \
 | 
					    upstream-openbsd/lib/libc/stdio/fileno.c \
 | 
				
			||||||
    upstream-openbsd/lib/libc/stdio/findfp.c \
 | 
					    upstream-openbsd/lib/libc/stdio/findfp.c \
 | 
				
			||||||
 | 
					    upstream-openbsd/lib/libc/stdio/flags.c \
 | 
				
			||||||
    upstream-openbsd/lib/libc/stdio/fmemopen.c \
 | 
					    upstream-openbsd/lib/libc/stdio/fmemopen.c \
 | 
				
			||||||
    upstream-openbsd/lib/libc/stdio/fprintf.c \
 | 
					    upstream-openbsd/lib/libc/stdio/fprintf.c \
 | 
				
			||||||
    upstream-openbsd/lib/libc/stdio/fpurge.c \
 | 
					    upstream-openbsd/lib/libc/stdio/fpurge.c \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					/*	$OpenBSD: flags.c,v 1.8 2014/08/31 02:21:18 guenther Exp $ */
 | 
				
			||||||
/*-
 | 
					/*-
 | 
				
			||||||
 * Copyright (c) 1990, 1993
 | 
					 * Copyright (c) 1990, 1993
 | 
				
			||||||
 *	The Regents of the University of California.  All rights reserved.
 | 
					 *	The Regents of the University of California.  All rights reserved.
 | 
				
			||||||
@@ -30,22 +31,15 @@
 | 
				
			|||||||
 * SUCH DAMAGE.
 | 
					 * SUCH DAMAGE.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(LIBC_SCCS) && !defined(lint)
 | 
					 | 
				
			||||||
static char sccsid[] = "@(#)flags.c	8.1 (Berkeley) 6/4/93";
 | 
					 | 
				
			||||||
#endif /* LIBC_SCCS and not lint */
 | 
					 | 
				
			||||||
#include <sys/cdefs.h>
 | 
					 | 
				
			||||||
__FBSDID("$FreeBSD$");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
#include <sys/file.h>
 | 
					#include <sys/file.h>
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "local.h"
 | 
					#include "local.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Return the (stdio) flags for a given mode.  Store the flags
 | 
					 * Return the (stdio) flags for a given mode.  Store the flags
 | 
				
			||||||
 * to be passed to an _open() syscall through *optr.
 | 
					 * to be passed to an open() syscall through *optr.
 | 
				
			||||||
 * Return 0 on error.
 | 
					 * Return 0 on error.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
@@ -78,34 +72,33 @@ __sflags(const char *mode, int *optr)
 | 
				
			|||||||
		return (0);
 | 
							return (0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* 'b' (binary) is ignored */
 | 
						while (*mode != '\0') 
 | 
				
			||||||
	if (*mode == 'b')
 | 
							switch (*mode++) {
 | 
				
			||||||
		mode++;
 | 
							case 'b':
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
	/* [rwa][b]\+ means read and write */
 | 
							case '+':
 | 
				
			||||||
	if (*mode == '+') {
 | 
								ret = __SRW;
 | 
				
			||||||
		mode++;
 | 
								m = O_RDWR;
 | 
				
			||||||
		ret = __SRW;
 | 
								break;
 | 
				
			||||||
		m = O_RDWR;
 | 
							case 'e':
 | 
				
			||||||
	}
 | 
								o |= O_CLOEXEC;
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
	/* 'b' (binary) can appear here, too -- and is ignored again */
 | 
							case 'x':
 | 
				
			||||||
	if (*mode == 'b')
 | 
								if (o & O_CREAT)
 | 
				
			||||||
		mode++;
 | 
									o |= O_EXCL;
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
	/* 'x' means exclusive (fail if the file exists) */
 | 
							default:
 | 
				
			||||||
	if (*mode == 'x') {
 | 
								/*
 | 
				
			||||||
		mode++;
 | 
								 * Lots of software passes other extension mode
 | 
				
			||||||
		if (m == O_RDONLY) {
 | 
								 * letters, like Window's 't'
 | 
				
			||||||
 | 
								 */
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
			errno = EINVAL;
 | 
								errno = EINVAL;
 | 
				
			||||||
			return (0);
 | 
								return (0);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		o |= O_EXCL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* set close-on-exec */
 | 
					 | 
				
			||||||
	if (*mode == 'e')
 | 
					 | 
				
			||||||
		o |= O_CLOEXEC;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*optr = m | o;
 | 
						*optr = m | o;
 | 
				
			||||||
	return (ret);
 | 
						return (ret);
 | 
				
			||||||
		Reference in New Issue
	
	Block a user