Commit 38b2c076 authored by Paul Eggert's avatar Paul Eggert
Browse files

* dired.c (directory_files_internal, file_name_completion):

Rename locals to avoid shadowing.
parent 15206ed9
2011-03-15 Paul Eggert <eggert@cs.ucla.edu>
 
* dired.c (directory_files_internal, file_name_completion):
Rename locals to avoid shadowing.
Fix a race condition diagnosed by gcc -Wsequence-point (Bug#8254).
An expression of the form (DOWNCASE (x) == DOWNCASE (y)), found in
dired.c's scmp function, had undefined behavior.
......@@ -233,11 +233,11 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object m
int len;
int wanted = 0;
Lisp_Object name, finalname;
struct gcpro gcpro1, gcpro2;
struct gcpro inner_gcpro1, inner_gcpro2;
len = NAMLEN (dp);
name = finalname = make_unibyte_string (dp->d_name, len);
GCPRO2 (finalname, name);
GCPRO2_VAR (finalname, name, inner_gcpro);
/* Note: DECODE_FILE can GC; it should protect its argument,
though. */
......@@ -293,23 +293,23 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object m
/* Construct an expanded filename for the directory entry.
Use the decoded names for input to Ffile_attributes. */
Lisp_Object decoded_fullname, fileattrs;
struct gcpro gcpro1, gcpro2;
struct gcpro innermost_gcpro1, innermost_gcpro2;
decoded_fullname = fileattrs = Qnil;
GCPRO2 (decoded_fullname, fileattrs);
GCPRO2_VAR (decoded_fullname, fileattrs, innermost_gcpro);
/* Both Fexpand_file_name and Ffile_attributes can GC. */
decoded_fullname = Fexpand_file_name (name, directory);
fileattrs = Ffile_attributes (decoded_fullname, id_format);
list = Fcons (Fcons (finalname, fileattrs), list);
UNGCPRO;
UNGCPRO_VAR (innermost_gcpro);
}
else
list = Fcons (finalname, list);
}
UNGCPRO;
UNGCPRO_VAR (inner_gcpro);
}
}
......@@ -676,11 +676,11 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
if (!NILP (predicate))
{
Lisp_Object val;
struct gcpro gcpro1;
struct gcpro inner_gcpro1;
GCPRO1 (name);
GCPRO1_VAR (name, inner_gcpro);
val = call1 (predicate, name);
UNGCPRO;
UNGCPRO_VAR (inner_gcpro);
if (NILP (val))
continue;
......@@ -702,16 +702,16 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
Lisp_Object zero = make_number (0);
/* FIXME: This is a copy of the code in Ftry_completion. */
int compare = min (bestmatchsize, SCHARS (name));
Lisp_Object tem
Lisp_Object cmp
= Fcompare_strings (bestmatch, zero,
make_number (compare),
name, zero,
make_number (compare),
completion_ignore_case ? Qt : Qnil);
int matchsize
= (EQ (tem, Qt) ? compare
: XINT (tem) < 0 ? - XINT (tem) - 1
: XINT (tem) - 1);
= (EQ (cmp, Qt) ? compare
: XINT (cmp) < 0 ? - XINT (cmp) - 1
: XINT (cmp) - 1);
if (completion_ignore_case)
{
......@@ -735,18 +735,18 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
(((matchsize == SCHARS (name))
==
(matchsize + !!directoryp == SCHARS (bestmatch)))
&& (tem = Fcompare_strings (name, zero,
&& (cmp = Fcompare_strings (name, zero,
make_number (SCHARS (file)),
file, zero,
Qnil,
Qnil),
EQ (Qt, tem))
&& (tem = Fcompare_strings (bestmatch, zero,
EQ (Qt, cmp))
&& (cmp = Fcompare_strings (bestmatch, zero,
make_number (SCHARS (file)),
file, zero,
Qnil,
Qnil),
! EQ (Qt, tem))))
! EQ (Qt, cmp))))
bestmatch = name;
}
bestmatchsize = matchsize;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment