Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2006-01-03 20:44:26 +0300
committerChristopher Faylor <me@cgf.cx>2006-01-03 20:44:26 +0300
commitadcff8d159698ea0ff59505ada74fc7243738e68 (patch)
tree8efd16e71fdef6a230dcb316dbca01a4127fad0d
parent825d0b93850125861ebefa6925ada44fe8f93f92 (diff)
* dir.cc (readdir_worker): Minor code cleanup.
* fhandler_console.cc (beep): Use a more Windows-generic wav file if the beep is missing. Use a more foolproof way to find out whether we should be recreating the missing key. * registry.h (reg_key::_disposition): New field. (reg_key::created): New function. * registry.cc (reg_key::reg_key): Set _disposition to zero by default. (reg_key::build_key): Fill in _disposition field.
-rw-r--r--winsup/cygwin/ChangeLog15
-rw-r--r--winsup/cygwin/dir.cc103
-rw-r--r--winsup/cygwin/fhandler_console.cc17
-rw-r--r--winsup/cygwin/registry.cc8
-rw-r--r--winsup/cygwin/registry.h4
5 files changed, 85 insertions, 62 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 58d60a21b..f388ca76f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,6 +1,19 @@
+2006-01-03 Christopher Faylor <cgf@timesys.com>
+
+ * dir.cc (readdir_worker): Minor code cleanup.
+
+ * fhandler_console.cc (beep): Use a more Windows-generic wav file if
+ the beep is missing. Use a more foolproof way to find out whether we
+ should be recreating the missing key.
+
+ * registry.h (reg_key::_disposition): New field.
+ (reg_key::created): New function.
+ * registry.cc (reg_key::reg_key): Set _disposition to zero by default.
+ (reg_key::build_key): Fill in _disposition field.
+
2006-01-03 Eric Blake <ebb9@byu.net>
- * dir.cc (readdir_worker): Ensure that saw_dot flags are updated when
+ * dir.cc (readdir_worker): Ensure that saw_dot* flags are updated when
not handling inodes.
2006-01-02 Christopher Faylor <cgf@timesys.com>
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index 2e109083d..e00aa77ab 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -100,57 +100,58 @@ readdir_worker (DIR *dir, dirent *de)
}
}
- if (!res)
- if (!CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO)
- {
- de->__invalid_d_ino = 0;
- de->__ino32 = 0;
- if (de->d_name[0] == '.')
- {
- if (de->d_name[1] == '\0')
- dir->__flags |= dirent_saw_dot;
- else if (de->d_name[1] == '.' && de->d_name[2] == '\0')
- dir->__flags |= dirent_saw_dot_dot;
- }
- }
- else
- {
- /* Compute d_ino by combining filename hash with the directory hash
- (which was stored in dir->__d_dirhash when opendir was called). */
- if (de->d_name[0] == '.')
- {
- if (de->d_name[1] == '\0')
- {
- de->__invalid_d_ino = dir->__d_dirhash;
- dir->__flags |= dirent_saw_dot;
- }
- else if (de->d_name[1] != '.' || de->d_name[2] != '\0')
- goto hashit;
- else
- {
- dir->__flags |= dirent_saw_dot_dot;
- char *p, up[strlen (dir->__d_dirname) + 1];
- strcpy (up, dir->__d_dirname);
- if (!(p = strrchr (up, '\\')))
- goto hashit;
- *p = '\0';
- if (!(p = strrchr (up, '\\')))
- de->__invalid_d_ino = hash_path_name (0, ".");
- else
- {
- *p = '\0';
- de->__invalid_d_ino = hash_path_name (0, up);
- }
- }
- }
- else
- {
- hashit:
- __ino64_t dino = hash_path_name (dir->__d_dirhash, "\\");
- de->__invalid_d_ino = hash_path_name (dino, de->d_name);
- }
- de->__ino32 = de->__invalid_d_ino; // for legacy applications
- }
+ if (res)
+ /* error return */;
+ else if (!CYGWIN_VERSION_CHECK_FOR_NEEDS_D_INO)
+ {
+ de->__invalid_d_ino = 0;
+ de->__ino32 = 0;
+ if (de->d_name[0] == '.')
+ {
+ if (de->d_name[1] == '\0')
+ dir->__flags |= dirent_saw_dot;
+ else if (de->d_name[1] == '.' && de->d_name[2] == '\0')
+ dir->__flags |= dirent_saw_dot_dot;
+ }
+ }
+ else
+ {
+ /* Compute d_ino by combining filename hash with the directory hash
+ (which was stored in dir->__d_dirhash when opendir was called). */
+ if (de->d_name[0] == '.')
+ {
+ if (de->d_name[1] == '\0')
+ {
+ de->__invalid_d_ino = dir->__d_dirhash;
+ dir->__flags |= dirent_saw_dot;
+ }
+ else if (de->d_name[1] != '.' || de->d_name[2] != '\0')
+ goto hashit;
+ else
+ {
+ dir->__flags |= dirent_saw_dot_dot;
+ char *p, up[strlen (dir->__d_dirname) + 1];
+ strcpy (up, dir->__d_dirname);
+ if (!(p = strrchr (up, '\\')))
+ goto hashit;
+ *p = '\0';
+ if (!(p = strrchr (up, '\\')))
+ de->__invalid_d_ino = hash_path_name (0, ".");
+ else
+ {
+ *p = '\0';
+ de->__invalid_d_ino = hash_path_name (0, up);
+ }
+ }
+ }
+ else
+ {
+ hashit:
+ __ino64_t dino = hash_path_name (dir->__d_dirhash, "\\");
+ de->__invalid_d_ino = hash_path_name (dino, de->d_name);
+ }
+ de->__ino32 = de->__invalid_d_ino; // for legacy applications
+ }
return res;
}
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 3370564c2..431886352 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -1,6 +1,7 @@
/* fhandler_console.cc
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ 2006 Red Hat, Inc.
This file is part of Cygwin.
@@ -1416,11 +1417,17 @@ bad_escape:
static void
beep ()
{
- char buf[4096];
reg_key r (HKEY_CURRENT_USER, KEY_ALL_ACCESS, "AppEvents", "Schemes", "Apps",
- ".Default", ".Default", ".current", NULL);
- if (r.get_string ("", buf, sizeof (buf), "") != 0)
- r.set_string ("", "Windows XP Ding.wav");
+ ".Default", ".Default", ".Current", NULL);
+ if (r.created ())
+ {
+ char *buf = NULL;
+ UINT len = GetWindowsDirectory (buf, 0);
+ buf = (char *) alloca (len += sizeof ("\\media\\ding.wav"));
+ UINT res = GetWindowsDirectory (buf, len);
+ if (res && res <= len)
+ r.set_string ("", strcat (buf, "\\media\\ding.wav"));
+ }
MessageBeep (0xFFFFFFFF);
}
diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc
index b443b92f4..723a71098 100644
--- a/winsup/cygwin/registry.cc
+++ b/winsup/cygwin/registry.cc
@@ -1,7 +1,7 @@
/* registry.cc: registry interface
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005 Red Hat, Inc.
+ 2005, 2006 Red Hat, Inc.
This file is part of Cygwin.
@@ -21,7 +21,7 @@ details. */
#include "cygheap.h"
static const char cygnus_class[] = "cygnus";
-reg_key::reg_key (HKEY top, REGSAM access, ...)
+reg_key::reg_key (HKEY top, REGSAM access, ...): _disposition (0)
{
va_list av;
va_start (av, access);
@@ -32,7 +32,7 @@ reg_key::reg_key (HKEY top, REGSAM access, ...)
/* Opens a key under the appropriate Cygwin key.
Do not use HKCU per MS KB 199190 */
-reg_key::reg_key (bool isHKLM, REGSAM access, ...)
+reg_key::reg_key (bool isHKLM, REGSAM access, ...): _disposition (0)
{
va_list av;
HKEY top;
@@ -91,7 +91,7 @@ reg_key::build_reg (HKEY top, REGSAM access, va_list av)
access,
&sec_none_nih,
&key,
- NULL);
+ &_disposition);
if (r != top)
RegCloseKey (r);
r = key;
diff --git a/winsup/cygwin/registry.h b/winsup/cygwin/registry.h
index 785a80e2a..3d1aea65d 100644
--- a/winsup/cygwin/registry.h
+++ b/winsup/cygwin/registry.h
@@ -1,6 +1,6 @@
/* registry.h: shared info for cygwin
- Copyright 2000, 2001 Red Hat, Inc.
+ Copyright 2000, 2001, 2004, 2006 Red Hat, Inc.
This file is part of Cygwin.
@@ -14,6 +14,7 @@ private:
HKEY key;
LONG key_is_invalid;
+ DWORD _disposition;
public:
@@ -33,6 +34,7 @@ public:
int get_string (const char *, char *buf, size_t len, const char *def);
int set_string (const char *,const char *);
int set_int (const char *, int val);
+ bool created () const {return _disposition & REG_CREATED_NEW_KEY;}
~reg_key ();
};