summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2009-05-07 16:59:59 -0400
committerAdam Jackson <ajax@redhat.com>2009-05-07 16:59:59 -0400
commit29f27b16dbe511a27a0e953b32913f9d9bf24f2d (patch)
treea0de32c1e117a7cd157b458fbfbb91c886ee63c0
parent33b839e16fe681ba915658f824ceb1b252084ea4 (diff)
Use flockfile if available.
Not really a huge improvement, but we might as well.
-rw-r--r--configure.ac4
-rw-r--r--src/maprules.c10
2 files changed, 13 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index df2c072..3a3822b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,9 @@ AC_PROG_LIBTOOL
XORG_CWARNFLAGS
AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
- [Do not have `strcasecmp'.]))
+ [Do not have 'strcasecmp'.]))
+AC_CHECK_FUNC(getc_unlocked, AC_DEFINE([HAVE_UNLOCKED_STDIO], 1,
+ ['Unlocked stdio']), [])
# Check for dependencies
PKG_CHECK_MODULES(XKBFILE, x11 kbproto)
diff --git a/src/maprules.c b/src/maprules.c
index cfc4d6d..b6d773c 100644
--- a/src/maprules.c
+++ b/src/maprules.c
@@ -137,6 +137,14 @@ InputLineAddChar(InputLine *line,int ch)
(int)((l)->line[(l)->num_line++]= (c)):\
InputLineAddChar(l,c))
+#ifdef HAVE_UNLOCKED_STDIO
+#undef getc
+#define getc(x) getc_unlocked(x)
+#else
+#define flockfile(x) do {} while (0)
+#define funlockfile(x) do {} while (0)
+#endif
+
static Bool
GetInputLine(FILE *file,InputLine *line,Bool checkbang)
{
@@ -144,6 +152,7 @@ int ch;
Bool endOfFile,spacePending,slashPending,inComment;
endOfFile= False;
+ flockfile(file);
while ((!endOfFile)&&(line->num_line==0)) {
spacePending= slashPending= inComment= False;
while (((ch=getc(file))!='\n')&&(ch!=EOF)) {
@@ -208,6 +217,7 @@ Bool endOfFile,spacePending,slashPending,inComment;
endOfFile= True;
/* else line->num_line++;*/
}
+ funlockfile(file);
if ((line->num_line==0)&&(endOfFile))
return False;
ADD_CHAR(line,'\0');