numbers.
* path.cc (symlink_info::check): Use the above function.
* fhandler.cc (fhandler_disk_file::open): Ditto.
+Tue Oct 31 18:12:56 2000 Christopher Faylor <cgf@cygnus.com>
+
+ * path.h (has_exec_chars): Standard function for checking for
+ executable magic numbers.
+ * path.cc (symlink_info::check): Use the above function.
+ * fhandler.cc (fhandler_disk_file::open): Ditto.
+
Tue Oct 31 17:57:52 2000 Christopher Faylor <cgf@cygnus.com>
* path.cc (_readlink): Return ENOENT when file does not exist.
/* FIXME should we use /etc/magic ? */
magic[0] = magic[1] = magic[2] = '\0';
ReadFile (get_handle (), magic, 3, &done, 0);
- if ((magic[0] == ':' && magic[1] == '\n') ||
- (magic[0] == '#' && magic[1] == '!'))
+ if (has_exec_chars (magic, done))
real_path.set_exec ();
if (!(flags & O_APPEND))
SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);
else
{
/* Not a symlink, see if executable. */
- if (!(pflags & PATH_ALL_EXEC) && got >= 2 &&
- ((cookie_buf[0] == '#' && cookie_buf[1] == '!') ||
- (cookie_buf[0] == ':' && cookie_buf[1] == '\n') ||
- (cookie_buf[0] == 'M' && cookie_buf[1] == 'Z')))
+ if (!(pflags & PATH_ALL_EXEC) &&
+ has_exec_chars (cookie_buf, got))
+{
+debug_printf ("setting exec flag");
pflags |= PATH_EXEC;
+}
close_and_return:
CloseHandle (h);
goto file_not_symlink;
#define isdrive(s) (isalpha (*(s)) && (s)[1] == ':')
+static inline bool
+has_exec_chars (const char *buf, int len)
+{
+ return len >= 2 &&
+ ((buf[0] == '#' && buf[1] == '!') ||
+ (buf[0] == ':' && buf[1] == '\n') ||
+ (buf[0] == 'M' && buf[1] == 'Z'));
+}
+
/* cwd cache stuff. */
class muto;