@@ -377,14 +377,9 @@ print_hint(void)
377377#ifndef MRB_USE_READLINE
378378/* Print the command line prompt of the REPL */
379379static void
380-print_cmdline(int code_block_open)
380+print_cmdline(int code_block_open, int line_num)
381381{
382-if (code_block_open) {
383-printf("* ");
384- }
385-else {
386-printf("> ");
387- }
382+printf("%d%c ", line_num, code_block_open ? '*' : '>');
388383fflush(stdout);
389384}
390385#endif
@@ -470,6 +465,7 @@ main(int argc, char **argv)
470465int n;
471466int i;
472467mrb_bool code_block_open = FALSE;
468+int line_num = 1;
473469int ai;
474470unsigned int stack_keep = 0;
475471@@ -550,7 +546,7 @@ main(int argc, char **argv)
550546 }
551547552548#ifndef MRB_USE_READLINE
553-print_cmdline(code_block_open);
549+print_cmdline(code_block_open, line_num);
554550555551signal(SIGINT, ctrl_c_handler);
556552char_index = 0;
@@ -567,6 +563,7 @@ main(int argc, char **argv)
567563ruby_code[0] = '\0';
568564last_code_line[0] = '\0';
569565code_block_open = FALSE;
566+line_num = 1;
570567puts("^C");
571568input_canceled = 0;
572569continue;
@@ -586,10 +583,15 @@ main(int argc, char **argv)
586583ruby_code[0] = '\0';
587584last_code_line[0] = '\0';
588585code_block_open = FALSE;
586+line_num = 1;
589587puts("^C");
590588 }
591589signal(SIGINT, ctrl_c_handler);
592-line = MIRB_READLINE(code_block_open ? "* " : "> ");
590+ {
591+char prompt[32];
592+snprintf(prompt, sizeof(prompt), "%d%c ", line_num, code_block_open ? '*' : '>');
593+line = MIRB_READLINE(prompt);
594+ }
593595signal(SIGINT, SIG_DFL);
594596595597if (line == NULL) {
@@ -607,6 +609,7 @@ main(int argc, char **argv)
607609 }
608610MIRB_LINE_FREE(line);
609611#endif
612+line_num++;
610613611614done:
612615if (code_block_open) {
@@ -654,6 +657,7 @@ main(int argc, char **argv)
654657char* msg = mrb_locale_from_utf8(parser->error_buffer[0].message, -1);
655658printf("line %d: %s\n", parser->error_buffer[0].lineno, msg);
656659mrb_locale_free(msg);
660+line_num = 1;
657661 }
658662else {
659663/* generate bytecode */
@@ -699,6 +703,7 @@ main(int argc, char **argv)
699703 }
700704ruby_code[0] = '\0';
701705last_code_line[0] = '\0';
706+line_num = 1;
702707mrb_gc_arena_restore(mrb, ai);
703708 }
704709mrb_parser_free(parser);