Changeset c702d2 in git
- Timestamp:
- Apr 28, 1998, 3:39:18 PM (25 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- fd39b4bc41d4f0180e03b38d9a8b48b70ae5ec87
- Parents:
- 986f2e14f22a5ca79aefc978f7420a7c9aa1147c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/find_exec.c
r986f2e rc702d2 36 36 37 37 38 /* Do not return copies of sth, but simply the strings 38 /* Do not return copies of sth, but simply the strings 39 39 -- we make copies later */ 40 40 #define copy_of(string) mstrdup(string) … … 42 42 /* ABSOLUTE_FILENAME_P (fname): True if fname is an absolute filename */ 43 43 #ifdef atarist 44 #define ABSOLUTE_FILENAME_P(fname) 45 44 #define ABSOLUTE_FILENAME_P(fname) ((fname[0] == '/') || \ 45 (fname[0] && (fname[1] == ':'))) 46 46 #else 47 #define ABSOLUTE_FILENAME_P(fname) 47 #define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/') 48 48 #endif /* atarist */ 49 49 … … 61 61 /* If we can execute the named file, and it is normal, then return it. */ 62 62 if (! access (name, X_OK)) { 63 63 struct stat stat_temp; 64 64 65 66 65 if (stat (name, &stat_temp)) 66 return 0; 67 67 68 68 #ifndef STAT_MACROS_BROKEN 69 70 69 if (! S_ISREG(stat_temp.st_mode)) 70 return 0; 71 71 #endif 72 72 return copy_of (name); 73 73 } 74 74 } … … 97 97 /* Perform tilde-expansion. Stolen from GNU readline/tilde.c. */ 98 98 if (p[0] == '~') { 99 100 101 99 if (! p[1] || p[1] == '/') { 100 /* Prepend $HOME to the rest of the string. */ 101 char *temp_home = (char *) getenv ("HOME"); 102 102 103 104 105 106 103 /* If there is no HOME variable, look up the directory in the 104 password database. */ 105 if (! temp_home) { 106 struct passwd *entry; 107 107 108 109 110 111 108 entry = getpwuid (getuid ()); 109 if (entry) 110 temp_home = entry->pw_dir; 111 } 112 112 113 114 115 116 117 118 119 120 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; 121 121 122 p ++;/* Skip the tilde. */123 124 125 122 p ++; /* Skip the tilde. */ 123 for (i = 0; *p && *p != '/' && *p != ':'; i++) 124 username[i] = *p ++; 125 username[i] = '\0'; 126 126 127 128 129 130 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 } 133 133 134 134 endpwent (); 135 135 } 136 136 137 137 /* Copy directory name into [tbuf]. */ 138 138 while (*p && *p != ':') 139 139 *next ++ = *p ++; 140 140 *next = '\0'; 141 141 if (*p != '\0') 142 142 p ++; 143 143 144 144 if (tbuf[0] == '.' && tbuf[1] == '\0') { 145 145 #ifdef HAVE_GETCWD 146 146 getcwd (tbuf, MAXPATHLEN); 147 147 #else 148 148 # ifdef HAVE_GETWD 149 149 getwd (tbuf); 150 150 # endif 151 151 #endif … … 157 157 /* If we can execute the named file, and it is normal, then return it. */ 158 158 if (! access (tbuf, X_OK)) { 159 159 struct stat stat_temp; 160 160 161 162 161 if (stat (tbuf, &stat_temp)) 162 continue; 163 163 164 164 #ifndef STAT_MACROS_BROKEN 165 166 165 if (! S_ISREG(stat_temp.st_mode)) 166 continue; 167 167 #endif 168 168 return copy_of (tbuf); 169 169 } 170 170 }
Note: See TracChangeset
for help on using the changeset viewer.