Changeset 138f0c in git for Singular/febase.cc


Ignore:
Timestamp:
Nov 15, 1999, 1:53:28 PM (25 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
d9909c94593c093ae99a6b1884d5343aba29fbb3
Parents:
8f0190b06443e3b86ce8a435044847907447e7a9
Message:
* feFopen: recognize "~obachman/..."


git-svn-id: file:///usr/local/Singular/svn/trunk@3823 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/febase.cc

    r8f0190 r138f0c  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: febase.cc,v 1.83 1999-09-21 14:44:58 obachman Exp $ */
     4/* $Id: febase.cc,v 1.84 1999-11-15 12:53:28 obachman Exp $ */
    55/*
    66* ABSTRACT: i/o system
     
    1818#ifdef NeXT
    1919#include <sys/file.h>
     20#endif
     21
     22#ifdef HAVE_PWD_H
     23#include "pwd.h"
    2024#endif
    2125
     
    102106  if (path[0]=='~')
    103107  {
    104     char* home = getenv("HOME");
    105     if (home != NULL)
    106     {
    107       strcpy(longpath, home);
    108       strcat(longpath, &(path[1]));
    109       path = longpath;
    110     }
     108    if (path[1] == DIR_SEP)
     109    {
     110      char* home = getenv("HOME");
     111      if (home != NULL)
     112      {
     113        strcpy(longpath, home);
     114        strcat(longpath, &(path[1]));
     115        path = longpath;
     116      }
     117    }
     118#if defined(HAVE_PWD_H) && defined(HAVE_GETPWNAM)
     119    else
     120    {
     121      char* dir_sep;
     122      struct passwd *pw_entry;
     123      strcpy (longpath, path);
     124      dir_sep = strchr(longpath, DIR_SEP);
     125      *dir_sep = '\0';
     126      pw_entry = getpwnam(&longpath[1]);
     127      if (pw_entry != NULL)
     128      {
     129        strcpy(longpath, pw_entry->pw_dir);
     130        dir_sep = strchr(path, DIR_SEP);
     131        strcat(longpath, dir_sep);
     132        path = longpath;
     133      }
     134    }
     135#endif
    111136  }
    112137  FILE * f=NULL;
Note: See TracChangeset for help on using the changeset viewer.