Changeset c702d2 in git


Ignore:
Timestamp:
Apr 28, 1998, 3:39:18 PM (25 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
fd39b4bc41d4f0180e03b38d9a8b48b70ae5ec87
Parents:
986f2e14f22a5ca79aefc978f7420a7c9aa1147c
Message:
* hannes: minor fixes


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

Legend:

Unmodified
Added
Removed
  • Singular/find_exec.c

    r986f2e rc702d2  
    3636
    3737
    38 /* Do not return copies of sth, but simply the strings 
     38/* Do not return copies of sth, but simply the strings
    3939   -- we make copies later */
    4040#define copy_of(string) mstrdup(string)
     
    4242/* ABSOLUTE_FILENAME_P (fname): True if fname is an absolute filename */
    4343#ifdef atarist
    44 #define ABSOLUTE_FILENAME_P(fname)      ((fname[0] == '/') || \
    45         (fname[0] && (fname[1] == ':')))
     44#define ABSOLUTE_FILENAME_P(fname)        ((fname[0] == '/') || \
     45        (fname[0] && (fname[1] == ':')))
    4646#else
    47 #define ABSOLUTE_FILENAME_P(fname)      (fname[0] == '/')
     47#define ABSOLUTE_FILENAME_P(fname)        (fname[0] == '/')
    4848#endif /* atarist */
    4949
     
    6161      /* If we can execute the named file, and it is normal, then return it. */
    6262      if (! access (name, X_OK)) {
    63         struct stat stat_temp;
     63        struct stat stat_temp;
    6464
    65         if (stat (name, &stat_temp))
    66           return 0;
     65        if (stat (name, &stat_temp))
     66          return 0;
    6767
    6868#ifndef STAT_MACROS_BROKEN
    69         if (! S_ISREG(stat_temp.st_mode))
    70           return 0;
     69        if (! S_ISREG(stat_temp.st_mode))
     70          return 0;
    7171#endif
    72         return copy_of (name);
     72        return copy_of (name);
    7373      }
    7474    }
     
    9797      /* Perform tilde-expansion. Stolen from GNU readline/tilde.c. */
    9898      if (p[0] == '~') {
    99         if (! p[1] || p[1] == '/') {
    100           /* Prepend $HOME to the rest of the string. */
    101           char *temp_home = (char *) getenv ("HOME");
     99        if (! p[1] || p[1] == '/') {
     100          /* Prepend $HOME to the rest of the string. */
     101          char *temp_home = (char *) getenv ("HOME");
    102102
    103           /* If there is no HOME variable, look up the directory in the
    104              password database. */
    105           if (! temp_home) {
    106             struct passwd *entry;
     103          /* If there is no HOME variable, look up the directory in the
     104             password database. */
     105          if (! temp_home) {
     106            struct passwd *entry;
    107107
    108             entry = getpwuid (getuid ());
    109             if (entry)
    110               temp_home = entry->pw_dir;
    111           }
     108            entry = getpwuid (getuid ());
     109            if (entry)
     110              temp_home = entry->pw_dir;
     111          }
    112112
    113           strcpy (tbuf, temp_home);
    114           next = tbuf + strlen (tbuf);
    115           p ++;
    116         }
    117         else {
    118           char username[MAXPATHLEN];
    119           struct passwd *user_entry;
    120           int i;
     113          strcpy (tbuf, temp_home);
     114          next = tbuf + strlen (tbuf);
     115          p ++;
     116        }
     117        else {
     118          char username[MAXPATHLEN];
     119          struct passwd *user_entry;
     120          int i;
    121121
    122           p ++;                 /* Skip the tilde. */
    123           for (i = 0; *p && *p != '/' && *p != ':'; i++)
    124             username[i] = *p ++;
    125           username[i] = '\0';
     122          p ++;                        /* Skip the tilde. */
     123          for (i = 0; *p && *p != '/' && *p != ':'; i++)
     124            username[i] = *p ++;
     125          username[i] = '\0';
    126126
    127           user_entry = getpwnam (username);
    128           if (user_entry) {
    129             strcpy (tbuf, user_entry->pw_dir);
    130             next = tbuf + strlen (tbuf);
    131           }
    132         }
     127          user_entry = getpwnam (username);
     128          if (user_entry) {
     129            strcpy (tbuf, user_entry->pw_dir);
     130            next = tbuf + strlen (tbuf);
     131          }
     132        }
    133133
    134         endpwent ();
     134        endpwent ();
    135135      }
    136136
    137137      /* Copy directory name into [tbuf]. */
    138138      while (*p && *p != ':')
    139         *next ++ = *p ++;
     139        *next ++ = *p ++;
    140140      *next = '\0';
    141141      if (*p != '\0')
    142         p ++;
     142        p ++;
    143143
    144144      if (tbuf[0] == '.' && tbuf[1] == '\0') {
    145145#ifdef HAVE_GETCWD
    146         getcwd (tbuf, MAXPATHLEN);
     146        getcwd (tbuf, MAXPATHLEN);
    147147#else
    148148# ifdef HAVE_GETWD
    149         getwd (tbuf);
     149        getwd (tbuf);
    150150# endif
    151151#endif
     
    157157      /* If we can execute the named file, and it is normal, then return it. */
    158158      if (! access (tbuf, X_OK)) {
    159         struct stat stat_temp;
     159        struct stat stat_temp;
    160160
    161         if (stat (tbuf, &stat_temp))
    162           continue;
     161        if (stat (tbuf, &stat_temp))
     162          continue;
    163163
    164164#ifndef STAT_MACROS_BROKEN
    165         if (! S_ISREG(stat_temp.st_mode))
    166           continue;
     165        if (! S_ISREG(stat_temp.st_mode))
     166          continue;
    167167#endif
    168         return copy_of (tbuf);
     168        return copy_of (tbuf);
    169169      }
    170170    }
Note: See TracChangeset for help on using the changeset viewer.