From 139075e96565f4b7436e8d2368f85f11852aa668 Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Thu, 3 Dec 2020 02:30:55 +0800 Subject: [PATCH] move decode_helpers to std/private (#16209) --- lib/pure/cgi.nim | 2 +- lib/pure/uri.nim | 2 +- lib/{pure/includes => std/private}/decode_helpers.nim | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) rename lib/{pure/includes => std/private}/decode_helpers.nim (69%) diff --git a/lib/pure/cgi.nim b/lib/pure/cgi.nim index 1f0e0736a3..cb64a3b1ba 100644 --- a/lib/pure/cgi.nim +++ b/lib/pure/cgi.nim @@ -32,7 +32,7 @@ import strutils, os, strtabs, cookies, uri export uri.encodeUrl, uri.decodeUrl -include includes/decode_helpers +import std/private/decode_helpers proc addXmlChar(dest: var string, c: char) {.inline.} = case c diff --git a/lib/pure/uri.nim b/lib/pure/uri.nim index 15d0996a78..5b16bfcb15 100644 --- a/lib/pure/uri.nim +++ b/lib/pure/uri.nim @@ -47,7 +47,7 @@ import std/private/since import strutils, parseutils, base64 -include includes/decode_helpers +import std/private/decode_helpers type diff --git a/lib/pure/includes/decode_helpers.nim b/lib/std/private/decode_helpers.nim similarity index 69% rename from lib/pure/includes/decode_helpers.nim rename to lib/std/private/decode_helpers.nim index 74fe37d074..586c7cae65 100644 --- a/lib/pure/includes/decode_helpers.nim +++ b/lib/std/private/decode_helpers.nim @@ -1,14 +1,12 @@ -# Include file that implements 'decodePercent' and friends. Do not import it! - -proc handleHexChar(c: char, x: var int, f: var bool) {.inline.} = +proc handleHexChar*(c: char, x: var int, f: var bool) {.inline.} = case c of '0'..'9': x = (x shl 4) or (ord(c) - ord('0')) of 'a'..'f': x = (x shl 4) or (ord(c) - ord('a') + 10) of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10) else: f = true -proc decodePercent(s: string, i: var int): char = - ## Converts `%xx` hexadecimal to the charracter with ordinal number `xx`. +proc decodePercent*(s: openArray[char], i: var int): char = + ## Converts `%xx` hexadecimal to the character with ordinal number `xx`. ## ## If `xx` is not a valid hexadecimal value, it is left intact: only the ## leading `%` is returned as-is, and `xx` characters will be processed in the