* cygheap.cc (_cfree): Add regparm attribute.

(_crealloc): Ditto.
* dcrt0.cc (dll_crt0_1): Default to always checking for executable for now.
* dtable.cc (dtable::not_open): Move method.
* dtable.h (dtable): Here.
* exceptions.cc (ctrl_c_handler): Don't expect process group leader to handle a
signal if it doesn't exist.
* fhandler.h (fhandler_base): Make openflags protected.
* localtime.c (tzsetwall): Check for __CYGWIN__ as well as __WIN32__.
* path.cc (path_conv::check): Add some comments.  Change strcat to assignment.
* lib/_cygwin_S_IEXEC.cc (_cygwin_bob__): Eliminate.
* fhandler_tty.cc (fhandler_console::dup): Set controlling terminal if
necessary.
* fhandler_tty.cc (fhandler_tty_slave::dup): Ditto.
This commit is contained in:
Christopher Faylor 2001-05-08 15:16:49 +00:00
parent 791cada5a2
commit 792011508a
12 changed files with 71 additions and 30 deletions

View File

@ -1,3 +1,27 @@
Tue May 8 11:09:59 2001 Christopher Faylor <cgf@cygnus.com>
* cygheap.cc (_cfree): Add regparm attribute.
(_crealloc): Ditto.
* dcrt0.cc (dll_crt0_1): Default to always checking for executable for now.
* dtable.cc (dtable::not_open): Move method.
* dtable.h (dtable): Here.
* exceptions.cc (ctrl_c_handler): Don't expect process group leader to
handle a signal if it doesn't exist.
* fhandler.h (fhandler_base): Make openflags protected.
* localtime.c (tzsetwall): Check for __CYGWIN__ as well as __WIN32__.
* path.cc (path_conv::check): Add some comments. Change strcat to assignment.
* lib/_cygwin_S_IEXEC.cc (_cygwin_bob__): Eliminate.
* fhandler_tty.cc (fhandler_console::dup): Set controlling terminal if necessary.
* fhandler_tty.cc (fhandler_tty_slave::dup): Ditto.
Mon May 7 21:33:17 2001 Christopher Faylor <cgf@cygnus.com> Mon May 7 21:33:17 2001 Christopher Faylor <cgf@cygnus.com>
* include/sys/file.h: Revert special X_OK usage. Just make it a * include/sys/file.h: Revert special X_OK usage. Just make it a

View File

