MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / readline

Function readline

extern/editline/src/readline.c:421–476  ·  view source on GitHub ↗

* read one line from input stream and return it, chomping * trailing newline (if there is any) */

Source from the content-addressed store, hash-verified

419 * trailing newline (if there is any)
420 */
421char *
422readline(const char *p)
423{
424 HistEvent ev;
425 const char * volatile prompt = p;
426 int count;
427 const char *ret;
428 char *buf;
429 static int used_event_hook;
430
431 if (e == NULL || h == NULL)
432 rl_initialize();
433
434 rl_done = 0;
435
436 (void)setjmp(topbuf);
437
438 /* update prompt accordingly to what has been passed */
439 if (rl_set_prompt(prompt) == -1)
440 return NULL;
441
442 if (rl_pre_input_hook)
443 (*rl_pre_input_hook)(NULL, 0);
444
445 if (rl_event_hook && !(e->el_flags&NO_TTY)) {
446 el_set(e, EL_GETCFN, _rl_event_read_char);
447 used_event_hook = 1;
448 }
449
450 if (!rl_event_hook && used_event_hook) {
451 el_set(e, EL_GETCFN, EL_BUILTIN_GETCFN);
452 used_event_hook = 0;
453 }
454
455 rl_already_prompted = 0;
456
457 /* get one line from input stream */
458 ret = el_gets(e, &count);
459
460 if (ret && count > 0) {
461 int lastidx;
462
463 buf = strdup(ret);
464 if (buf == NULL)
465 return NULL;
466 lastidx = count - 1;
467 if (buf[lastidx] == '\n')
468 buf[lastidx] = '\0';
469 } else
470 buf = NULL;
471
472 history(h, &ev, H_GETSIZE);
473 history_length = ev.num;
474
475 return buf;
476}
477
478/*

Callers

nothing calls this directly

Calls 5

rl_initializeFunction · 0.85
rl_set_promptFunction · 0.85
el_setFunction · 0.85
el_getsFunction · 0.85
historyClass · 0.85

Tested by

no test coverage detected