Merge branch 'rj/no-xopen-source-for-cygwin'
authorJunio C Hamano <gitster@pobox.com>
Thu, 5 Mar 2015 20:45:41 +0000 (12:45 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Mar 2015 20:45:41 +0000 (12:45 -0800)
Code cleanups.

* rj/no-xopen-source-for-cygwin:
git-compat-util.h: remove redundant code

1  2 
git-compat-util.h
diff --combined git-compat-util.h
index 3455c5ece68359c70e04284b1c25b97716678172,2dbb6a75a4425bc2c2878ed5e6d9a699c7cbb167..fd58b1d2bcde2e1bff67ce503226bdbedf82a382
@@@ -83,7 -83,6 +83,7 @@@
  #define _ALL_SOURCE 1
  #define _GNU_SOURCE 1
  #define _BSD_SOURCE 1
 +#define _DEFAULT_SOURCE 1
  #define _NETBSD_SOURCE 1
  #define _SGI_SOURCE 1
  
  typedef long intptr_t;
  typedef unsigned long uintptr_t;
  #endif
- #if defined(__CYGWIN__)
- #undef _XOPEN_SOURCE
- #include <grp.h>
- #define _XOPEN_SOURCE 600
- #else
  #undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */
  #include <grp.h>
  #define _ALL_SOURCE 1
  #endif
- #endif
  
  /* used on Mac OS X */
  #ifdef PRECOMPOSE_UNICODE
@@@ -193,7 -186,7 +187,7 @@@ extern int compat_mkdir_wo_trailing_sla
  struct itimerval {
        struct timeval it_interval;
        struct timeval it_value;
 -}
 +};
  #endif
  
  #ifdef NO_SETITIMER
@@@ -212,18 -205,8 +206,18 @@@ extern char *gitbasename(char *)
  #endif
  
  #ifndef NO_OPENSSL
 +#ifdef __APPLE__
 +#define __AVAILABILITY_MACROS_USES_AVAILABILITY 0
 +#include <AvailabilityMacros.h>
 +#undef DEPRECATED_ATTRIBUTE
 +#define DEPRECATED_ATTRIBUTE
 +#undef __AVAILABILITY_MACROS_USES_AVAILABILITY
 +#endif
  #include <openssl/ssl.h>
  #include <openssl/err.h>
 +#ifdef NO_HMAC_CTX_CLEANUP
 +#define HMAC_CTX_cleanup HMAC_cleanup
 +#endif
  #endif
  
  /* On most systems <netdb.h> would have given us this, but
  #endif
  
  #ifndef has_dos_drive_prefix
 -#define has_dos_drive_prefix(path) 0
 +static inline int git_has_dos_drive_prefix(const char *path)
 +{
 +      return 0;
 +}
 +#define has_dos_drive_prefix git_has_dos_drive_prefix
  #endif
  
 -#ifndef offset_1st_component
 -#define offset_1st_component(path) (is_dir_sep((path)[0]))
 +#ifndef is_dir_sep
 +static inline int git_is_dir_sep(int c)
 +{
 +      return c == '/';
 +}
 +#define is_dir_sep git_is_dir_sep
  #endif
  
 -#ifndef is_dir_sep
 -#define is_dir_sep(c) ((c) == '/')
 +#ifndef offset_1st_component
 +static inline int git_offset_1st_component(const char *path)
 +{
 +      return is_dir_sep(path[0]);
 +}
 +#define offset_1st_component git_offset_1st_component
  #endif
  
  #ifndef find_last_dir_sep
 -#define find_last_dir_sep(path) strrchr(path, '/')
 +static inline char *git_find_last_dir_sep(const char *path)
 +{
 +      return strrchr(path, '/');
 +}
 +#define find_last_dir_sep git_find_last_dir_sep
  #endif
  
  #if defined(__HP_cc) && (__HP_cc >= 61000)
  
  #include "wildmatch.h"
  
 +struct strbuf;
 +
  /* General helper functions */
  extern void vreportf(const char *prefix, const char *err, va_list params);
  extern void vwritef(int fd, const char *prefix, const char *err, va_list params);
