about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2022-12-12 03:36:03 +0200
committerArtturin <Artturin@artturin.com>2022-12-15 22:25:51 +0200
commit05a2dfd6744cdc6ab0b57f8ab866cc686b05f519 (patch)
tree9fac9a1b33e1f3053479fe68f7b4ddca25852fac /lib
parent084fd6904550d915954791b6923e7a1ac4e9f3ec (diff)
lib.replaceChars: warn about being a deprecated alias
replaceStrings has been in nix since 2015(nix 1.10)

so it is safe to remove the fallback

https://github.com/nixos/nix/commit/d6d5885c1567454754a0d260521bafa0bd5e7fdb
Diffstat (limited to 'lib')
-rw-r--r--lib/strings.nix23
1 files changed, 6 insertions, 17 deletions
diff --git a/lib/strings.nix b/lib/strings.nix
index 376c537287e94..64bf5bbafd3da 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -328,7 +328,7 @@ rec {
        escape ["(" ")"] "(foo)"
        => "\\(foo\\)"
   */
-  escape = list: replaceChars list (map (c: "\\${c}") list);
+  escape = list: replaceStrings list (map (c: "\\${c}") list);
 
   /* Escape occurence of the element of `list` in `string` by
      converting to its ASCII value and prefixing it with \\x.
@@ -341,7 +341,7 @@ rec {
        => "foo\\x20bar"
 
   */
-  escapeC = list: replaceChars list (map (c: "\\x${ toLower (lib.toHexString (charToInt c))}") list);
+  escapeC = list: replaceStrings list (map (c: "\\x${ toLower (lib.toHexString (charToInt c))}") list);
 
   /* Quote string to be used safely within the Bourne shell.
 
@@ -471,19 +471,8 @@ rec {
     ["\"" "'" "<" ">" "&"]
     ["&quot;" "&apos;" "&lt;" "&gt;" "&amp;"];
 
-  # Obsolete - use replaceStrings instead.
-  replaceChars = builtins.replaceStrings or (
-    del: new: s:
-    let
-      substList = lib.zipLists del new;
-      subst = c:
-        let found = lib.findFirst (sub: sub.fst == c) null substList; in
-        if found == null then
-          c
-        else
-          found.snd;
-    in
-      stringAsChars subst s);
+  # warning added 12-12-2022
+  replaceChars = lib.warn "replaceChars is a deprecated alias of replaceStrings, replace usages of it with replaceStrings." builtins.replaceStrings;
 
   # Case conversion utilities.
   lowerChars = stringToCharacters "abcdefghijklmnopqrstuvwxyz";
@@ -497,7 +486,7 @@ rec {
        toLower "HOME"
        => "home"
   */
-  toLower = replaceChars upperChars lowerChars;
+  toLower = replaceStrings upperChars lowerChars;
 
   /* Converts an ASCII string to upper-case.
 
@@ -507,7 +496,7 @@ rec {
        toUpper "home"
        => "HOME"
   */
-  toUpper = replaceChars lowerChars upperChars;
+  toUpper = replaceStrings lowerChars upperChars;
 
   /* Appends string context from another string.  This is an implementation
      detail of Nix and should be used carefully.