about summary refs log tree commit diff stats
path: root/subx/071read-line.subx
diff options
context:
space:
mode:
Diffstat (limited to 'subx/071read-line.subx')
-rw-r--r--subx/071read-line.subx40
1 files changed, 20 insertions, 20 deletions
diff --git a/subx/071read-line.subx b/subx/071read-line.subx
index 39c5f576..f33fd035 100644
--- a/subx/071read-line.subx
+++ b/subx/071read-line.subx
@@ -4,7 +4,7 @@
 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 
 #? Entry:  # run a single test, while debugging
-#?     e8/call test-read-line/disp32
+#?     e8/call test-read-line-buffered/disp32
 #?     # syscall(exit, Num-test-failures)
 #?     8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           3/r32/EBX   Num-test-failures/disp32          # copy *Num-test-failures to EBX
 #?     b8/copy-to-EAX  1/imm32/exit
@@ -13,7 +13,7 @@
 # read bytes from 'f' until (and including) a newline and store them into 's'
 # 's' fails to grow if and only if no data found
 # just abort if 's' is too small
-read-line:  # f : (address buffered-file), s : (address stream byte) -> <void>
+read-line-buffered:  # f : (address buffered-file), s : (address stream byte) -> <void>
     # pseudocode:
     #   while true
     #     if (s->write >= s->length) abort
@@ -41,13 +41,13 @@ read-line:  # f : (address buffered-file), s : (address stream byte) -> <void>
     8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .             .           7/r32/EDI   0xc/disp8       .                 # copy *(EBP+12) to EDI
     # EDX = s->write
     8b/copy                         0/mod/indirect  7/rm32/EDI    .           .             .           2/r32/EDX   .               .                 # copy *EDI to EDX
-$read-line:loop:
+$read-line-buffered:loop:
     # if (s->write >= s->length) abort
     3b/compare                      1/mod/*+disp8   7/rm32/EDI    .           .             .           2/r32/EDX   8/disp8         .                 # compare EDX with *(EDI+8)
-    7d/jump-if-greater-or-equal  $read-line:abort/disp8
+    7d/jump-if-greater-or-equal  $read-line-buffered:abort/disp8
     # if (f->read >= f->write) populate stream from file
     3b/compare                      1/mod/*+disp8   6/rm32/ESI    .           .             .           1/r32/ECX   4/disp8         .                 # compare ECX with *(ESI+4)
-    7c/jump-if-lesser  $read-line:from-stream/disp8
+    7c/jump-if-lesser  $read-line-buffered:from-stream/disp8
     # . clear-stream(stream = f+4)
     # . . push args
     8d/copy-address                 1/mod/*+disp8   6/rm32/ESI    .           .             .           0/r32/EAX   4/disp8         .                 # copy ESI+4 to EAX
@@ -70,8 +70,8 @@ $read-line:loop:
     # since f->read was initially 0, EAX is the same as f->write
     # . if (EAX == 0) return true
     3d/compare-EAX-and  0/imm32
-    74/jump-if-equal  $read-line:end/disp8
-$read-line:from-stream:
+    74/jump-if-equal  $read-line-buffered:end/disp8
+$read-line-buffered:from-stream:
     # AL = f->data[f->read]
     31/xor                          3/mod/direct    0/rm32/EAX    .           .             .           0/r32/EAX   .               .                 # clear EAX
     8a/copy-byte                    1/mod/*+disp8   4/rm32/sib    6/base/ESI  1/index/ECX   .           0/r32/AL    0x10/disp8      .                 # copy byte at *(ESI+ECX+16) to AL
@@ -83,8 +83,8 @@ $read-line:from-stream:
     42/increment-EDX
     # if (AL == '\n') return
     3d/compare-EAX-and  0xa/imm32
-    75/jump-if-not-equal  $read-line:loop/disp8
-$read-line:end:
+    75/jump-if-not-equal  $read-line-buffered:loop/disp8
+$read-line-buffered:end:
     # save f->read
     89/copy                         1/mod/*+disp8   6/rm32/ESI    .           .             .           1/r32/ECX   8/disp8         .                 # copy ECX to *(ESI+8)
     # save s->write
@@ -100,10 +100,10 @@ $read-line:end:
     5d/pop-to-EBP
     c3/return
 
-$read-line:abort:
+$read-line-buffered:abort:
     # . _write(2/stderr, error)
     # . . push args
-    68/push  "read-line: line too long\n"/imm32
+    68/push  "read-line-buffered: line too long\n"/imm32
     68/push  2/imm32/stderr
     # . . call
     e8/call  _write/disp32
@@ -115,8 +115,8 @@ $read-line:abort:
     cd/syscall  0x80/imm8
     # never gets here
 
-test-read-line:
-    # - check that read-line stops at a newline
+test-read-line-buffered:
+    # - check that read-line-buffered stops at a newline
     # setup
     # . clear-stream(_test-stream)
     # . . push args
@@ -150,17 +150,17 @@ test-read-line:
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # read a line from _test-stream (buffered by _test-buffered-file) into _test-tmp-stream
-    # . EAX = read-line(_test-buffered-file, _test-tmp-stream)
+    # . EAX = read-line-buffered(_test-buffered-file, _test-tmp-stream)
     # . . push args
     68/push  _test-tmp-stream/imm32
     68/push  _test-buffered-file/imm32
     # . . call
-    e8/call  read-line/disp32
+    e8/call  read-line-buffered/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # check-next-stream-line-equal(_test-tmp-stream, "ab", msg)
     # . . push args
-    68/push  "F - test-read-line"/imm32
+    68/push  "F - test-read-line-buffered"/imm32
     68/push  "ab"/imm32
     68/push  _test-tmp-stream/imm32
     # . . call
@@ -170,7 +170,7 @@ test-read-line:
     # end
     c3/return
 
-test-read-line-reads-final-line-until-Eof:
+test-read-line-buffered-reads-final-line-until-Eof:
     # setup
     # . clear-stream(_test-stream)
     # . . push args
@@ -204,17 +204,17 @@ test-read-line-reads-final-line-until-Eof:
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # read a line from _test-stream (buffered by _test-buffered-file) into _test-tmp-stream
-    # . EAX = read-line(_test-buffered-file, _test-tmp-stream)
+    # . EAX = read-line-buffered(_test-buffered-file, _test-tmp-stream)
     # . . push args
     68/push  _test-tmp-stream/imm32
     68/push  _test-buffered-file/imm32
     # . . call
-    e8/call  read-line/disp32
+    e8/call  read-line-buffered/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # check-stream-equal(_test-tmp-stream, "cd", msg)
     # . . push args
-    68/push  "F - test-read-line-reads-final-line-until-Eof"/imm32
+    68/push  "F - test-read-line-buffered-reads-final-line-until-Eof"/imm32
     68/push  "cd"/imm32
     68/push  _test-tmp-stream/imm32
     # . . call