mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 01:37:19 +00:00
Fix broken doc format.
Many assumptions in the parsing code that could cause infinite loops, as well as assuming things were non-nil.
This commit is contained in:
parent
848d4a1498
commit
c5da87b860
@ -1798,7 +1798,7 @@
|
|||||||
(defn skip-line-indent []
|
(defn skip-line-indent []
|
||||||
(var pos* pos)
|
(var pos* pos)
|
||||||
(set c (get str pos*))
|
(set c (get str pos*))
|
||||||
(while (and (not= nil c)
|
(while (and c
|
||||||
(not= 10 c)
|
(not= 10 c)
|
||||||
(= 32 c))
|
(= 32 c))
|
||||||
(set c (get str (++ pos*))))
|
(set c (get str (++ pos*))))
|
||||||
@ -1807,7 +1807,8 @@
|
|||||||
|
|
||||||
(defn update-levels []
|
(defn update-levels []
|
||||||
(while (< leading (array/peek levels))
|
(while (< leading (array/peek levels))
|
||||||
(array/pop levels)))
|
(array/pop levels)
|
||||||
|
(if (empty? levels) (break))))
|
||||||
|
|
||||||
(defn start-nl? []
|
(defn start-nl? []
|
||||||
(= 10 (get str pos)))
|
(= 10 (get str pos)))
|
||||||
@ -1831,8 +1832,7 @@
|
|||||||
(defn start-ul? []
|
(defn start-ul? []
|
||||||
(var pos* pos)
|
(var pos* pos)
|
||||||
(var c* (get str pos*))
|
(var c* (get str pos*))
|
||||||
(while (and (not= nil c*)
|
(while (and c* (= 32 c*))
|
||||||
(= 32 c*))
|
|
||||||
(set c* (get str (++ pos*))))
|
(set c* (get str (++ pos*))))
|
||||||
(and (or (= 42 c*)
|
(and (or (= 42 c*)
|
||||||
(= 43 c*)
|
(= 43 c*)
|
||||||
@ -1842,10 +1842,9 @@
|
|||||||
(defn start-ol? []
|
(defn start-ol? []
|
||||||
(var pos* pos)
|
(var pos* pos)
|
||||||
(var c* (get str pos*))
|
(var c* (get str pos*))
|
||||||
(while (and (not= nil c*)
|
(while (and c* (= 32 c*))
|
||||||
(= 32 c*))
|
|
||||||
(set c* (get str (++ pos*))))
|
(set c* (get str (++ pos*))))
|
||||||
(while (and (not= nil c*)
|
(while (and c*
|
||||||
(<= 48 c*)
|
(<= 48 c*)
|
||||||
(>= 57 c*))
|
(>= 57 c*))
|
||||||
(set c* (get str (++ pos*))))
|
(set c* (get str (++ pos*))))
|
||||||
@ -1858,10 +1857,10 @@
|
|||||||
(defn push-line []
|
(defn push-line []
|
||||||
(buffer/push-string res (buffer/new-filled indent 32))
|
(buffer/push-string res (buffer/new-filled indent 32))
|
||||||
(set c (get str pos))
|
(set c (get str pos))
|
||||||
(while (not= 10 c)
|
(while (and c (not= 10 c))
|
||||||
(buffer/push-byte res c)
|
(buffer/push-byte res c)
|
||||||
(set c (get str (++ pos))))
|
(set c (get str (++ pos))))
|
||||||
(buffer/push-byte res c)
|
(buffer/push-byte res 10)
|
||||||
(++ pos))
|
(++ pos))
|
||||||
|
|
||||||
(defn push-bullet []
|
(defn push-bullet []
|
||||||
@ -1869,11 +1868,11 @@
|
|||||||
(buffer/push-string line (buffer/new-filled leading 32))
|
(buffer/push-string line (buffer/new-filled leading 32))
|
||||||
(set c (get str pos*))
|
(set c (get str pos*))
|
||||||
# Add bullet
|
# Add bullet
|
||||||
(while (and (not= nil c) (not= 32 c))
|
(while (and c (not= 32 c))
|
||||||
(buffer/push-byte line c)
|
(buffer/push-byte line c)
|
||||||
(set c (get str (++ pos*))))
|
(set c (get str (++ pos*))))
|
||||||
# Add item indentation
|
# Add item indentation
|
||||||
(while (and (not= nil c) (= 32 c))
|
(while (= 32 c)
|
||||||
(buffer/push-byte line c)
|
(buffer/push-byte line c)
|
||||||
(set c (get str (++ pos*))))
|
(set c (get str (++ pos*))))
|
||||||
# Record indentation if necessary
|
# Record indentation if necessary
|
||||||
@ -1889,7 +1888,7 @@
|
|||||||
(def word @"")
|
(def word @"")
|
||||||
(var word-len 0)
|
(var word-len 0)
|
||||||
# Build a word
|
# Build a word
|
||||||
(while (and (not= nil c)
|
(while (and c
|
||||||
(not= 10 c)
|
(not= 10 c)
|
||||||
(not= 32 c))
|
(not= 32 c))
|
||||||
(buffer/push-byte word c)
|
(buffer/push-byte word c)
|
||||||
@ -1926,7 +1925,7 @@
|
|||||||
(push-bullet)
|
(push-bullet)
|
||||||
# Add words
|
# Add words
|
||||||
(set c (get str pos))
|
(set c (get str pos))
|
||||||
(while (and (not= nil c)
|
(while (and c
|
||||||
(not= 10 c))
|
(not= 10 c))
|
||||||
# Skip spaces
|
# Skip spaces
|
||||||
(while (= 32 c)
|
(while (= 32 c)
|
||||||
@ -1950,14 +1949,14 @@
|
|||||||
(defn push-fcb []
|
(defn push-fcb []
|
||||||
(update-levels)
|
(update-levels)
|
||||||
(push-line)
|
(push-line)
|
||||||
(while (not (end-fcb?))
|
(while (and (< pos len) (not (end-fcb?)))
|
||||||
(push-line))
|
(push-line))
|
||||||
(push-line))
|
(push-line))
|
||||||
|
|
||||||
(defn push-icb []
|
(defn push-icb []
|
||||||
(buffer/push-string res (buffer/new-filled leading 32))
|
(buffer/push-string res (buffer/new-filled leading 32))
|
||||||
(push-line)
|
(push-line)
|
||||||
(while (not (start-nl?))
|
(while (and (< pos len) (not (start-nl?)))
|
||||||
(push-line))
|
(push-line))
|
||||||
(push-nl))
|
(push-nl))
|
||||||
|
|
||||||
@ -1970,8 +1969,7 @@
|
|||||||
(set line-width para-indent)
|
(set line-width para-indent)
|
||||||
# Add words
|
# Add words
|
||||||
(set c (get str pos))
|
(set c (get str pos))
|
||||||
(while (and (not= nil c)
|
(while (and c (not= 10 c))
|
||||||
(not= 10 c))
|
|
||||||
# Skip spaces
|
# Skip spaces
|
||||||
(while (= 32 c)
|
(while (= 32 c)
|
||||||
(set c (get str (++ pos))))
|
(set c (get str (++ pos))))
|
||||||
|
Loading…
Reference in New Issue
Block a user