Ticket #2206: avoid-PATH_MAX.patch

File avoid-PATH_MAX.patch, 1.1 KB (added by Steven Robbins <smr@…>, 14 years ago)
  • tools/jam/src/pwd.c

    old new  
    22/* Software License, Version 1.0. (See accompanying */
    33/* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */
    44
     5/* Define _GNU_SOURCE to expose get_current_dir_name() */
     6#define _GNU_SOURCE
     7
    58#include "jam.h"
    69#include "lists.h"
    710#include "newstr.h"
     
    2427/* The current directory can't change in bjam, so optimize this to cache
    2528** the result.
    2629*/
     30#ifndef __GLIBC__
    2731static char pwd_buffer[PATH_MAX];
     32#endif
    2833static char * pwd_result = NULL;
    2934
    3035
     
    3338{
    3439    if (!pwd_result)
    3540    {
     41#ifdef __GLIBC__
     42        if ((pwd_result = get_current_dir_name()) == NULL)
     43#else
    3644        if (getcwd(pwd_buffer, sizeof(pwd_buffer)) == NULL)
     45#endif
    3746        {
    3847            perror("can not get current directory");
    3948            return L0;
    4049        }
     50#ifndef __GLIBC__
    4151        else
    4252        {
    4353#ifdef NT
     
    4656            pwd_result = newstr(pwd_buffer);
    4757#endif
    4858        }
     59#endif
    4960    }
    5061    return list_new(L0, pwd_result);
    5162}