[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
20/376: == operator: Ignore string context
From: |
Ludovic Courtès |
Subject: |
20/376: == operator: Ignore string context |
Date: |
Wed, 28 Jan 2015 22:03:46 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit ee7fe64c0ac00f2be11604a2a6509eb86dc19f0a
Author: Eelco Dolstra <address@hidden>
Date: Tue Jun 10 14:02:56 2014 +0200
== operator: Ignore string context
There really is no case I can think of where taking the context into
account is useful. Mostly it's just very inconvenient.
---
src/libexpr/eval.cc | 13 ++-----------
src/libexpr/primops.cc | 2 +-
tests/lang/eval-okay-context.nix | 2 +-
3 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 81ce7d9..87b6bc9 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1355,17 +1355,8 @@ bool EvalState::eqValues(Value & v1, Value & v2)
case tBool:
return v1.boolean == v2.boolean;
- case tString: {
- /* Compare both the string and its context. */
- if (strcmp(v1.string.s, v2.string.s) != 0) return false;
- const char * * p = v1.string.context, * * q = v2.string.context;
- if (!p && !q) return true;
- if (!p || !q) return false;
- for ( ; *p && *q; ++p, ++q)
- if (strcmp(*p, *q) != 0) return false;
- if (*p || *q) return false;
- return true;
- }
+ case tString:
+ return strcmp(v1.string.s, v2.string.s) == 0;
case tPath:
return strcmp(v1.path, v2.path) == 0;
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 993d290..feb0227 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -1297,7 +1297,7 @@ void EvalState::createBaseEnv()
language feature gets added. It's not necessary to increase it
when primops get added, because you can just use `builtins ?
primOp' to check. */
- mkInt(v, 2);
+ mkInt(v, 3);
addConstant("__langVersion", v);
// Miscellaneous
diff --git a/tests/lang/eval-okay-context.nix b/tests/lang/eval-okay-context.nix
index b3f1748..8cd8f2e 100644
--- a/tests/lang/eval-okay-context.nix
+++ b/tests/lang/eval-okay-context.nix
@@ -1,6 +1,6 @@
let s = "foo ${builtins.substring 33 100 (baseNameOf ./eval-okay-context.nix)}
bar";
in
- if s == "foo eval-okay-context.nix bar"
+ if s != "foo eval-okay-context.nix bar"
then abort "context not discarded"
else builtins.unsafeDiscardStringContext s
- 15/376: Sort nixPath attributes, (continued)
- 15/376: Sort nixPath attributes, Ludovic Courtès, 2015/01/28
- 16/376: Fix test, Ludovic Courtès, 2015/01/28
- 21/376: Add autoloads, make code more concise & idiomatic, Ludovic Courtès, 2015/01/28
- 18/376: Print a warning when loading a large path into memory, Ludovic Courtès, 2015/01/28
- 19/376: Report daemon OOM better, Ludovic Courtès, 2015/01/28
- 22/376: Share code between scopedImport and import, Ludovic Courtès, 2015/01/28
- 28/376: Only add the importNative primop if the allow-arbitrary-code-during-evaluation option is true (default false), Ludovic Courtès, 2015/01/28
- 26/376: Don't use member initialisers, Ludovic Courtès, 2015/01/28
- 27/376: Add importNative primop, Ludovic Courtès, 2015/01/28
- 29/376: Merge branch 'shlevy-import-native', Ludovic Courtès, 2015/01/28
- 20/376: == operator: Ignore string context,
Ludovic Courtès <=
- 30/376: allow-arbitrary-code-during-evaluation -> allow-unsafe-native-code-during-evaluation, Ludovic Courtès, 2015/01/28
- 32/376: Style fix, Ludovic Courtès, 2015/01/28
- 24/376: Drop ImportError and FindError, Ludovic Courtès, 2015/01/28
- 31/376: Add `--json` argument to `nix-instantiate`, Ludovic Courtès, 2015/01/28
- 33/376: Manual: html -> xhtml, Ludovic Courtès, 2015/01/28
- 25/376: Fix bogus warnings about dumping large paths, Ludovic Courtès, 2015/01/28
- 36/376: Fix compilation error on some versions of GCC, Ludovic Courtès, 2015/01/28
- 37/376: Add a test for the SSH substituter, Ludovic Courtès, 2015/01/28
- 38/376: Fix security hole in ‘nix-store --serve’, Ludovic Courtès, 2015/01/28
- 35/376: Don't build on Ubuntu 10.10, Ludovic Courtès, 2015/01/28