node/lib
Ian Harris 9decb70d05
readline: fix issue with newline-less last line
The logic for reading lines was slightly flawed, in that it assumed
there would be a final new line. It handled the case where there are no
new lines, but this then broke if there were some new lines.

The fix in logic is basically removing the special case where there are
no new lines by changing it to always read the final line with no new
lines. This works because if a file contains no new lines, the final
line is the first line, and all is well.

There is some subtlety in this functioning, however. If the last line
contains no new lines, then `lastIndex` will be the start of the last
line, and `kInsertString` will be called from that point. If it does
contain a new line, `lastIndex` will be equal to `s.length`, so the
slice will be the empty string.

Fixes: https://github.com/nodejs/node/issues/47305
PR-URL: https://github.com/nodejs/node/pull/47317
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-04-14 10:12:16 +00:00
..
assert assert: add `assert/strict` alias module 2020-06-25 08:37:48 -07:00
dns dns: make promise API fully constructed from `lib/internal/dns/promises` 2022-06-20 19:58:45 +01:00
fs fs: add fs/promises alias module 2020-02-18 22:15:50 -08:00
inspector inspector: refactor `inspector/promises` to be more robust 2022-10-19 18:39:31 +00:00
internal readline: fix issue with newline-less last line 2023-04-14 10:12:16 +00:00
path path: add `path/posix` and `path/win32` alias modules 2020-10-20 14:27:31 +00:00
readline readline: remove `question` method from `InterfaceConstructor` 2022-09-14 19:10:53 +00:00
stream stream: add pipeline() for webstreams 2023-02-02 19:45:42 +00:00
test test_runner: expose reporter for use in run api 2023-03-28 12:10:34 +00:00
timers lib: enforce use of trailing commas in more files 2023-02-16 18:47:24 +01:00
util util: add `util/types` alias module 2020-10-21 01:26:34 +02:00
.eslintrc.yaml buffer: graduate File from experimental and expose as global 2023-03-22 19:28:12 +00:00
_http_agent.js lib: add trailing commas to more internal files 2023-02-26 11:34:02 +01:00
_http_client.js url: offload `URLSearchParams` initialization 2023-03-01 17:03:58 +00:00
_http_common.js lib: add trailing commas to more internal files 2023-02-26 11:34:02 +01:00
_http_incoming.js lib: add trailing commas to more internal files 2023-02-26 11:34:02 +01:00
_http_outgoing.js stream: add setter & getter for default highWaterMark (#46929) 2023-03-29 20:02:10 +02:00
_http_server.js http: use listenerCount when adding noop event 2023-03-08 07:09:21 +00:00
_stream_duplex.js stream: do not use _stream_* anymore 2021-01-05 19:02:04 +01:00
_stream_passthrough.js stream: do not use _stream_* anymore 2021-01-05 19:02:04 +01:00
_stream_readable.js stream: do not use _stream_* anymore 2021-01-05 19:02:04 +01:00
_stream_transform.js stream: do not use _stream_* anymore 2021-01-05 19:02:04 +01:00
_stream_wrap.js
_stream_writable.js stream: do not use _stream_* anymore 2021-01-05 19:02:04 +01:00
_tls_common.js tools: add `prefer-proto` rule 2023-01-10 05:38:36 +00:00
_tls_wrap.js lib,src: fix a few typos in comments 2023-02-25 20:29:59 +00:00
assert.js src: bootstrap prepare stack trace callback in shadow realm 2023-04-04 01:13:37 +00:00
async_hooks.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
buffer.js buffer: check INSPECT_MAX_BYTES with validateNumber 2023-04-03 08:24:24 +00:00
child_process.js child_process: add trailing commas in source files 2023-02-24 09:44:18 +01:00
cluster.js lib,src: update cluster to use Parent 2021-01-05 15:41:45 -05:00
console.js
constants.js lib: flatten access to primordials 2019-11-25 10:28:15 +01:00
crypto.js crypto: remove DEFAULT_ENCODING 2023-03-26 18:03:58 +00:00
dgram.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
diagnostics_channel.js diagnostics_channel: fix ref counting bug when reaching zero subscribers 2023-04-13 13:40:50 +00:00
dns.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
domain.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
events.js events: add getMaxListeners method 2023-03-19 12:58:19 +00:00
fs.js src,process: add permission model 2023-02-23 18:11:51 +00:00
http.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
http2.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
https.js url: offload `URLSearchParams` initialization 2023-03-01 17:03:58 +00:00
inspector.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
module.js module: add API for interacting with source maps 2020-01-14 12:39:06 -08:00
net.js net: enable autoSelectFamily by default 2023-04-05 08:31:56 -07:00
os.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
path.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
perf_hooks.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
process.js src: disambiguate terms used to refer to builtins and addons 2022-08-09 01:36:49 +08:00
punycode.js lib: runtime deprecate punycode 2023-04-03 17:47:28 +00:00
querystring.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
readline.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
repl.js src: bootstrap prepare stack trace callback in shadow realm 2023-04-04 01:13:37 +00:00
stream.js stream: add setter & getter for default highWaterMark (#46929) 2023-03-29 20:02:10 +02:00
string_decoder.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
sys.js
test.js test_runner: support function mocking 2022-11-07 18:25:54 -05:00
timers.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
tls.js tls: add trailing commas in source files 2023-02-22 01:22:23 +01:00
trace_events.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
tty.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
url.js url: use ada::url_aggregator for parsing urls 2023-04-05 09:05:27 -07:00
util.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
v8.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
vm.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
wasi.js wasi: make returnOnExit true by default 2023-04-11 16:35:52 -04:00
worker_threads.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00
zlib.js lib: add trailing commas to all public core modules 2023-02-28 12:10:24 +01:00