pike.git / src / main.c

version» Context lines:

pike.git/src/main.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: main.c,v 1.235 2008/07/31 21:11:36 mast Exp $ + || $Id: main.c,v 1.236 2009/09/18 16:00:42 grubba Exp $   */      #include "global.h"   #include "fdlib.h"   #include "backend.h"   #include "module.h"   #include "object.h"   #include "lex.h"   #include "pike_types.h"   #include "builtin_functions.h"
pike.git/src/main.c:128: Inside #if defined(__NT__)
   &len)==ERROR_SUCCESS)    {    /* FIXME: Look at len? UNICODE? */    set_master(buffer);    }    RegCloseKey(k);    }   }   #endif /* __NT__ */    - static void set_default_master(void) + static void set_default_master(const char *bin_name)   {    char *mp = master_location + CONSTANT_STRLEN (MASTER_COOKIE);      #ifdef HAVE_GETENV    if(!*mp && getenv("PIKE_MASTER")) {    set_master(getenv("PIKE_MASTER"));    }   #endif      #ifdef __NT__    if(!*mp) get_master_key(HKEY_CURRENT_USER);    if(!*mp) get_master_key(HKEY_LOCAL_MACHINE);   #endif    -  if(!*mp) +  if(!*mp && strncmp(DEFAULT_MASTER, "NONE/", 5))    {    SNPRINTF (mp, sizeof (master_location) - CONSTANT_STRLEN (MASTER_COOKIE),    DEFAULT_MASTER,    PIKE_MAJOR_VERSION,    PIKE_MINOR_VERSION,    PIKE_BUILD_VERSION);    }      #ifdef __NT__    if (!(*mp == '/' || *mp == '\\' || (isalpha (*mp) && mp[1] == ':'))) {
pike.git/src/main.c:167: Inside #if defined(__NT__)
   GetLastError());    else {    char tmp[MAXPATHLEN * 2];    char *p = strrchr (exepath, '\\');    if (p) *p = 0;    SNPRINTF (tmp, sizeof (tmp), "%s/%s", exepath, mp);    strncpy (mp, tmp,    sizeof (master_location) - CONSTANT_STRLEN (MASTER_COOKIE));    }    } + #else +  if (!*mp) { +  /* Attempt to find a master via the path to the binary. */ +  /* Note: We assume that MAXPATHLEN is > 18 characters. */ +  if (strlen(bin_name) < (2*MAXPATHLEN - +  CONSTANT_STRLEN(MASTER_COOKIE "master.pike"))) { +  char *p; +  strcpy(mp, bin_name); +  p = strrchr(mp, '/'); +  if (!p) p = mp; +  else p++; +  strcpy(p, "master.pike"); +  } +  }   #endif       TRACE((stderr, "Default master at \"%s\"...\n", mp));   }      #ifdef LIBPIKE   static char libpike_file[MAXPATHLEN * 2];   static void *libpike;      static void (*init_pike)(const char **argv, const char *file);   static void (*init_pike_runtime)(void (*exit_cb)(int));   #endif /* LIBPIKE */      static void find_lib_dir(int argc, char **argv)   {    int e;       TRACE((stderr, "find_lib_dir...\n"));    -  set_default_master(); +  set_default_master(argv[0]);       for(e=1; e<argc; e++)    {    TRACE((stderr, "Parse argument %d:\"%s\"...\n", e, argv[e]));       if(argv[e][0] != '-') break;       switch(argv[e][1])    {    default: