about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-11-20 17:20:41 +0100
committerbptato <nincsnevem662@gmail.com>2023-11-20 17:20:41 +0100
commit342a1a7f787fc260448842ee312cf29825f96ba6 (patch)
treee4e1d28e424e60da8b2618195c40442b79bd2ba8 /src/config
parentd20fc30e10aeecfb2ede7adc4547b9ae394565b9 (diff)
downloadchawan-342a1a7f787fc260448842ee312cf29825f96ba6.tar.gz
twtstr: remove tolower, isWhitespace
* tolower: strutils toLowerAscii is good enough for the cases where
  we need it. Also, it's easy to confuse with unicode toLower and
  vice versa.
* isWhitespace: in AsciiWhitespace is more idiomatic. Also has a
  naming collision with unicode toLower.
Diffstat (limited to 'src/config')
-rw-r--r--src/config/mailcap.nim6
-rw-r--r--src/config/mimetypes.nim5
2 files changed, 6 insertions, 5 deletions
diff --git a/src/config/mailcap.nim b/src/config/mailcap.nim
index 4370f775..a53ce24a 100644
--- a/src/config/mailcap.nim
+++ b/src/config/mailcap.nim
@@ -80,7 +80,7 @@ proc consumeTypeField(state: var MailcapParser): Result[string, string] =
       break
     if c notin AsciiAlphaNumeric + {'-', '*'}:
       return err("Invalid character encountered in type field")
-    s &= c.tolower()
+    s &= c.toLowerAscii()
   if not state.has():
     return err("Missing subtype")
   # subtype
@@ -91,7 +91,7 @@ proc consumeTypeField(state: var MailcapParser): Result[string, string] =
       break
     if c notin AsciiAlphaNumeric + {'-', '.', '*', '_', '+'}:
       return err("Invalid character encountered in subtype field")
-    s &= c.tolower()
+    s &= c.toLowerAscii()
   var c: char
   if not state.skipBlanks(c) or c != ';':
     return err("Semicolon not found")
@@ -245,7 +245,7 @@ proc unquoteCommand*(ecmd, contentType, outpath: string, url: URL,
       cmd &= c
       state = STATE_NORMAL
     of STATE_ATTR_QUOTED:
-      attrname &= c.tolower()
+      attrname &= c.toLowerAscii()
       state = STATE_ATTR
     of STATE_NORMAL, STATE_DOLLAR:
       let prev_dollar = state == STATE_DOLLAR
diff --git a/src/config/mimetypes.nim b/src/config/mimetypes.nim
index 2133d863..577fcbed 100644
--- a/src/config/mimetypes.nim
+++ b/src/config/mimetypes.nim
@@ -1,4 +1,5 @@
 import streams
+import strutils
 import tables
 
 import utils/twtstr
@@ -18,7 +19,7 @@ proc parseMimeTypes*(mimeTypes: var MimeTypes, stream: Stream) =
     var t = ""
     var i = 0
     while i < line.len and line[i] notin AsciiWhitespace:
-      t &= line[i].tolower()
+      t &= line[i].toLowerAscii()
       inc i
     if t == "": continue
     while i < line.len:
@@ -26,7 +27,7 @@ proc parseMimeTypes*(mimeTypes: var MimeTypes, stream: Stream) =
         inc i
       var ext = ""
       while i < line.len and line[i] notin AsciiWhitespace:
-        ext &= line[i].tolower()
+        ext &= line[i].toLowerAscii()
         inc i
       if ext == "": continue
       discard mimeTypes.hasKeyOrPut(ext, t)