use of "t" (text) flag for fopen in X.Org

Matthieu Herrb matthieu at herrb.eu
Wed Aug 27 01:02:40 PDT 2014


Hi,

one of the OpenBSD developpers recently tried to add some consistency
checks on the "mode" argument to fopen(3), based on the ISO C and
POSIX standards. Thus his code rejects the "t" flag. 

In the whole X.Org code base it seems to be used inconsistently. Only
libXfont seems to set this flag unconditionnally.

If windows libs can support read Unix text files whitout this flag,
the patch below could be applied, and moreover we should set a policy
somewhere in the developers' wiki to tell to never add it. or if it's
needed to decide if it should be added for all text files
unconditionnally or inside some CPP conditionals for the system(s) that
need it.

>From 81f4ba7ba72c08077bc3a0618e7b0e4eb533c9e6 Mon Sep 17 00:00:00 2001
From: Matthieu Herrb <matthieu at herrb.eu>
Date: Wed, 27 Aug 2014 09:44:03 +0200
Subject: [patch libXfont] Remove "t" flag from fopen() calls.

This is the only place in the whole X.Org set of packages where this
flag is used, leading us to think it's not useful here either.

OpenBSD is considering adding some more sanity checks on fopen mode
argument and this "t" causes the new code to fail fopen().
---
 src/fontfile/dirfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git src/fontfile/dirfile.c src/fontfile/dirfile.c
index 38ced75..0fc6745 100644
--- src/fontfile/dirfile.c
+++ src/fontfile/dirfile.c
@@ -91,7 +91,7 @@ FontFileReadDirectory (const char *directory, FontDirectoryPtr *pdir)
     if (dir_file[strlen(dir_file) - 1] != '/')
 	strcat(dir_file, "/");
     strcat(dir_file, FontDirFile);
-    file = fopen(dir_file, "rt");
+    file = fopen(dir_file, "r");
     if (file) {
 #ifndef WIN32
 	if (fstat (fileno(file), &statb) == -1)
@@ -279,7 +279,7 @@ ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir)
 	    strcat(alias_file, "/");
 	strcat(alias_file, FontAliasFile);
     }
-    file = fopen(alias_file, "rt");
+    file = fopen(alias_file, "r");
     if (!file)
 	return ((errno == ENOENT) ? Successful : BadFontPath);
     if (!dir)
-- 
1.9.3


-- 
Matthieu Herrb


More information about the xorg-devel mailing list