From bf7ce77fc890a0cf0f31b1c50daeb8b165edf1b3 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Mon, 2 Nov 2020 16:58:06 +0100 Subject: [PATCH] Editorial: rename internal run algorithm "Run" is now "process a queue" and "process" is now "process an item". Also tidy up the error mode note and shorten the "process an item" algorithm. Closes #245. --- encoding.bs | 89 ++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/encoding.bs b/encoding.bs index 2b2af26..ae966cd 100644 --- a/encoding.bs +++ b/encoding.bs @@ -261,37 +261,36 @@ a decoder and "fatal" or "html" for an An XML processor would set error mode to "fatal". [[XML]] -

html exists as error mode due to URLs and HTML forms -requiring a non-terminating legacy encoder. The "html" -error mode causes a sequence to be emitted that cannot be distinguished from -legitimate input and can therefore lead to silent data loss. Developers are strongly -encouraged to use the UTF-8 encoding to prevent this from -happening. -[[URL]] -[[HTML]] - -

To run an encoding's decoder or -encoder instance encoderDecoder with I/O queue -input, I/O queue output, and error mode -mode, run these steps: +

"html" exists as error mode due to HTML forms requiring a +non-terminating legacy encoder. The "html" error mode causes +a sequence to be emitted that cannot be distinguished from legitimate input and can therefore lead +to silent data loss. Developers are strongly encouraged to use the UTF-8 +encoding to prevent this from happening. [[HTML]] + +


+ +

To process a queue +given an encoding's decoder or encoder instance +encoderDecoder, I/O queue input, I/O queue +output, and error mode mode:

  1. While true:

      -
    1. Let result be the result of processing the result of reading from - input for encoderDecoder, input, output, and - mode. +

    2. Let result be the result of processing an item with the result of + reading from input, encoderDecoder, input, + output, and mode.

    3. If result is not continue, then return result.

-

To process an item item for an -encoding's encoder or decoder instance -encoderDecoder, I/O queue input, I/O queue -output, and error mode mode, run these steps: +

To process an item +given an item item, encoding's encoder or +decoder instance encoderDecoder, I/O queue input, +I/O queue output, and error mode mode:

  1. Assert: if encoderDecoder is an encoder instance, mode is @@ -306,10 +305,8 @@ happening.

  2. Let result be the result of running encoderDecoder's handler on input and item. -

  3. If result is continue, then return result. -

  4. -

    Otherwise, if result is finished: +

    If result is finished:

    1. Push end-of-queue to output. @@ -1000,8 +997,8 @@ queue of scalar values output (default « »), run these steps:

    2. If buffer is 0xEF 0xBB 0xBF, then read three bytes from ioQueue. (Do nothing with those bytes.) -

    3. Run an instance of UTF-8's decoder with ioQueue, - output, and "replacement". +

    4. Process a queue with an instance of UTF-8's decoder, + ioQueue, output, and "replacement".

    5. Return output.

    @@ -1010,8 +1007,8 @@ queue of scalar values output (default « »), run these steps: optional I/O queue of scalar values output (default « »), run these steps:
      -
    1. Run an instance of UTF-8's decoder with ioQueue, - output, and "replacement". +

    2. Process a queue wih an instance of UTF-8's decoder, + ioQueue, output, and "replacement".

    3. Return output.

    @@ -1023,8 +1020,9 @@ given an optional I/O queue of scalar values output (default « »), -->
      -
    1. Let potentialError be the result of running an instance of UTF-8's - decoder with ioQueue, output, and "fatal". +

    2. Let potentialError be the result of processing a queue with an instance of + UTF-8's decoder, ioQueue, output, and + "fatal".

    3. If potentialError is an error, then return failure. @@ -1073,7 +1071,7 @@ these steps: than anything else. In a context where HTTP is used this is in violation of the semantics of the `Content-Type` header. -

    4. Run an instance of encoding's decoder with +

    5. Process a queue with an instance of encoding's decoder, ioQueue, output, and "replacement".

    6. Return output. @@ -1113,7 +1111,7 @@ steps:

      1. Let encoder be the result of getting an encoder from encoding. -

      2. Run encoder with ioQueue, output, and +

      3. Process a queue with encoder, ioQueue, output, and "html".

      4. Return output. @@ -1138,8 +1136,8 @@ is safe as it never triggers errors. [[HTML]] these steps:

          -
        1. Let potentialError be the result of running encoder with - ioQueue, output, and "fatal". +

        2. Let potentialError be the result of processing a queue with + encoder, ioQueue, output, and "fatal".

        3. Push end-of-queue to output. @@ -1460,7 +1458,7 @@ method steps are:

          Otherwise:

            -
          1. Let result be the result of processing item for +

          2. Let result be the result of processing an item with item, this's decoder, this's I/O queue, output, and this's error mode. @@ -1549,16 +1547,17 @@ constructor steps are to do nothing.

          3. Let item be the result of reading from input. -

          4. Let result be the result of processing item for an instance - of the UTF-8 encoder, input, output, and "fatal". +

          5. Let result be the result of processing an item with item, an + instance of the UTF-8 encoder, input, output, and + "fatal".

          6. -

            Assert: result is not error. +

            Assert: result is not an error.

            The UTF-8 encoder cannot return error. -

          7. If result is finished, convert - output into a byte sequence, and then return a {{Uint8Array}} object wrapping an +

          8. If result is finished, then convert + output into a byte sequence and return a {{Uint8Array}} object wrapping an {{ArrayBuffer}} containing output.

          @@ -1791,7 +1790,7 @@ constructor steps are:
        4. Return.

        -
      5. Let result be the result of processing item for +

      6. Let result be the result of processing an item with item, decoder's decoder, decoder's I/O queue, output, and decoder's error mode. @@ -1808,8 +1807,8 @@ steps:

      7. Let output be the I/O queue of scalar values « end-of-queue ». -

      8. Let result be the result of processing end-of-queue for - decoder's decoder and decoder's +

      9. Let result be the result of processing an item with end-of-queue, + decoder's decoder, decoder's I/O queue, output, and decoder's error mode. @@ -1949,9 +1948,9 @@ constructor steps are:

      10. Let result be the result of executing the convert code unit to scalar value algorithm with encoder, item and input. -

      11. If result is not continue, then process result for - encoder's encoder, input, output, - and "fatal". +

      12. If result is not continue, then process an item with + result, encoder's encoder, input, + output, and "fatal".