Commit Graph

241 Commits

Author SHA1 Message Date
narimiran
2074ad1416 strutils: document parseEnum [ci skip] 2019-02-25 11:35:37 +01:00
Araq
68ce92d4eb fixes a critical strutils bug [backport] 2019-02-19 19:37:25 +01:00
Araq
e4a76c6ebf fixes #6832 2019-02-19 17:17:12 +01:00
narimiran
52a54f5f04 documentation: remove author field [ci skip] 2019-01-17 07:15:40 +01:00
narimiran
be6456f0f4 better docs: strutils 2019-01-16 09:45:51 +01:00
Araq
f7d0e5c1d1 strutils: minor code cleanup 2018-12-19 18:06:13 +01:00
Araq
3f6168b337 removes deprecated T/P types 2018-11-16 13:27:56 +01:00
Araq
56f76c5b08 better implementation for wrapWords 2018-11-08 20:52:22 +01:00
Timothee Cour
e4e19f8288 stripLineEnd aka chomp (#9623) 2018-11-05 08:01:31 +01:00
Federico Ceratto
62693457df Add 'dedent' to documentation index (#9615) 2018-11-04 08:36:13 +01:00
Arne Döring
80843373ba changelog entry 2018-10-31 14:29:40 +01:00
Arne Döring
84db658eb4 fix typo 2018-10-31 10:44:44 +01:00
Arne Döring
e653121633 fixes #9557 2018-10-30 17:13:02 +01:00
Neelesh Chandola
95cc1abdc7 Fixes #9525 (#9526) 2018-10-28 14:27:17 +01:00
eqperes
afd9d8dd8d Some documentation added to strutils (#9379)
* wip documentation strutils

* some runnableExamples in strutils

* assert -> doAssert

* corrected doc for abbrev; some more runnable examples

* runnableExamples for join

* fix c&p error

* corrections
2018-10-16 17:30:38 +02:00
skilchen
f04c93b5dd math.round is not needed in strutils (#9383) 2018-10-16 09:19:53 +02:00
Federico Ceratto
b62328cb76 Add strip() example (#8002) 2018-10-14 11:05:28 +02:00
Andreas Rumpf
152c7d99c3 struils: don't use the deprecated accumulateResult 2018-10-14 10:28:50 +02:00
Andreas Rumpf
7656925140 added new editdistance stdlib module, deprecated strutils.editDistance, refs #6301 2018-10-14 10:26:45 +02:00
Andreas Rumpf
7f81519f41 strutils/unicode: deprecate isLower and friends operating on complete strings; fixes #7963 properly 2018-10-14 09:48:54 +02:00
Timothee Cour
e4c76f8a2a add strutils.stripLineEnd (#9346) 2018-10-13 14:59:56 +02:00
eqperes
14925ee8b6 Proposed solution for issue #8919 (#9280)
* Proposed solution for issue #8919

* count sub/subs must be non-empty
2018-10-12 17:28:21 +02:00
Andreas Rumpf
0330fb2e13 fixes #8911 2018-09-16 12:28:43 +02:00
LemonBoy
36e6ca16d1 Fix too broad generic match for toHex (#8889)
Fixes #8865
2018-09-05 20:57:50 +02:00
Araq
06e6c38d99 strutils: don't deprecate escape/unescape, too much code uses it 2018-08-31 17:30:58 +02:00
Araq
a0cde8cee6 Merge branch 'devel' into araq-misc 2018-08-13 20:16:18 +02:00
Iván Montes
ee29370f60 Fixed 7478: splitLines keepEol option (#8621) 2018-08-13 11:42:50 +02:00
Araq
babd31360a fixes more nil string bugs 2018-08-08 18:22:48 +02:00
Araq
00d718b1db strutils: minor code cleanup 2018-08-08 12:01:17 +02:00
genotrance
c115090f6e Testament should run tests with no action (#8232)
* Testament should run tests with no action

* Fix strutils tests for JS
2018-07-08 20:38:46 -04:00
Dominik Picheta
03b073d541 Workaround VM bug in strutils 2018-06-17 23:26:18 +01:00
Dominik Picheta
8081a9b3d0 Exports unicode.toUpper/toLower in strutils module. 2018-06-17 00:12:51 +01:00
Vindaar
e80be6173d Add parse bin int, fixes #8018 (#8020)
* clarify `parseHexInt`, `parseOctInt` docstring and exception msgs

* add `parseBinInt` based on `parseutil.parseBin` implementation

Adds a `parseBinInt`, which parses a binary integer string and returns
it as an integer. This is based on the implementation of
`parseutil.parseBin`, removing the unnecessary parts.

* add tests for all `parse(Hex|Oct|Bin)Int` procs

* replace `parse*Int` proc impls by call to parseutil procs

Replaces the `parse(Hex|Oct|Bin)Int` procedure implementation by calls
to the `parseutil` procs, which receive a mutable argument.

Has the main advantage that the empty string as well as a "prefix
only" string, e.g. "0x" counts as an invalid integer.

Also moves the `parseOctInt` proc further up in the file so that all
`parse` procs are below one another.

* replace `var L` by `let L` in `parse` procs

There's no reason for the usage of `var` here.

* add `maxLen` optional arg for `parseutil.parse(Oct|Bin)`

Plus small change to test cases.

* update changelog about `parse*Int` procs

* fix `rejectParse` template in `tstrutils`

* make sure only `s.len` chars are parsed, if `maxLen+start` > s.len

Fixes a previous bug in `parseHex` (and now affected `parseOct` and
`parseBin`), which allowed to set `start + maxLen` to be larger than
the strings length. This resulted in an out of bounds access.

* move `parse*Int` proc change to breaking changes, add double `
2018-06-13 13:32:12 -04:00
Kaushal Modi
24df909d8a Make isUpper (and variants) work for strings with non-alpha chars
The other variants are isLower, isUpperAscii and isLowerAscii

Fixes https://github.com/nim-lang/Nim/issues/7963.

This commit changes the behavior and signatures of:

- isUpper, isLower in the unicode module
- isUpperAscii, isLowerAscii in the strutils module

A second mandatory parameter skipNonAlpha is added to these 4 procs.

(This change affects only for the case where the input is a *string*.)

---

With skipNonAlpha set to true, the behavior mimics the Python isupper and
islower behavior i.e. non-alphabetic chars/runes are ignored when checking if
the string is upper-case or lower-case.

    Before this commit:

      doAssert(not isUpper("A B"))

    After this commit:

      doAssert(not isUpper("A B", false))    <-- old behavior
      doAssert isUpper("A B", true)

      Below two are equivalent:

                           isUpper("A B", true)

        isAlpha("A B") and isUpper("A B", false)

.. and the similar for other 3 procs.
2018-06-08 15:14:29 -04:00
skilchen
91765e583d fix handling of default precision in formatBiggestFloat for the js backend (#7928) 2018-06-01 22:24:32 -04:00
Zahary Karadjov
70ec344bbf bugfix: strutils.find was broken for strings with uneven number of chars
For some reason, the problem was manifesting only inside the VM, it was
detecting an attempt to read past the string end (i.e. the formerly
accessible null byte).

To catch such errors, strutils now performs static tests too.

I've solved the problem by re-implementing the Boyer-Moore algotihm
in a cleaner way and I took the opportunity to make some other
optimisations to strutils.
2018-05-07 09:37:49 +02:00
Andreas Rumpf
0fad659bf7 make more tests green 2018-04-30 02:52:58 +02:00
Andreas Rumpf
9b8603adcd strutils: code cleanups and do not rely on the terminating binary zero anymore 2018-04-28 21:59:43 +02:00
Oscar Nihlgård
8caf257607 Don't escape multibyte characters (#7570) 2018-04-23 11:09:48 +02:00
Jacek Sieka
72dfe176f5 remove dead code elimination option (#7669) 2018-04-23 11:02:38 +02:00
Araq
5d13e3f28b fixes #7507 2018-04-19 00:09:55 +02:00
Arne Döring
ed5b7cbac0 move eqIdent to vm.nim (#7585)
* Strutils comment changes.

* fix typo
2018-04-15 23:38:43 +02:00
Andreas Rumpf
50d4224d41 fixes #6205 2018-04-14 00:40:24 +02:00
ryanc-signiq
67fd7a7f86 FIXUP: Removed +1 causing substr slicing to skip chars on first iteration of while loop (#7312) 2018-03-08 08:33:41 +01:00
Andreas Rumpf
0132442c1d strutils.strip: improve the documentation; fixes #7159 2018-03-05 21:45:13 +01:00
Andreas Rumpf
5c8332d871 fixes #7293 2018-03-05 19:46:13 +01:00
Dominik Picheta
1a565d7b20 Merge pull request #6517 from FedericoCeratto/hexstr
Add string-to-hex and back conversions
2018-01-26 15:32:28 +00:00
Fabian Keller
6df6ec27ec Improved collection-to-string behavior (#6825) 2017-12-14 14:02:13 +01:00
Dominik Picheta
45821ea2ab Fixes #4377. 2017-11-28 21:55:29 +01:00
Araq
653dcb8027 cleaned up strutils.nim 2017-11-28 01:15:33 +01:00