1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Bug 960: Redefine LOADMSGCAT_USE_MMAP instead of HAVE_MMAP.

And add a prominent notice as stipulated in GNU GPL version 2 section 2a.

[ From commit ba54124f16 in ELinks
  0.11.3.GIT.  --KON ]
This commit is contained in:
Kalle Olavi Niemitalo 2007-07-02 21:24:11 +03:00 committed by Kalle Olavi Niemitalo
parent 1ea44dcda5
commit 69e9a586ba

View File

@ -15,6 +15,8 @@
along with this program; if not, write to the Free Software Foundation, along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Modified on 2007-07-02 by Kalle Olavi Niemitalo. */
/* Tell glibc's <string.h> to provide a prototype for mempcpy(). /* Tell glibc's <string.h> to provide a prototype for mempcpy().
This must come before <config.h> because <config.h> may include This must come before <config.h> because <config.h> may include
<features.h>, and once <features.h> has been included, it's too late. */ <features.h>, and once <features.h> has been included, it's too late. */
@ -41,10 +43,15 @@
#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) #if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP)
#include <sys/mman.h> #include <sys/mman.h>
#undef HAVE_MMAP /* Use a custom macro instead of overloading HAVE_MMAP, because the
#define HAVE_MMAP 1 * following #include directives may cause "config.h" to be included
* again (bug 960). It might be good to remove #include "config.h"
* directives from header files and keep them in *.c files only, but
* that seems too risky for the stable elinks-0.11 branch. */
#undef LOADMSGCAT_USE_MMAP
#define LOADMSGCAT_USE_MMAP 1
#else #else
#undef HAVE_MMAP #undef LOADMSGCAT_USE_MMAP
#endif #endif
#include "elinks.h" #include "elinks.h"
@ -285,7 +292,7 @@ source_success:
close(fd); close(fd);
return; return;
} }
#ifdef HAVE_MMAP #ifdef LOADMSGCAT_USE_MMAP
/* Now we are ready to load the file. If mmap() is available we try /* Now we are ready to load the file. If mmap() is available we try
this first. If not available or it failed we try to load it. */ this first. If not available or it failed we try to load it. */
data = (struct mo_file_header *) mmap(NULL, size, PROT_READ, data = (struct mo_file_header *) mmap(NULL, size, PROT_READ,
@ -328,7 +335,7 @@ source_success:
catalog file. */ catalog file. */
if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED) { if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED) {
/* The magic number is wrong: not a message catalog file. */ /* The magic number is wrong: not a message catalog file. */
#ifdef HAVE_MMAP #ifdef LOADMSGCAT_USE_MMAP
if (use_mmap) if (use_mmap)
munmap((void *) data, size); munmap((void *) data, size);
else else
@ -365,7 +372,7 @@ source_success:
break; break;
default: default:
/* This is an invalid revision. */ /* This is an invalid revision. */
#ifdef HAVE_MMAP #ifdef LOADMSGCAT_USE_MMAP
if (use_mmap) if (use_mmap)
munmap((void *) data, size); munmap((void *) data, size);
else else