@ -115,6 +115,7 @@ _cmalloc (int size)
return rvc->data; return rvc->data;
} }
static void __stdcall _cfree (void *ptr) __attribute__((regparm(1)));
static void __stdcall static void __stdcall
_cfree (void *ptr) _cfree (void *ptr)
{ {
@ -126,6 +127,7 @@ _cfree (void *ptr)
cygheap_protect->release (); cygheap_protect->release ();
} }
static void *__stdcall _crealloc (void *ptr, int size) __attribute__((regparm(2)));
static void *__stdcall static void *__stdcall
_crealloc (void *ptr, int size) _crealloc (void *ptr, int size)
{ {

View File

@ -109,7 +109,7 @@ extern "C"
/* impure_ptr */ &reent_data, /* impure_ptr */ &reent_data,
}; };
bool ignore_case_with_glob = FALSE; bool ignore_case_with_glob = FALSE;
int __declspec (dllexport) _check_for_executable = FALSE; int __declspec (dllexport) _check_for_executable = TRUE;
#ifdef DEBUGGING #ifdef DEBUGGING
int pinger = 0; int pinger = 0;
#endif #endif
@ -753,9 +753,6 @@ dll_crt0_1 ()
longjmp (fork_info->jmp, fork_info->cygpid); longjmp (fork_info->jmp, fork_info->cygpid);
} }
if (!CYGWIN_VERSION_CHECK_FOR_S_IEXEC)
_check_for_executable = TRUE;
#ifdef DEBUGGING #ifdef DEBUGGING
{ {
extern void fork_init (); extern void fork_init ();

View File

@ -125,17 +125,6 @@ stdio_init (void)
} }
} }
int
dtable::not_open (int fd)
{
SetResourceLock(LOCK_FD_LIST, READ_LOCK, "not_open");
int res = fd < 0 || fd >= (int)size || fds[fd] == NULL;
ReleaseResourceLock(LOCK_FD_LIST, READ_LOCK, "not open");
return res;
}
int int
dtable::find_unused_handle (int start) dtable::find_unused_handle (int start)
{ {

View File

@ -11,6 +11,8 @@ details. */
/* Initial and increment values for cygwin's fd table */ /* Initial and increment values for cygwin's fd table */
#define NOFILE_INCR 32 #define NOFILE_INCR 32
#include "thread.h"
class dtable class dtable
{ {
fhandler_base **fds; fhandler_base **fds;
@ -41,7 +43,15 @@ public:
fhandler_base *build_fhandler (int fd, DWORD dev, const char *name, fhandler_base *build_fhandler (int fd, DWORD dev, const char *name,
int unit = -1); int unit = -1);
fhandler_base *build_fhandler (int fd, const char *name, HANDLE h); fhandler_base *build_fhandler (int fd, const char *name, HANDLE h);
int not_open (int n) __attribute__ ((regparm(1))); int not_open (int fd)
{
SetResourceLock (LOCK_FD_LIST, READ_LOCK, "not_open");
int res = fd < 0 || fd >= (int) size || fds[fd] == NULL;
ReleaseResourceLock (LOCK_FD_LIST, READ_LOCK, "not open");
return res;
}
int find_unused_handle (int start); int find_unused_handle (int start);
int find_unused_handle () { return find_unused_handle (first_fd_for_open);} int find_unused_handle () { return find_unused_handle (first_fd_for_open);}
void release (int fd); void release (int fd);

View File

@ -904,7 +904,8 @@ ctrl_c_handler (DWORD type)
tty_min *t = cygwin_shared->tty.get_tty (myself->ctty); tty_min *t = cygwin_shared->tty.get_tty (myself->ctty);
/* Ignore this if we're not the process group lead since it should be handled /* Ignore this if we're not the process group lead since it should be handled
*by* the process group leader. */ *by* the process group leader. */
if (t->getpgid () && (t->getpgid () != myself->pid || if (t->getpgid () && pid_exists (t->getpgid ()) &&
(t->getpgid () != myself->pid ||
(GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP)) (GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP))
return TRUE; return TRUE;
else else

View File

@ -150,11 +150,11 @@ private:
unsigned long namehash; /* hashed filename, used as inode num */ unsigned long namehash; /* hashed filename, used as inode num */
protected:
/* Full unix path name of this file */ /* Full unix path name of this file */
/* File open flags from open () and fcntl () calls */ /* File open flags from open () and fcntl () calls */
int openflags; int openflags;
protected:
char *rabuf; /* used for crlf conversion in text files */ char *rabuf; /* used for crlf conversion in text files */
size_t ralen; size_t ralen;
size_t raixget; size_t raixget;

View File

@ -595,7 +595,7 @@ fhandler_console::dup (fhandler_base *child)
{ {
fhandler_console *fhc = (fhandler_console *) child; fhandler_console *fhc = (fhandler_console *) child;
if (!fhc->open (get_name (), get_flags (), 0)) if (!fhc->open (get_name (), get_flags () & ~O_NOCTTY, 0))
system_printf ("error opening console, %E"); system_printf ("error opening console, %E");
fhc->default_color = default_color; fhc->default_color = default_color;

View File

@ -783,6 +783,7 @@ fhandler_tty_common::dup (fhandler_base *child)
fts->tcinit (get_ttyp ()); fts->tcinit (get_ttyp ());
attach_tty (ttynum); attach_tty (ttynum);
tc->set_ctty (ttynum, openflags & ~O_NOCTTY);
HANDLE nh; HANDLE nh;

View File

@ -19,9 +19,3 @@ unsigned _cygwin_S_IXGRP = S_IXGRP;
unsigned _cygwin_S_IXOTH = S_IXOTH; unsigned _cygwin_S_IXOTH = S_IXOTH;
unsigned _cygwin_X_OK = X_OK; unsigned _cygwin_X_OK = X_OK;
}; };
extern int __declspec (dllimport) _check_for_executable;
struct _cygwin_bob__
{
_cygwin_bob__ () {_check_for_executable = 1;}
} _cygwin_dummy_bob__;

View File

@ -1429,7 +1429,7 @@ tzsetwall P((void))
} }
} }
#endif /* defined ALL_STATE */ #endif /* defined ALL_STATE */
#ifdef _WIN32 #if defined (_WIN32) || defined (__CYGWIN__)
#define is_upper(c) ((unsigned)(c) - 'A' <= 26) #define is_upper(c) ((unsigned)(c) - 'A' <= 26)
{ {
TIME_ZONE_INFORMATION tz; TIME_ZONE_INFORMATION tz;

View File

@ -386,6 +386,9 @@ path_conv::check (const char *src, unsigned opt,
MALLOC_CHECK; MALLOC_CHECK;
assert (src); assert (src);
char *p = strrchr (src, '/'); char *p = strrchr (src, '/');
/* Detect if the user was looking for a directory. We have to strip the
trailing slash initially and add it back on at the end due to Windows
brain damage. */
if (p) if (p)
{ {
if (p[1] == '\0' || strcmp (p, "/.") == 0) if (p[1] == '\0' || strcmp (p, "/.") == 0)
@ -434,9 +437,11 @@ path_conv::check (const char *src, unsigned opt,
full_path = this->path; full_path = this->path;
} }
/* Convert to native path spec sans symbolic link info. */
error = mount_table->conv_to_win32_path (path_copy, full_path, devn, error = mount_table->conv_to_win32_path (path_copy, full_path, devn,
unit, &sym.pflags); unit, &sym.pflags);
/* devn should not be a device. If it is, then stop parsing now. */
if (devn != FH_BAD) if (devn != FH_BAD)
{ {
fileattr = 0; fileattr = 0;
@ -453,7 +458,10 @@ path_conv::check (const char *src, unsigned opt,
*tail = '\0'; *tail = '\0';
if (full_path[0] && full_path[1] == ':' && full_path[2] == '\0') if (full_path[0] && full_path[1] == ':' && full_path[2] == '\0')
strcat (full_path, "\\"); {
full_path[2] = '\\';
full_path[3] = '\0';
}
if ((opt & PC_SYM_IGNORE) && pcheck_case == PCHECK_RELAXED) if ((opt & PC_SYM_IGNORE) && pcheck_case == PCHECK_RELAXED)
{ {
@ -529,13 +537,16 @@ path_conv::check (const char *src, unsigned opt,
break; break;
} }
/* No existing file found. */ /* No existing file found. */
} }
/* Find the "tail" of the path, e.g. in '/for/bar/baz',
/baz is the tail. */
char *newtail = strrchr (path_copy, '/'); char *newtail = strrchr (path_copy, '/');
if (tail != path_end) if (tail != path_end)
*tail = '/'; *tail = '/';
/* Exit loop if there is no tail or we are at the
beginning of a UNC path */
if (!newtail || newtail == path_copy || (newtail == path_copy + 1 && newtail[-1] == '/')) if (!newtail || newtail == path_copy || (newtail == path_copy + 1 && newtail[-1] == '/'))
goto out; // all done goto out; // all done
@ -556,6 +567,9 @@ path_conv::check (const char *src, unsigned opt,
MALLOC_CHECK; MALLOC_CHECK;
/* The tail is pointing at a null pointer. Increment it and get the length.
If the tail was empty then this increment will end up pointing to the extra
\0 added to path_copy above. */
int taillen = strlen (++tail); int taillen = strlen (++tail);
int buflen = strlen (sym.contents); int buflen = strlen (sym.contents);
if (buflen + taillen > MAX_PATH) if (buflen + taillen > MAX_PATH)
@ -565,24 +579,32 @@ path_conv::check (const char *src, unsigned opt,
return; return;
} }
/* Strip off current directory component since this is the part that refers
to the symbolic link. */
if ((p = strrchr (path_copy, '/')) == NULL) if ((p = strrchr (path_copy, '/')) == NULL)
p = path_copy; p = path_copy;
*p = '\0'; *p = '\0';
char *headptr; char *headptr;
if (isabspath (sym.contents)) if (isabspath (sym.contents))
headptr = tmp_buf; headptr = tmp_buf; /* absolute path */
else else
{ {
/* Copy the first part of the path and point to the end. */
strcpy (tmp_buf, path_copy); strcpy (tmp_buf, path_copy);
headptr = strchr (tmp_buf, '\0'); headptr = strchr (tmp_buf, '\0');
} }
/* See if we need to separate first part + symlink contents with a / */
if (headptr > tmp_buf && headptr[-1] != '/') if (headptr > tmp_buf && headptr[-1] != '/')
*headptr++ = '/'; *headptr++ = '/';
/* Copy the symlink contents to the end of tmp_buf.
Convert slashes. FIXME? */
for (p = sym.contents; *p; p++) for (p = sym.contents; *p; p++)
*headptr++ = *p == '\\' ? '/' : *p; *headptr++ = *p == '\\' ? '/' : *p;
/* Copy any tail component */
if (tail >= path_end) if (tail >= path_end)
*headptr = '\0'; *headptr = '\0';
else else
@ -591,6 +613,7 @@ path_conv::check (const char *src, unsigned opt,
strcpy (headptr, tail); strcpy (headptr, tail);
} }
/* Now evaluate everything all over again. */
src = tmp_buf; src = tmp_buf;
} }