Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 284431
Collapse All | Expand All

(-)a/src/gmxlib/futil.c (-16 / +16 lines)
Lines 52-57 Link Here
52
#include "smalloc.h"
52
#include "smalloc.h"
53
#include "statutil.h"
53
#include "statutil.h"
54
54
55
#define MAX_PATHBUF 4096
56
55
typedef struct t_pstack {
57
typedef struct t_pstack {
56
  FILE   *fp;
58
  FILE   *fp;
57
  struct t_pstack *prev;
59
  struct t_pstack *prev;
Lines 385-404 static bool filename_is_absolute(char *name) Link Here
385
#endif
387
#endif
386
}
388
}
387
389
388
389
bool get_libdir(char *libdir)
390
bool get_libdir(char *libdir)
390
{
391
{
391
  char bin_name[512];
392
  char bin_name[512];
392
  char buf[512];
393
  char buf[512];
393
  char full_path[512];
394
  char full_path[MAX_PATHBUF];
394
  char test_file[512];
395
  char test_file[MAX_PATHBUF];
395
  char system_path[512];
396
  char system_path[MAX_PATHBUF];
396
  char *dir,*ptr,*s,*pdum;
397
  char *dir,*ptr,*s,*pdum;
397
  bool found=FALSE;
398
  bool found=FALSE;
398
  int i;
399
  int i;
399
400
400
  /* First - detect binary name */
401
  /* First - detect binary name */
401
  strcpy(bin_name,Program());
402
  strncpy(bin_name,Program(),512);
402
  
403
  
403
  /* On windows & cygwin we need to add the .exe extension
404
  /* On windows & cygwin we need to add the .exe extension
404
   * too, or we wont be able to detect that the file exists
405
   * too, or we wont be able to detect that the file exists
Lines 409-415 bool get_libdir(char *libdir) Link Here
409
#endif
410
#endif
410
411
411
  /* Only do the smart search part if we got a real name */
412
  /* Only do the smart search part if we got a real name */
412
  if (NULL!=bin_name && strcmp(bin_name,"GROMACS")) {
413
  if (NULL!=bin_name && strncmp(bin_name,"GROMACS",512)) {
413
  
414
  
414
    if (!strchr(bin_name,DIR_SEPARATOR)) {
415
    if (!strchr(bin_name,DIR_SEPARATOR)) {
415
      /* No slash or backslash in name means it must be in the path - search it! */
416
      /* No slash or backslash in name means it must be in the path - search it! */
Lines 435-445 bool get_libdir(char *libdir) Link Here
435
       * name is relative to the current dir 
436
       * name is relative to the current dir 
436
       */
437
       */
437
      pdum=getcwd(buf,sizeof(buf)-1);
438
      pdum=getcwd(buf,sizeof(buf)-1);
438
      strcpy(full_path,buf);
439
      strncpy(full_path,buf,MAX_PATHBUF);
439
      strcat(full_path,"/");
440
      strcat(full_path,"/");
440
      strcat(full_path,bin_name);
441
      strcat(full_path,bin_name);
441
    } else {
442
    } else {
442
      strcpy(full_path,bin_name);
443
      strncpy(full_path,bin_name,MAX_PATHBUF);
443
    }
444
    }
444
    
445
    
445
    /* Now we should have a full path and name in full_path,
446
    /* Now we should have a full path and name in full_path,
Lines 450-458 bool get_libdir(char *libdir) Link Here
450
      buf[i]='\0';
451
      buf[i]='\0';
451
      /* If it doesn't start with "/" it is relative */
452
      /* If it doesn't start with "/" it is relative */
452
      if (buf[0]!=DIR_SEPARATOR) {
453
      if (buf[0]!=DIR_SEPARATOR) {
453
	strcpy(strrchr(full_path,DIR_SEPARATOR)+1,buf);
454
	strncpy(strrchr(full_path,DIR_SEPARATOR)+1,buf,MAX_PATHBUF);
454
      } else
455
      } else
455
	strcpy(full_path,buf);
456
	strncpy(full_path,buf,MAX_PATHBUF);
456
    }
457
    }
457
#endif
458
#endif
458
    
459
    
Lines 489-498 const char *low_libfn(const char *file, bool bFatal) Link Here
489
  const char *ret=NULL;
490
  const char *ret=NULL;
490
  char *lib,*dir;
491
  char *lib,*dir;
491
  static char buf[1024];
492
  static char buf[1024];
492
  static char libpath[4096];
493
  static char libpath[MAX_PATHBUF];
493
  static int  bFirst=1;
494
  static int  bFirst=1;
494
  static bool env_is_set;
495
  static bool env_is_set;
495
  char   *s,tmppath[4096];
496
  char   *s,tmppath[MAX_PATHBUF];
496
  bool found;
497
  bool found;
497
  
498
  
498
  if (bFirst) {
499
  if (bFirst) {
Lines 500-509 const char *low_libfn(const char *file, bool bFatal) Link Here
500
    lib=getenv("GMXLIB");
501
    lib=getenv("GMXLIB");
501
    if (lib != NULL) {
502
    if (lib != NULL) {
502
      env_is_set=TRUE;
503
      env_is_set=TRUE;
503
      strcpy(libpath,lib);
504
      strncpy(libpath,lib,MAX_PATHBUF);
504
    } 
505
    } 
505
    else if (!get_libdir(libpath))
506
    else if (!get_libdir(libpath))
506
      strcpy(libpath,GMXLIBDIR);
507
      strncpy(libpath,GMXLIBDIR,MAX_PATHBUF);
507
    
508
    
508
    bFirst=0;
509
    bFirst=0;
509
  }
510
  }
Lines 512-518 const char *low_libfn(const char *file, bool bFatal) Link Here
512
    ret=file;
513
    ret=file;
513
  else {
514
  else {
514
    found=FALSE;
515
    found=FALSE;
515
    strcpy(tmppath,libpath);
516
    strncpy(tmppath,libpath,MAX_PATHBUF);
516
    s=tmppath;
517
    s=tmppath;
517
    while(!found && (dir=strtok(s,PATH_SEPARATOR))!=NULL) {
518
    while(!found && (dir=strtok(s,PATH_SEPARATOR))!=NULL) {
518
      sprintf(buf,"%s%c%s",dir,DIR_SEPARATOR,file);
519
      sprintf(buf,"%s%c%s",dir,DIR_SEPARATOR,file);
519
- 

Return to bug 284431