summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin/ChangeLog6
-rw-r--r--admin/coccinelle/list_loop.cocci19
-rw-r--r--admin/coccinelle/vector_contents.cocci4
-rw-r--r--src/ChangeLog8
-rw-r--r--src/callint.c2
-rw-r--r--src/coding.c4
-rw-r--r--src/doc.c2
-rw-r--r--src/editfns.c2
-rw-r--r--src/eval.c4
-rw-r--r--src/font.c4
-rw-r--r--src/fontset.c2
-rw-r--r--src/frame.c2
-rw-r--r--src/gnutls.c6
-rw-r--r--src/minibuf.c2
-rw-r--r--src/msdos.c2
-rw-r--r--src/textprop.c2
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32menu.c3
-rw-r--r--src/window.c2
-rw-r--r--src/xmenu.c3
20 files changed, 56 insertions, 25 deletions
diff --git a/admin/ChangeLog b/admin/ChangeLog
index 6c5b1342d32..3a71c1c8d78 100644
--- a/admin/ChangeLog
+++ b/admin/ChangeLog
@@ -1,3 +1,9 @@
+2012-07-10 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * coccinelle/list_loop.cocci: Semantic patch to convert from Fcdr
+ to XCDR and consistently use CONSP in the list iteration loops.
+ * coccinelle/vector_contents.cocci: Fix indentation.
+
2012-07-10 Stefan Monnier <monnier@iro.umontreal.ca>
* bzrmerge.el: Use cl-lib.
diff --git a/admin/coccinelle/list_loop.cocci b/admin/coccinelle/list_loop.cocci
new file mode 100644
index 00000000000..89f0bfff7b3
--- /dev/null
+++ b/admin/coccinelle/list_loop.cocci
@@ -0,0 +1,19 @@
+// Omit redundant type check, consistently use CONSP.
+@@
+identifier A;
+expression X;
+statement S;
+@@
+(
+for (A = X;
+- !NILP (A);
++ CONSP (A);
+- A = Fcdr (A))
++ A = XCDR (A))
+S
+|
+for (A = X; CONSP (A);
+- A = Fcdr (A))
++ A = XCDR (A))
+S
+)
diff --git a/admin/coccinelle/vector_contents.cocci b/admin/coccinelle/vector_contents.cocci
index beebc2d2089..3c696ffd237 100644
--- a/admin/coccinelle/vector_contents.cocci
+++ b/admin/coccinelle/vector_contents.cocci
@@ -11,6 +11,6 @@ expression E1, E2;
- XVECTOR (I1)->contents[E1] = E2
+ ASET (I1, E1, E2)
|
--XVECTOR (I1)->contents[E1]
-+AREF (I1, E1)
+- XVECTOR (I1)->contents[E1]
++ AREF (I1, E1)
)
diff --git a/src/ChangeLog b/src/ChangeLog
index 1c451168e15..677b78ccbfb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2012-07-10 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Use XCAR and XCDR instead of Fcar and Fcdr where possible.
+ * callint.c, coding.c, doc.c, editfns.c, eval.c, font.c, fontset.c,
+ * frame.c, gnutls.c, minibuf.c, msdos.c, textprop.c, w32fns.c,
+ * w32menu.c, window.c, xmenu.c: Changed to use XCAR and XCDR
+ where argument type is known to be a Lisp_Cons.
+
2012-07-10 Tom Tromey <tromey@redhat.com>
* bytecode.c (BYTE_CODE_THREADED): New macro.
diff --git a/src/callint.c b/src/callint.c
index 1a99ca2731c..58e1a5be2f4 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -205,7 +205,7 @@ fix_command (Lisp_Object input, Lisp_Object values)
if (CONSP (elt))
{
Lisp_Object presflag, carelt;
- carelt = Fcar (elt);
+ carelt = XCAR (elt);
/* If it is (if X Y), look at Y. */
if (EQ (carelt, Qif)
&& EQ (Fnthcdr (make_number (3), elt), Qnil))
diff --git a/src/coding.c b/src/coding.c
index 8210cacc4d8..134ebf2ab73 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -9791,7 +9791,7 @@ usage: (define-coding-system-internal ...) */)
val = args[coding_arg_ccl_valids];
valids = Fmake_string (make_number (256), make_number (0));
- for (tail = val; !NILP (tail); tail = Fcdr (tail))
+ for (tail = val; CONSP (tail); tail = XCDR (tail))
{
int from, to;
@@ -9892,7 +9892,7 @@ usage: (define-coding-system-internal ...) */)
CHECK_NUMBER_CDR (reg_usage);
request = Fcopy_sequence (args[coding_arg_iso2022_request]);
- for (tail = request; ! NILP (tail); tail = Fcdr (tail))
+ for (tail = request; CONSP (tail); tail = XCDR (tail))
{
int id;
Lisp_Object tmp1;
diff --git a/src/doc.c b/src/doc.c
index 6b356d57cb3..7d82211faea 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -381,7 +381,7 @@ string is passed through `substitute-command-keys'. */)
}
else if (CONSP (fun))
{
- funcar = Fcar (fun);
+ funcar = XCAR (fun);
if (!SYMBOLP (funcar))
xsignal1 (Qinvalid_function, fun);
else if (EQ (funcar, Qkeymap))
diff --git a/src/editfns.c b/src/editfns.c
index f6d849fbc7a..e48097ab3a6 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1915,7 +1915,7 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */)
tm.tm_isdst = -1;
if (CONSP (zone))
- zone = Fcar (zone);
+ zone = XCAR (zone);
if (NILP (zone))
{
BLOCK_INPUT;
diff --git a/src/eval.c b/src/eval.c
index 9da9ec05cae..f16fdc6dd4c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2070,8 +2070,8 @@ eval_sub (Lisp_Object form)
error ("Lisp nesting exceeds `max-lisp-eval-depth'");
}
- original_fun = Fcar (form);
- original_args = Fcdr (form);
+ original_fun = XCAR (form);
+ original_args = XCDR (form);
backtrace.next = backtrace_list;
backtrace_list = &backtrace;
diff --git a/src/font.c b/src/font.c
index 1eca1c2eb29..ea6fc47884c 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1827,7 +1827,7 @@ check_otf_features (Lisp_Object otf_features)
CHECK_CONS (otf_features);
CHECK_SYMBOL (XCAR (otf_features));
otf_features = XCDR (otf_features);
- for (val = Fcar (otf_features); ! NILP (val); val = Fcdr (val))
+ for (val = Fcar (otf_features); CONSP (val); val = XCDR (val))
{
CHECK_SYMBOL (Fcar (val));
if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4)
@@ -1835,7 +1835,7 @@ check_otf_features (Lisp_Object otf_features)
SDATA (SYMBOL_NAME (XCAR (val))));
}
otf_features = XCDR (otf_features);
- for (val = Fcar (otf_features); ! NILP (val); val = Fcdr (val))
+ for (val = Fcar (otf_features); CONSP (val); val = XCDR (val))
{
CHECK_SYMBOL (Fcar (val));
if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4)
diff --git a/src/fontset.c b/src/fontset.c
index bd5956d2bee..056ef31e4f1 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1668,7 +1668,7 @@ FONT-SPEC is a vector, a cons, or a string. See the documentation of
Fset_char_table_range (fontset, Qt, Qnil);
}
- for (; ! NILP (fontlist); fontlist = Fcdr (fontlist))
+ for (; CONSP (fontlist); fontlist = XCDR (fontlist))
{
Lisp_Object elt, script;
diff --git a/src/frame.c b/src/frame.c
index 61baa25be3d..3a3f5526035 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2754,7 +2754,7 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist)
struct gcpro gcpro1, gcpro2;
i = 0;
- for (tail = alist; CONSP (tail); tail = Fcdr (tail))
+ for (tail = alist; CONSP (tail); tail = XCDR (tail))
i++;
parms = alloca (i * sizeof *parms);
diff --git a/src/gnutls.c b/src/gnutls.c
index 9c96379ff7e..21658a1bc82 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -871,7 +871,7 @@ one trustfile (usually a CA bundle). */)
int file_format = GNUTLS_X509_FMT_PEM;
Lisp_Object tail;
- for (tail = trustfiles; !NILP (tail); tail = Fcdr (tail))
+ for (tail = trustfiles; CONSP (tail); tail = XCDR (tail))
{
Lisp_Object trustfile = Fcar (tail);
if (STRINGP (trustfile))
@@ -893,7 +893,7 @@ one trustfile (usually a CA bundle). */)
}
}
- for (tail = crlfiles; !NILP (tail); tail = Fcdr (tail))
+ for (tail = crlfiles; CONSP (tail); tail = XCDR (tail))
{
Lisp_Object crlfile = Fcar (tail);
if (STRINGP (crlfile))
@@ -913,7 +913,7 @@ one trustfile (usually a CA bundle). */)
}
}
- for (tail = keylist; !NILP (tail); tail = Fcdr (tail))
+ for (tail = keylist; CONSP (tail); tail = XCDR (tail))
{
Lisp_Object keyfile = Fcar (Fcar (tail));
Lisp_Object certfile = Fcar (Fcdr (tail));
diff --git a/src/minibuf.c b/src/minibuf.c
index acf57a73268..27c776857db 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -425,7 +425,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
if (CONSP (initial))
{
Lisp_Object backup_n = Fcdr (initial);
- initial = Fcar (initial);
+ initial = XCAR (initial);
CHECK_STRING (initial);
if (!NILP (backup_n))
{
diff --git a/src/msdos.c b/src/msdos.c
index 8a6a150a956..e19e4ef8f3a 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1618,7 +1618,7 @@ IT_set_frame_parameters (struct frame *f, Lisp_Object alist)
/* Extract parm names and values into those vectors. */
i = 0;
- for (tail = alist; CONSP (tail); tail = Fcdr (tail))
+ for (tail = alist; CONSP (tail); tail = XCDR (tail))
{
Lisp_Object elt;
diff --git a/src/textprop.c b/src/textprop.c
index 4562cc0bd18..efce7259ce5 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -271,7 +271,7 @@ interval_has_some_properties_list (Lisp_Object list, INTERVAL i)
/* Go through each element of LIST. */
for (tail1 = list; CONSP (tail1); tail1 = XCDR (tail1))
{
- sym = Fcar (tail1);
+ sym = XCAR (tail1);
/* Go through i's plist, looking for tail1 */
for (tail2 = i->plist; CONSP (tail2); tail2 = XCDR (XCDR (tail2)))
diff --git a/src/w32fns.c b/src/w32fns.c
index 459d4c835f5..825f9815482 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -678,7 +678,7 @@ w32_color_map_lookup (char *colorname)
elt = XCAR (tail);
if (!CONSP (elt)) continue;
- tem = Fcar (elt);
+ tem = XCAR (elt);
if (lstrcmpi (SDATA (tem), colorname) == 0)
{
diff --git a/src/w32menu.c b/src/w32menu.c
index b957da67567..8adc6c62814 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -162,8 +162,7 @@ otherwise it is "Question". */)
}
else if (CONSP (position))
{
- Lisp_Object tem;
- tem = Fcar (position);
+ Lisp_Object tem = XCAR (position);
if (CONSP (tem))
window = Fcar (Fcdr (position));
else
diff --git a/src/window.c b/src/window.c
index 721b4d98477..7fd66057ad2 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4854,7 +4854,7 @@ specifies the window to scroll. This takes precedence over
else
{
if (CONSP (arg))
- arg = Fcar (arg);
+ arg = XCAR (arg);
CHECK_NUMBER (arg);
window_scroll (window, XINT (arg), 0, 1);
}
diff --git a/src/xmenu.c b/src/xmenu.c
index 5a6390449c4..fb03ab84d82 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -258,8 +258,7 @@ for instance using the window manager, then this produces a quit and
}
else if (CONSP (position))
{
- Lisp_Object tem;
- tem = Fcar (position);
+ Lisp_Object tem = XCAR (position);
if (CONSP (tem))
window = Fcar (Fcdr (position));
else