[svn] GnuPG - r4570 - in branches/STABLE-BRANCH-1-4: . g10 include po util
svn author wk
cvs at cvs.gnupg.org
Fri Aug 24 11:52:30 CEST 2007
Author: wk
Date: 2007-08-24 11:51:58 +0200 (Fri, 24 Aug 2007)
New Revision: 4570
Modified:
branches/STABLE-BRANCH-1-4/NEWS
branches/STABLE-BRANCH-1-4/g10/ChangeLog
branches/STABLE-BRANCH-1-4/g10/keyring.c
branches/STABLE-BRANCH-1-4/include/ChangeLog
branches/STABLE-BRANCH-1-4/include/util.h
branches/STABLE-BRANCH-1-4/po/de.glo
branches/STABLE-BRANCH-1-4/util/ChangeLog
branches/STABLE-BRANCH-1-4/util/fileutil.c
Log:
Improved detection of ketrings specified several times.
Modified: branches/STABLE-BRANCH-1-4/NEWS
===================================================================
--- branches/STABLE-BRANCH-1-4/NEWS 2007-08-24 09:34:39 UTC (rev 4569)
+++ branches/STABLE-BRANCH-1-4/NEWS 2007-08-24 09:51:58 UTC (rev 4570)
@@ -3,8 +3,9 @@
* Changed the license to GPLv3.
+ * Improved detection of keyrings specified multiple times.
+
* Minor bug fixes.
-
Noteworthy changes in version 1.4.7 (2007-03-05)
------------------------------------------------
Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-08-24 09:34:39 UTC (rev 4569)
+++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-08-24 09:51:58 UTC (rev 4570)
@@ -1,3 +1,8 @@
+2007-08-24 Werner Koch <wk at g10code.com>
+
+ * keyring.c (keyring_register_filename): Use same_file_p.
+ Suggested by Kurt Fitzner.
+
2007-07-19 David Shaw <dshaw at jabberwocky.com>
* gpg.c (main): Fix typo. Noted by John Clizbe.
Modified: branches/STABLE-BRANCH-1-4/g10/keyring.c
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/keyring.c 2007-08-24 09:34:39 UTC (rev 4569)
+++ branches/STABLE-BRANCH-1-4/g10/keyring.c 2007-08-24 09:51:58 UTC (rev 4570)
@@ -207,7 +207,7 @@
for (kr=kr_names; kr; kr = kr->next)
{
- if ( !compare_filenames (kr->fname, fname) )
+ if (same_file_p (kr->fname, fname) )
{
*ptr=kr;
return 0; /* already registered */
Modified: branches/STABLE-BRANCH-1-4/include/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/include/ChangeLog 2007-08-24 09:34:39 UTC (rev 4569)
+++ branches/STABLE-BRANCH-1-4/include/ChangeLog 2007-08-24 09:51:58 UTC (rev 4570)
@@ -1,3 +1,7 @@
+2007-08-24 Werner Koch <wk at g10code.com>
+
+ * util.h (same_file_p): Add prototype.
+
2007-06-13 David Shaw <dshaw at jabberwocky.com>
* cipher.h (CIPHER_ALGO_CAMELLIA): Add Camellia define.
Modified: branches/STABLE-BRANCH-1-4/include/util.h
===================================================================
--- branches/STABLE-BRANCH-1-4/include/util.h 2007-08-24 09:34:39 UTC (rev 4569)
+++ branches/STABLE-BRANCH-1-4/include/util.h 2007-08-24 09:51:58 UTC (rev 4570)
@@ -143,6 +143,7 @@
char * make_dirname(const char *filepath);
char *make_filename( const char *first_part, ... );
int compare_filenames( const char *a, const char *b );
+int same_file_p (const char *name1, const char *name2);
const char *print_fname_stdin( const char *s );
const char *print_fname_stdout( const char *s );
int is_file_compressed(const char *s, int *r_status);
Modified: branches/STABLE-BRANCH-1-4/po/de.glo
===================================================================
--- branches/STABLE-BRANCH-1-4/po/de.glo 2007-08-24 09:34:39 UTC (rev 4569)
+++ branches/STABLE-BRANCH-1-4/po/de.glo 2007-08-24 09:51:58 UTC (rev 4570)
@@ -143,7 +143,7 @@
packet Paket
packet type Pakettyp
parse -zerlegen
-passphrase Mantra
+passphrase Passphrase -# Mantra
permission [file] Zugriffsrechte
Photo-ID Foto-ID
policy Richtlinie
Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-08-24 09:34:39 UTC (rev 4569)
+++ branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-08-24 09:51:58 UTC (rev 4570)
@@ -1,3 +1,9 @@
+2007-08-24 Werner Koch <wk at g10code.com>
+
+ * fileutil.c (same_file_p): New. Taken from SVN trunk.
+ (compare_filenames) [HAVE_DRIVE_LETTERS]: Take drive letters and
+ backslashes in account.
+
2007-04-16 David Shaw <dshaw at jabberwocky.com>
* strgutil.c (ascii_toupper, ascii_tolower, ascii_strcasecmp,
Modified: branches/STABLE-BRANCH-1-4/util/fileutil.c
===================================================================
--- branches/STABLE-BRANCH-1-4/util/fileutil.c 2007-08-24 09:34:39 UTC (rev 4569)
+++ branches/STABLE-BRANCH-1-4/util/fileutil.c 2007-08-24 09:51:58 UTC (rev 4570)
@@ -1,5 +1,5 @@
/* fileutil.c - file utilities
- * Copyright (C) 1998, 2003, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 2003, 2005, 2007 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -30,6 +30,17 @@
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
+#include <ctype.h>
+#ifdef HAVE_W32_SYSTEM
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#else /*!HAVE_W32_SYSTEM*/
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <unistd.h>
+#endif /*!HAVE_W32_SYSTEM*/
+
+
#include "util.h"
#include "memory.h"
#include "ttyio.h"
@@ -194,32 +205,87 @@
}
+/* Compare whether the filenames are identical. This is a
+ special version of strcmp() taking the semantics of filenames in
+ account. Note that this function works only on the supplied names
+ without considereing any context like the current directory. See
+ also same_file_p(). */
int
-compare_filenames( const char *a, const char *b )
+compare_filenames (const char *a, const char *b)
{
- /* ? check whether this is an absolute filename and
- * resolve symlinks?
- */
-#ifndef __riscos__
-#ifdef HAVE_DRIVE_LETTERS
- return ascii_strcasecmp(a,b);
-#else
- return strcmp(a,b);
+#ifdef __riscos__
+ int c = 0;
+ char *abuf, *bbuf;
+
+ abuf = riscos_gstrans(a);
+ bbuf = riscos_gstrans(b);
+ c = ascii_strcasecmp (abuf, bbuf);
+ xfree(abuf);
+ xfree(bbuf);
+
+ return c;
+#elif defined (HAVE_DRIVE_LETTERS)
+ for ( ; *a && *b; a++, b++ )
+ {
+ if (*a != *b
+ && (toupper (*(const unsigned char*)a)
+ != toupper (*(const unsigned char*)b) )
+ && !((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/')))
+ break;
+ }
+ if ((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/'))
+ return 0;
+ else
+ return (toupper (*(const unsigned char*)a)
+ - toupper (*(const unsigned char*)b));
+#else /*!HAVE_DRIVE_LETTERS*/
+ return strcmp (a,b);
#endif
-#else /* __riscos__ */
- int c = 0;
- char *abuf, *bbuf;
+}
- abuf = riscos_gstrans(a);
- bbuf = riscos_gstrans(b);
-
- c = ascii_strcasecmp (abuf, bbuf);
-
- xfree(abuf);
- xfree(bbuf);
-
- return c;
-#endif /* __riscos__ */
+/* Check whether the files NAME1 and NAME2 are identical. This is for
+ example achieved by comparing the inode numbers of the files. */
+int
+same_file_p (const char *name1, const char *name2)
+{
+ int yes;
+
+ /* First try a shortcut. */
+ if (!compare_filenames (name1, name2))
+ yes = 1;
+ else
+ {
+#ifdef HAVE_W32_SYSTEM
+ HANDLE file1, file2;
+ BY_HANDLE_FILE_INFORMATION info1, info2;
+
+ file1 = CreateFile (name1, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
+ if (file1 == INVALID_HANDLE_VALUE)
+ yes = 0; /* If we can't open the file, it is not the same. */
+ else
+ {
+ file2 = CreateFile (name2, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
+ if (file1 == INVALID_HANDLE_VALUE)
+ yes = 0; /* If we can't open the file, it is not the same. */
+ else
+ {
+ yes = (GetFileInformationByHandle (file1, &info1)
+ && GetFileInformationByHandle (file2, &info2)
+ && info1.dwVolumeSerialNumber==info2.dwVolumeSerialNumber
+ && info1.nFileIndexHigh == info2.nFileIndexHigh
+ && info1.nFileIndexLow == info2.nFileIndexLow);
+ CloseHandle (file2);
+ }
+ CloseHandle (file1);
+ }
+#else /*!HAVE_W32_SYSTEM*/
+ struct stat info1, info2;
+
+ yes = (!stat (name1, &info1) && !stat (name2, &info2)
+ && info1.st_dev == info2.st_dev && info1.st_ino == info2.st_ino);
+#endif /*!HAVE_W32_SYSTEM*/
+ }
+ return yes;
}
More information about the Gnupg-commits
mailing list