about summary refs log tree commit diff stats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-26 20:43:32 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-26 20:45:17 +0100
commit2d5245d9ecc920c81b39e790bc3e396a61381849 (patch)
treea491b9761dec78f4f53e588f92452a8753848980 /src/utils
parent9c78cc3ce8b3345f95cb37a2a9d2101f52ecaa41 (diff)
downloadchawan-2d5245d9ecc920c81b39e790bc3e396a61381849.tar.gz
Correct attribute functions, de-extern jserr
Instead of unnecessarily marking every jserr function as *, add the
used pragma (so the C compiler can get rid of them later.)
Also, use the correct definition of attribute namespace.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/twtstr.nim12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index 06340c59..91633734 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -694,7 +694,7 @@ const NameStartCharAscii = {':', '_'} + AsciiAlpha
 const NameCharAscii = NameStartCharAscii + {'-', '.'} + AsciiDigit
 func matchNameProduction*(str: string): bool =
   if str.len == 0:
-    return true
+    return false
   # NameStartChar
   var i = 0
   var r: Rune
@@ -720,9 +720,15 @@ func matchNameProduction*(str: string): bool =
   return true
 
 func matchQNameProduction*(s: string): bool =
+  if s.len == 0:
+    return false
+  if s[0] == ':':
+    return false
+  if s[^1] == ':':
+    return false
   var colon = false
-  for c in s:
-    if c == ':':
+  for i in 1 ..< s.len - 1:
+    if s[i] == ':':
       if colon:
         return false
       colon = true