mruby-bin-mirb: drop the readline and linenoise completion adapters - #7249
Conversation
527018c replaced readline, libedit and linenoise with the built-in multi-line editor and removed their detection from `mrbgem.rake`. That rake file was also what defined `MRB_READLINE_HEADER` next to `MRB_USE_READLINE`, so a config that still defines `MRB_USE_READLINE` on its own now reaches an `#include` with nothing to include: ```console CPP mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c -> build/host/mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.pi mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c:45:10: error: #include expects "FILENAME" or <FILENAME> 45 | #include MRB_READLINE_HEADER | ^~~~~~~~~~~~~~~~~~~ ``` Nothing calls the guarded code any more: `mirb.c` only uses `mirb_setup_editor_completion` and `mirb_get_completions`, and neither `mirb_setup_readline_completion` nor `mirb_setup_linenoise_completion` has a caller. Remove both adapters, their declarations, the conditional includes, and the `current_index` field that only the readline generator used. Defining `MRB_USE_READLINE` or `MRB_USE_LINENOISE` is now a no-op, matching what 527018c already stated. Without either define the removed blocks were never compiled, so the editor path is unchanged: `mirb_completion.o` shrinks by the 11 bytes of the dropped field store and Tab completion behaves identically before and after.
The README still said completion needs "a readline library", listed GNU readline, libedit and linenoise as the supported backends, and documented the `MRUBY_MIRB_READLINE` environment variable. All of that left with 527018c; the environment variable is not read by anything. Rewrite the introduction around the built-in multi-line editor and replace the backend and configuration sections with a short note on what a Tab press does: a single match is inserted, a shared longer prefix extends the input, otherwise the candidates are listed.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 1 remains after this review. 📝 WalkthroughWalkthroughMirb removes readline, libedit, and linenoise completion adapters, related declarations, cleanup state, headers, and configuration. The README documents the built-in multi-line editor and completion behavior. ChangesMirb completion adapter cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change removes obsolete completion adapters, keeps built-in tab completion unchanged, and allows the IntelEdison configuration to build successfully. No actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The cross target has carried `cc.defines = %w(MRB_USE_READLINE)` since the config was written, when it selected mirb's readline backend. mirb stopped reading the define in 527018c, and the previous commit removed the last guarded block, so the assignment now selects nothing and only replaces the toolchain's default define list with a stale name. Delete it; `cxx.defines` still copies `cc.defines`, which is now the default. With the config loaded, `MRuby.targets['core2-32-poky-linux'].cc.defines` is `[]` where it was `["MRB_USE_READLINE"]`.
002f4b6 to
403b8a1
Compare
527018c replaced readline, libedit and linenoise in mirb with the built-in multi-line editor and took their detection out of
mrbgem.rake. That rake file was also what definedMRB_READLINE_HEADERnext toMRB_USE_READLINE, so a config that still definesMRB_USE_READLINEon its own, as the IntelEdison cross target does (build_config/IntelEdison.rb:25), now reaches an#includewith nothing to include:What is left in the source
Three guarded blocks survived 527018c, none of them reachable:
mirb_completion.c:43-51#ifdef MRB_USE_READLINE→#include MRB_READLINE_HEADER,#ifdef MRB_USE_LINENOISE→#include <linenoise.h>mirb_completion.c:593-698mirb_readline_generator,mirb_readline_completion,mirb_setup_readline_completion) and the linenoise adapter (mirb_linenoise_completion,mirb_setup_linenoise_completion)mirb_completion.h:107-116mirb.conly callsmirb_setup_editor_completionandmirb_get_completions; neither setup function has a caller. The first commit removes the three blocks together with thecurrent_indexfield that only the readline generator used, so definingMRB_USE_READLINEorMRB_USE_LINENOISEis a no-op, which is what 527018c's message already says ("readline integration has been completely removed").The second commit brings
mrbgems/mruby-bin-mirb/README.mdup to date: it still said completion needs "a readline library", listed the three backends, and documented aMRUBY_MIRB_READLINEenvironment variable that nothing reads. The Tab Completion section now describes the built-in editor.The third commit removes the define from
IntelEdison.rb:25itself. It selected mirb's readline backend when the config was written; with the last guarded block gone,cc.defines = %w(MRB_USE_READLINE)only replaces the toolchain's default define list with a stale name. With the config loaded,MRuby.targets['core2-32-poky-linux'].cc.definesis[]where it was["MRB_USE_READLINE"].Verified
Three builds of the same config (
default.gembox,enable_debug,enable_test) into separate build directories: master, this branch, and this branch withconf.cc.defines << 'MRB_USE_READLINE'added. The third one fails on master at the line above and builds here;mirb_completion.o.flagsconfirms-DMRB_USE_READLINEreached the compiler.sizeon the results, master versus branch and branch with the define:mirbtextmirb_completion.otextMRB_USE_READLINEThe 11 bytes are the
ctx->current_index = 0store inmirb_completion_free(this config is-O0); the guarded blocks were never compiled without the define, so nothing else moves. Master and the branch with the define are not comparable, since master does not build.Tab completion was driven through a pty on all three binaries with the same key sequence per case (constant
Stri, methodString.ne, listingString.n, keywordwhi, global$std, localmy_var), and the three terminal transcripts are byte-identical (md5sumb80fb4d6…). Excerpts:rake -m teston the branch build: KO 0, Crash 0.Environment
Details
The line each build gives
mrbgems/mruby-bin-mirb/tools/mirb/mirb_completion.c, read off the.flagsrecord beside the object, the-Ilist and-odropped: