summaryrefslogtreecommitdiff
path: root/lib/strings.nix (follow)
Commit message (Expand)AuthorAgeFilesLines
...
| * lib.strings: fix negative number handling for `toInt` and `toIntBase10`•••The previous version would be unstable due to an input validation regex not expecting a '-' in front of the number. h7x42022-12-101-6/+7
* | Merge pull request #204087 from ncfavier/splitString-simplifyNaïm Favier2022-12-081-6/+4
|\ \
| * | lib/strings: simplify `splitString`•••There's no need to use `unsafeDiscardStringContext` since https://github.com/NixOS/nix/commit/ee7fe64c0ac00f2be11604a2a6509eb86dc19f0a (Nix 1.8). Also the separator can't have a context since `builtins.split` would fail, so we can assume it doesn't. Naïm Favier2022-12-021-6/+4
| |/
* / lib/strings.nix: add mesonOption utility function•••And some friends, to help write Meson commandline invocations. AndersonTorres2022-12-061-0/+55
|/
* Merge pull request #173949 from jacoblambda/fix-toInt-zero-padding•••lib: add strings.toIntBase10 to parse zero-padded stringsRobert Hensing2022-10-241-6/+87
|\
| * lib/strings: Update docs and restructured code to improve readability of toIn...Jacob Abel2022-10-231-21/+37
| * lib/strings: Improve error message for octal ambiguity in toIntJacob Abel2022-10-231-3/+2
| * lib/strings: Refactor toInt into toInt and toIntBase10Jacob Abel2022-10-231-3/+51
| * lib/strings: Update toInt to handle intermixed ws and zeros. Added testsJacob Abel2022-10-231-7/+13
| * lib/strings: allow toInt to parse zero-padded stringsJacob Abel2022-10-231-4/+16
* | lib.normalizePath: the empty string is not a valid regex on darwin•••presumably due to using libc++'s regex lib instead of libstdc++ on linux Fixes https://github.com/NixOS/nixpkgs/pull/177273#issuecomment-1287562800 Guillaume Girol2022-10-241-1/+1
|/
* lib.strings: Add normalizePath•••dedupes extranous /'s in filepaths Co-authored-by: Daniel Olsen <daniel.olsen99@gmail.com> ajs1242022-10-201-0/+10
* lib.strings: Add function to do C-style escapingDaniel Olsen2022-10-201-0/+13
* lib.strings: Add function to convert character to numberDaniel Olsen2022-10-201-0/+15
* lib/strings/toShellVars: handle derivations as stringsNaïm Favier2022-05-071-4/+5
* lib/strings: convert to string within hasInfix•••This should fix the issue mentioned here: https://github.com/NixOS/nixpkgs/pull/168175#issuecomment-1107830574 Daniel Thwaites2022-05-011-1/+1
* lib/strings: fix quoting of example•••Co-authored-by: Silvan Mosberger <github@infinisil.com>Naïm Camille Favier2022-04-271-1/+1
* lib/strings: add toShellVars•••A straightforward piece of plumbing to safely inject Nix variables into shell scripts: '' ${lib.toShellVars { inherit foo bar; }} cmd "$foo" --bar "$bar" '' Naïm Favier2022-04-271-0/+60
* lib/strings: optimise hasInfix function (#168175)•••* lib/strings: optimise hasInfix function * lib/strings: optimise hasInfix further using regex * rstudio: call hasInfix with a string * lib/strings: remove let from hasInfix Co-authored-by: pennae <82953136+pennae@users.noreply.github.com> Co-authored-by: pennae <82953136+pennae@users.noreply.github.com>Daniel Thwaites2022-04-221-4/+1
* Merge pull request #166383 from hercules-ci/always-sanitize-derivation-name•••Always sanitize derivation nameRobert Hensing2022-04-051-1/+8
|\
| * lib.sanitizeDerivationName: Simplify regex•••`^` and `$` are implicit in `match`. Robert Hensing2022-04-051-1/+1
| * lib.sanitizeDerivationName: Optimize the common caseRobert Hensing2022-03-311-1/+8
* | lib/strings: Add levenshtein distance functions•••Adds some functions related to string similarity: - lib.strings.commonPrefixLength - lib.strings.commonSuffixLength - lib.strings.levenshtein - lib.strings.levenshteinAtMost Silvan Mosberger2022-04-011-0/+127
|/
* lib: fix escapeXML example in documentation•••The previous example output was forgotten copy-paste from some other function. Robert Helgesson2021-11-021-1/+1
* lib: add function escapeXML•••Given a string, this function returns a string that can be inserted verbatim in an XML document. Robert Helgesson2021-10-031-0/+13
* lib/strings: fix infinite recursion on concatStringsSep fallback•••The current implementation of the concatStringsSep fallback references concatStrings whcih is just a partial application of concatStringsSep, forming a circular dependency. Although this will almost never be encountered as (assuming the user does not explicitly trigger it): 1. the or operator will short circuit both in lazy and strict evaluation 2. this can only occur in Nix versions prior to 1.10 which is not compatible with various nix operations as of 2.3.15 However it is still important if scopedImport is used or the builtins have been overwritten. lib.foldl' is used instead of builtins.foldl' as the foldl' primops was introduced in the same release as concatStringsSep. polykernel2021-08-261-1/+1
* strings.nix: Fix overly monomorphic type signature comments•••These functions work on lists of anything, not just lists of strings.Niklas Hambüchen2021-07-041-2/+2
* lib/strings: forbid lists in isStorePath•••When a list is passed to isStorePath this is most likely a mistake and it is therefore better to just return false. There is one case where this theoretically makes sense (if a list contains a single element for which isStorePath elem), but since that case is also probably seldomly intentional, it may save someone from debbuging unclear evaluation errors. sternenseemann2021-05-071-1/+1
* lib/strings: fix example for isStorePath•••Since it checks if dirOf x is the nix store dir, a trailing slash will break this check and make it return false. sternenseemann2021-05-071-1/+1
* lib: fix documented type of fixedWidthString (#121396)Lennart Spitzner2021-05-011-1/+1
* treewide: use lib.warnIf where appropriateAlyssa Ross2021-04-281-2/+2
* lib/string: drop redundant string in description of toInt.•••Describing the string argument as a string is redundant and not needed to describe what this function does. Alex Brandt2020-12-051-1/+1
* lib/strings: fix typo in example•••The example refers to a snake_case function name but Nix uses camelCase function names. This ensures the example is correct for the given function. Alex Brandt2020-12-041-2/+2
* lib/strings: fix examples for enableFeatureAs•••The As was missing in the examples on this library function. This will ensure the examples refer to the function they document. Alex Brandt2020-12-031-2/+2
* Merge pull request #44928 from vcunat/p/configure-assert•••lib/strings: guard against an easy mistakeEelco Dolstra2020-11-111-2/+6
|\
| * lib/strings: guard against an easy mistake•••This would catch the bad `fwknop` flags fixed in 580cab57e4, during evaluation already. Vladimír Čunát2018-08-121-2/+6
* | lib: Use Nix's static scope checking, fix error message, optimize•••Nix can perform static scope checking, but whenever code is inside a `with` expression, the analysis breaks down, because it can't know statically what's in the attribute set whose attributes were brought into scope. In those cases, Nix has to assume that everything works out. Except it doesnt. Removing `with` from lib/ revealed an undefined variable in an error message. If that doesn't convince you that we're better off without `with`, I can tell you that this PR results in a 3% evaluation performance improvement because Nix can look up local variables by index. This adds up with applications like the module system. Furthermore, removing `with` makes the binding site of each variable obvious, which helps with comprehension. Robert Hensing2020-10-221-21/+43
* | lib.splitString: use builtin.splitEtienne Laurin2020-10-181-21/+14
* | lib/strings: deprecate readPathsFromFile•••> NOTE: This function is not performant and should be avoided. It's not used at all in-tree now, so we can remove it completely after any remaining users are given notice. V2020-09-031-8/+9
* | lib/strings: Add floatToStringSilvan Mosberger2020-07-251-0/+16
* | lib/strings: Introduce escapeNixIdentifierSilvan Mosberger2020-04-131-0/+15
* | Merge pull request #83241 from Infinisil/valid-drv-name•••lib/strings: Add `sanitizeDerivationName` functionSilvan Mosberger2020-04-021-0/+32
|\ \
| * | lib/strings: Add sanitizeDerivationName functionSilvan Mosberger2020-03-301-0/+32
* | | Revert "Revert "Merge master into staging-next""•••In 87a19e9048773d5a363679617406ad148d36c3b8 I merged staging-next into master using the GitHub gui as intended. In ac241fb7a570d6cf81d229ad22a8889602639160 I merged master into staging-next for the next staging cycle, however, I accidentally pushed it to master. Thinking this may cause trouble, I reverted it in 0be87c79797a5fa384fbc356c74ed54f9f7829ea. This was however wrong, as it "removed" master. This reverts commit 0be87c79797a5fa384fbc356c74ed54f9f7829ea. Frederik Rietdijk2020-02-051-1/+1
* | | Revert "Merge master into staging-next"•••I merged master into staging-next but accidentally pushed it to master. This should get us back to 87a19e9048773d5a363679617406ad148d36c3b8. This reverts commit ac241fb7a570d6cf81d229ad22a8889602639160, reversing changes made to 76a439239eb310d9ad76d998b34d5d3bc0e37acb. Frederik Rietdijk2020-02-051-1/+1
* | | lib/strings: fix comment typoRobert Helgesson2020-02-051-1/+1
|/ /
* | lib: Add getName to mirror getVersionJohn Ericson2019-11-241-0/+17
* | Doc fix: use correct function name in type signature for concatIMapStringsSepNathan van Doorn2019-03-181-1/+1
* | lib.makePerlPath -> perlPackages.makePerlPathvolth2018-12-151-20/+0
* | make-derivation: use pname-version as default name if both are presentPatrick Hilhorst2018-11-061-0/+20