[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/shorthand-namespacing 2e607b3 3/8: Robustify checking of shortha
From: |
João Távora |
Subject: |
feature/shorthand-namespacing 2e607b3 3/8: Robustify checking of shorthand-shorthands |
Date: |
Tue, 21 Sep 2021 11:27:00 -0400 (EDT) |
branch: feature/shorthand-namespacing
commit 2e607b3a2dfd4b0e4090fba2c8813047b87773d7
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Robustify checking of shorthand-shorthands
* src/lread.c (oblookup_considering_shorthand): Maybe warn when we
find fishy shorthand-shorthands.
---
src/lread.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/lread.c b/src/lread.c
index f7d0a8c..33a7bd0 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -4553,19 +4553,30 @@ oblookup (Lisp_Object obarray, register const char
*ptr, ptrdiff_t size, ptrdiff
Lisp_Object
oblookup_considering_shorthand (Lisp_Object obarray, Lisp_Object* string)
{
+ Lisp_Object original = *string; /* Save pointer to original string... */
Lisp_Object tail = Vshorthand_shorthands;
FOR_EACH_TAIL_SAFE(tail)
{
Lisp_Object pair = XCAR (tail);
+ if (!CONSP (pair)) goto undo;
Lisp_Object shorthand = XCAR (pair);
Lisp_Object longhand = XCDR (pair);
- CHECK_STRING (shorthand);
- CHECK_STRING (longhand);
- Lisp_Object match = Fstring_match(shorthand, *string, Qnil);
+ if (!STRINGP (shorthand) || !STRINGP (longhand)) goto undo;
+ Lisp_Object match = Fstring_match (shorthand, *string, Qnil);
if (!NILP(match)){
*string = Freplace_match(longhand, Qnil, Qnil, *string, Qnil);
}
}
+ goto fine;
+ undo:
+ {
+ static const char* warn =
+ "Fishy value of `shorthand-shorthands'. "
+ "Consider reviewing before evaluating code.";
+ message_dolog (warn, sizeof(warn), 0, 0);
+ *string = original; /* ...so we can any failed trickery here. */
+ }
+ fine:
return oblookup(obarray, SSDATA (*string), SCHARS (*string), SBYTES
(*string));
}
- branch feature/shorthand-namespacing created (now 4d5f6ad), João Távora, 2021/09/21
- feature/shorthand-namespacing b759f0b 1/8: First Elisp version of lisp/shorthand.el, failing some tests, João Távora, 2021/09/21
- feature/shorthand-namespacing b5e4902 2/8: Move most of the shorthand implementation to C code, João Távora, 2021/09/21
- feature/shorthand-namespacing 6bc684c 7/8: Rework docstring of hack-elisp-shorthands, João Távora, 2021/09/21
- feature/shorthand-namespacing 4d5f6ad 8/8: Adjust C style and add comments to shorthand code, João Távora, 2021/09/21
- feature/shorthand-namespacing a527a1a 6/8: Rework elisp-shorthands to only allow only prefix substitution, João Távora, 2021/09/21
- feature/shorthand-namespacing 2e607b3 3/8: Robustify checking of shorthand-shorthands,
João Távora <=
- feature/shorthand-namespacing 4b61464 5/8: Add a test for byte-compilation, João Távora, 2021/09/21
- feature/shorthand-namespacing 8076838 4/8: Integrate shorthand functionality into elisp-mode.el, João Távora, 2021/09/21