aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto I <roberto@inf.puc-rio.br>2025-11-11 14:40:30 -0300
committerRoberto I <roberto@inf.puc-rio.br>2025-11-11 14:40:30 -0300
commit5b7d9987642f72d44223a8e5e79e013bb2b3d579 (patch)
tree0a755e85069f2c19609500151fec5b1e6ff30f88 /lgc.c
parent81f4def54f440e045b1401f11ef78b65b56b7abe (diff)
downloadlua-5b7d9987642f72d44223a8e5e79e013bb2b3d579.tar.gz
lua-5b7d9987642f72d44223a8e5e79e013bb2b3d579.tar.bz2
lua-5b7d9987642f72d44223a8e5e79e013bb2b3d579.zip
External strings are as good as internal ones
A '__mode' metafield and an "n" key both can be external strings.
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lgc.c b/lgc.c
index a775b6e5..60f042c7 100644
--- a/lgc.c
+++ b/lgc.c
@@ -594,10 +594,10 @@ static void traversestrongtable (global_State *g, Table *h) {
594*/ 594*/
595static int getmode (global_State *g, Table *h) { 595static int getmode (global_State *g, Table *h) {
596 const TValue *mode = gfasttm(g, h->metatable, TM_MODE); 596 const TValue *mode = gfasttm(g, h->metatable, TM_MODE);
597 if (mode == NULL || !ttisshrstring(mode)) 597 if (mode == NULL || !ttisstring(mode))
598 return 0; /* ignore non-(short)string modes */ 598 return 0; /* ignore non-string modes */
599 else { 599 else {
600 const char *smode = getshrstr(tsvalue(mode)); 600 const char *smode = getstr(tsvalue(mode));
601 const char *weakkey = strchr(smode, 'k'); 601 const char *weakkey = strchr(smode, 'k');
602 const char *weakvalue = strchr(smode, 'v'); 602 const char *weakvalue = strchr(smode, 'v');
603 return ((weakkey != NULL) << 1) | (weakvalue != NULL); 603 return ((weakkey != NULL) << 1) | (weakvalue != NULL);