From: Paul Eggert Date: Tue, 15 Mar 2011 08:38:32 +0000 (-0700) Subject: * dired.c (directory_files_internal, file_name_completion): X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~554^2~78 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=38b2c0769fbfc40162fc8c39170fcb28bcf69520;p=emacs.git * dired.c (directory_files_internal, file_name_completion): Rename locals to avoid shadowing. --- diff --git a/src/ChangeLog b/src/ChangeLog index 7e873e3d85d..6355d81ba40 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2011-03-15 Paul Eggert + * 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. diff --git a/src/dired.c b/src/dired.c index 7891fc5f4a1..4080e1711e0 100644 --- a/src/dired.c +++ b/src/dired.c @@ -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;