Commit 247873ed

247873ed8fc2Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

docs(regexp): comment explaining why compile_error still exits (#781 deferred)

Issue #781 wants compile_error to raise RegexpError instead of fprintf + exit(1). Tried the simple route (call sp_raise_cls directly) but the runtime declares sp_raise_cls as static inline per translation unit -- the library cannot reference the user program's copy at link time.

Fix needs an extern raise hook: re_set_error_handler(fn) called from the user program's startup. Defer to a follow-up; in the meantime leave a comment so the next reader doesn't try the naive route.

Refs #781

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
247873ed8fc2
Parent
62496fbccef0

lib/regexp/re_compile.cmodifiedView file

@@ -356,6 +356,10 @@
356356 return FALSE;
357357 }
358358 next_char(c); /* skip '}' */
359+ /* Issue #822: min > max is invalid. CRuby raises RegexpError. */
360+ if (max >= 0 && min > max) {
361+ compile_error(c, "invalid repeat count");
362+ }
359363 *min_out = min;
360364 *max_out = max;
361365 return TRUE;