os/*_defs.h: MAXNAMLEN cleanup

For non-Windows systems, we assume that NAME_MAX is in <limits.h>, as
specified in POSIX.1-2008[1]. For Windows, which doesn't have NAME_MAX,
just define it ourselves to _MAX_PATH[2].

Also, remove two (now unused) HAVE_*_H checks.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
[2]: https://msdn.microsoft.com/en-us/library/930f87yf.aspx

Helped-by: Seth Jackson
This commit is contained in:
Michael Reed
2016-01-11 01:37:15 -05:00
parent a1c770ca27
commit f65d58907d
5 changed files with 7 additions and 30 deletions

View File

@@ -13,28 +13,7 @@
# include "nvim/os/unix_defs.h"
#endif
#if defined(DIRSIZ) && !defined(MAXNAMLEN)
# define MAXNAMLEN DIRSIZ
#endif
#if defined(UFS_MAXNAMLEN) && !defined(MAXNAMLEN)
# define MAXNAMLEN UFS_MAXNAMLEN /* for dynix/ptx */
#endif
#if defined(NAME_MAX) && !defined(MAXNAMLEN)
# define MAXNAMLEN NAME_MAX /* for Linux before .99p3 */
#endif
#if defined(_MAX_PATH) && !defined(MAXNAMLEN)
# define MAXNAMLEN _MAX_PATH /* for Windows */
#endif
// Default value.
#ifndef MAXNAMLEN
# define MAXNAMLEN 512
#endif
#define BASENAMELEN (MAXNAMLEN - 5)
#define BASENAMELEN (NAME_MAX - 5)
// Use the system path length if it makes sense.
#if defined(PATH_MAX) && (PATH_MAX > 1000)

View File

@@ -1,13 +1,12 @@
#ifndef NVIM_OS_UNIX_DEFS_H
#define NVIM_OS_UNIX_DEFS_H
// Windows doesn't have unistd.h, so we include it here to avoid numerous
// instances of `#ifdef HAVE_UNISTD_H'.
#include <unistd.h>
#include <signal.h>
// Defines BSD, if it's a BSD system.
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
// POSIX.1-2008 says that NAME_MAX should be in here
#include <limits.h>
#define TEMP_DIR_NAMES {"$TMPDIR", "/tmp", ".", "~"}
#define TEMP_FILE_PATH_MAXLEN 256

View File

@@ -5,6 +5,8 @@
#include <sys/stat.h>
#include <stdio.h>
#define NAME_MAX _MAX_PATH
#define TEMP_DIR_NAMES {"$TMP", "$TEMP", "$USERPROFILE", ""}
#define TEMP_FILE_PATH_MAXLEN _MAX_PATH