@@@ -485,40 -450,6 +479,40 @@@ extern int git_munmap(void *start, size
  #define on_disk_bytes(st) ((st).st_blocks * 512)
  #endif
  
 +#ifdef NEEDS_MODE_TRANSLATION
 +#undef S_IFMT
 +#undef S_IFREG
 +#undef S_IFDIR
 +#undef S_IFLNK
 +#undef S_IFBLK
 +#undef S_IFCHR
 +#undef S_IFIFO
 +#undef S_IFSOCK
 +#define S_IFMT   0170000
 +#define S_IFREG  0100000
 +#define S_IFDIR  0040000
 +#define S_IFLNK  0120000
 +#define S_IFBLK  0060000
 +#define S_IFCHR  0020000
 +#define S_IFIFO  0010000
 +#define S_IFSOCK 0140000
 +#ifdef stat
 +#undef stat
 +#endif
 +#define stat(path, buf) git_stat(path, buf)
 +extern int git_stat(const char *, struct stat *);
 +#ifdef fstat
 +#undef fstat
 +#endif
 +#define fstat(fd, buf) git_fstat(fd, buf)
 +extern int git_fstat(int, struct stat *);
 +#ifdef lstat
 +#undef lstat
 +#endif
 +#define lstat(path, buf) git_lstat(path, buf)
 +extern int git_lstat(const char *, struct stat *);
 +#endif
 +
  #define DEFAULT_PACKED_GIT_LIMIT \
        ((1024L * 1024L) * (sizeof(void*) >= 8 ? 8192 : 256))
  
@@@ -641,11 -572,6 +635,11 @@@ int inet_pton(int af, const char *src, 
  const char *inet_ntop(int af, const void *src, char *dst, size_t size);
  #endif
  
 +#ifdef NO_PTHREADS
 +#define atexit git_atexit
 +extern int git_atexit(void (*handler)(void));
 +#endif
 +
  extern void release_pack_memory(size_t);
  
  typedef void (*try_to_free_t)(size_t);
@@@ -662,7 -588,6 +656,7 @@@ extern try_to_free_t set_try_to_free_ro
  extern char *xstrdup(const char *str);
  extern void *xmalloc(size_t size);
  extern void *xmallocz(size_t size);
 +extern void *xmallocz_gently(size_t size);
  extern void *xmemdupz(const void *data, size_t len);
  extern char *xstrndup(const char *str, size_t len);
  extern void *xrealloc(void *ptr, size_t size);
@@@ -677,14 -602,6 +671,14 @@@ extern int xmkstemp(char *template)
  extern int xmkstemp_mode(char *template, int mode);
  extern int odb_mkstemp(char *template, size_t limit, const char *pattern);
  extern int odb_pack_keep(char *name, size_t namesz, const unsigned char *sha1);
 +extern char *xgetcwd(void);
 +
 +#define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), (alloc) * sizeof(*(x)))
 +
 +static inline char *xstrdup_or_null(const char *str)
 +{
 +      return str ? xstrdup(str) : NULL;
 +}
  
  static inline size_t xsize_t(off_t len)
  {
@@@ -734,7 -651,7 +728,7 @@@ extern const unsigned char sane_ctype[2
  #define iscntrl(x) (sane_istest(x,GIT_CNTRL))
  #define ispunct(x) sane_istest(x, GIT_PUNCT | GIT_REGEX_SPECIAL | \
                GIT_GLOB_SPECIAL | GIT_PATHSPEC_MAGIC)
 -#define isxdigit(x) (hexval_table[x] != -1)
 +#define isxdigit(x) (hexval_table[(unsigned char)(x)] != -1)
  #define tolower(x) sane_case((unsigned char)(x), 0x20)
  #define toupper(x) sane_case((unsigned char)(x), 0)
  #define is_pathspec_magic(x) sane_istest(x,GIT_PATHSPEC_MAGIC)
@@@ -828,27 -745,17 +822,27 @@@ void git_qsort(void *base, size_t nmemb
  #endif
  #endif
  
 -#if defined(__GNUC__) || (_MSC_VER >= 1400)
 +#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__C99_MACRO_WITH_VA_ARGS)
  #define HAVE_VARIADIC_MACROS 1
  #endif
  
  /*
   * Preserves errno, prints a message, but gives no warning for ENOENT.
 - * Always returns the return value of unlink(2).
 + * Returns 0 on success, which includes trying to unlink an object that does
 + * not exist.
   */
  int unlink_or_warn(const char *path);
 + /*
 +  * Tries to unlink file.  Returns 0 if unlink succeeded
 +  * or the file already didn't exist.  Returns -1 and
 +  * appends a message to err suitable for
 +  * 'error("%s", err->buf)' on error.
 +  */
 +int unlink_or_msg(const char *file, struct strbuf *err);
  /*
 - * Likewise for rmdir(2).
 + * Preserves errno, prints a message, but gives no warning for ENOENT.
 + * Returns 0 on success, which includes trying to remove a directory that does
 + * not exist.
   */
  int rmdir_or_warn(const char *path);
  /*
@@@ -878,8 -785,4 +872,8 @@@ struct tm *git_gmtime_r(const time_t *
  #define gmtime_r git_gmtime_r
  #endif
  
 +#if !defined(USE_PARENS_AROUND_GETTEXT_N) && defined(__GNUC__)
 +#define USE_PARENS_AROUND_GETTEXT_N 1
 +#endif
 +
  #endif