From 13e14a6bfd9f29cbfeab0c5161d2a994f97532e7 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 26 Mar 2026 12:53:53 +0100 Subject: Update/gnulib 2026 03 (#2247) * Sync with the 202601-stable Gnulib code (4a3650d887) * Ignore more deps stuff in gnulib * Remove autogenerated gnulib files * Ignore more gnulib generated headers --- gl/fopen.c | 47 +++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) (limited to 'gl/fopen.c') diff --git a/gl/fopen.c b/gl/fopen.c index 41587d2c..93710ad0 100644 --- a/gl/fopen.c +++ b/gl/fopen.c @@ -1,5 +1,5 @@ /* Open a stream to a file. - Copyright (C) 2007-2025 Free Software Foundation, Inc. + Copyright (C) 2007-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -33,13 +33,7 @@ orig_fopen (const char *filename, const char *mode) } /* Specification. */ -#ifdef __osf__ -/* Write "stdio.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates - this include because of the preliminary #include above. */ -# include "stdio.h" -#else -# include -#endif +#include #include #include @@ -51,24 +45,18 @@ orig_fopen (const char *filename, const char *mode) FILE * rpl_fopen (const char *filename, const char *mode) { - int open_direction; - int open_flags; -#if GNULIB_FOPEN_GNU - bool open_flags_gnu; -# define BUF_SIZE 80 - char fdopen_mode_buf[BUF_SIZE + 1]; -#endif - #if defined _WIN32 && ! defined __CYGWIN__ - if (strcmp (filename, "/dev/null") == 0) + if (streq (filename, "/dev/null")) filename = "NUL"; #endif /* Parse the mode. */ - open_direction = 0; - open_flags = 0; + int open_direction = 0; + int open_flags = 0; #if GNULIB_FOPEN_GNU - open_flags_gnu = false; + bool open_flags_gnu = false; +# define BUF_SIZE 80 + char fdopen_mode_buf[BUF_SIZE + 1]; #endif { const char *p = mode; @@ -169,21 +157,18 @@ rpl_fopen (const char *filename, const char *mode) size_t len = strlen (filename); if (len > 0 && filename[len - 1] == '/') { - int fd; - struct stat statbuf; - FILE *fp; - if (open_direction != O_RDONLY) { errno = EISDIR; return NULL; } - fd = open (filename, open_direction | open_flags, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + int fd = open (filename, open_direction | open_flags, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (fd < 0) return NULL; + struct stat statbuf; if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) { close (fd); @@ -191,6 +176,7 @@ rpl_fopen (const char *filename, const char *mode) return NULL; } + FILE *fp; # if GNULIB_FOPEN_GNU fp = fdopen (fd, fdopen_mode_buf); # else @@ -210,15 +196,12 @@ rpl_fopen (const char *filename, const char *mode) #if GNULIB_FOPEN_GNU if (open_flags_gnu) { - int fd; - FILE *fp; - - fd = open (filename, open_direction | open_flags, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + int fd = open (filename, open_direction | open_flags, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (fd < 0) return NULL; - fp = fdopen (fd, fdopen_mode_buf); + FILE *fp = fdopen (fd, fdopen_mode_buf); if (fp == NULL) { int saved_errno = errno; -- cgit v1.2.3-74-g34f1