Browse Source

- Centralize some configuration stuff

- Use inline in my strtok_r implementation
PHP-4.0.5
Andi Gutmans 26 years ago
parent
commit
b8a95da22a
  1. 9
      TSRM/tsrm_config.w32.h
  2. 22
      TSRM/tsrm_config_common.h
  3. 7
      TSRM/tsrm_strtok_r.c
  4. 14
      TSRM/tsrm_virtual_cwd.c
  5. 10
      TSRM/tsrm_virtual_cwd.h

9
TSRM/tsrm_config.w32.h

@ -2,5 +2,14 @@
#define TSRM_CONFIG_W32_H
#define HAVE_UTIME 1
#define HAVE_ALLOCA 1
#undef inline
#ifdef ZEND_WIN32_FORCE_INLINE
# define inline __forceinline
#else
# define inline
#endif
#endif

22
TSRM/tsrm_config_common.h

@ -0,0 +1,22 @@
#ifndef TSRM_CONFIG_COMMON_H
#define TSRM_CONFIG_COMMON_H
#if WINNT|WIN32
# define TSRM_WIN32
#endif
#ifndef TSRM_WIN32
# include "tsrm_config.h"
#else
# include "tsrm_config.w32.h"
#endif
#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2))
# define tsrm_do_alloca(p) alloca(p)
# define tsrm_free_alloca(p)
#else
# define tsrm_do_alloca(p) malloc(p)
# define tsrm_free_alloca(p) free(p)
#endif
#endif /* TSRM_CONFIG_COMMON_H */

7
TSRM/tsrm_strtok_r.c

@ -1,8 +1,9 @@
#include "tsrm_strtok_r.h"
#include <stdio.h>
static int in_character_class(char ch, const char *delim)
#include "tsrm_config_common.h"
#include "tsrm_strtok_r.h"
static inline int in_character_class(char ch, const char *delim)
{
while (*delim) {
if (*delim == ch) {

14
TSRM/tsrm_virtual_cwd.c

@ -37,16 +37,6 @@
#define MAXPATHLEN 256
#endif
#ifndef do_alloca
# if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(TSRM_WIN32))
# define do_alloca(p) alloca(p)
# define free_alloca(p)
# else
# define do_alloca(p) malloc(p)
# define free_alloca(p) free(p)
# endif
#endif
#ifdef TSRM_WIN32
#include <io.h>
#endif
@ -444,14 +434,14 @@ CWD_API int virtual_chdir_file(const char *path, int (*p_chdir)(const char *path
if (length == COPY_WHEN_ABSOLUTE && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */
length++;
}
temp = (char *) do_alloca(length+1);
temp = (char *) tsrm_do_alloca(length+1);
memcpy(temp, path, length);
temp[length] = 0;
#if VIRTUAL_CWD_DEBUG
fprintf (stderr, "Changing directory to %s\n", temp);
#endif
retval = p_chdir(temp);
free_alloca(temp);
tsrm_free_alloca(temp);
return retval;
}

10
TSRM/tsrm_virtual_cwd.h

@ -22,15 +22,7 @@
#ifndef VIRTUAL_CWD_H
#define VIRTUAL_CWD_H
#ifdef WIN32
# define TSRM_WIN32
#endif
#ifndef TSRM_WIN32
# include "tsrm_config.h"
#else
# include "tsrm_config.w32.h"
#endif
#include "tsrm_config_common.h"
#include <sys/types.h>
#include <sys/stat.h>

Loading…
Cancel
Save