[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compile errors with MSVC
From: |
Gisle Vanem |
Subject: |
Re: Compile errors with MSVC |
Date: |
Fri, 19 Mar 2021 14:14:57 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
I wrote:
dir.c(528,24): error: use of undeclared identifier 'p'
memcpy (tem, name, p - name + 1);
^
dir.c(532,24): error: use of undeclared identifier 'p'
for (tend = tem + (p - name - 1);
^
I fixed this by:
--- a/src/dir.c 2021-03-18 12:53:01
+++ b/src/dir.c 2021-03-19 13:59:40
@@ -474,6 +474,7 @@
struct stat st;
int r;
+ size_t len;
#ifdef WINDOWS32
char *w32_path;
#endif
@@ -482,6 +483,8 @@
dir_slot = (struct directory **) hash_find_slot (&directories, &dir_key);
dir = *dir_slot;
+ len = strlen (name);
+
if (!HASH_VACANT (dir))
{
unsigned long ctr = dir->contents ? dir->contents->counter :
dir->counter;
@@ -499,7 +502,6 @@
else
{
/* The directory was not found. Create a new entry for it. */
- size_t len = strlen (name);
dir = xmalloc (sizeof (struct directory));
#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
@@ -525,11 +527,11 @@
/* Remove any trailing slashes. Windows32 stat fails even on
valid directories if they end in a slash. */
- memcpy (tem, name, p - name + 1);
+ memcpy (tem, name, len + 1);
tstart = tem;
if (tstart[1] == ':')
tstart += 2;
- for (tend = tem + (p - name - 1);
+ for (tend = tem + len - 1;
tend > tstart && (*tend == '/' || *tend == '\\');
tend--)
*tend = '\0';
-------------
Avoiding the use of 'p'.
--
--gv