node_enum(): * Traverse the node printing the characters it is bound in buffer */
| 540 | * Traverse the node printing the characters it is bound in buffer |
| 541 | */ |
| 542 | private int |
| 543 | node_enum(EditLine *el, keymacro_node_t *ptr, size_t cnt) |
| 544 | { |
| 545 | ssize_t used; |
| 546 | |
| 547 | if (cnt >= KEY_BUFSIZ - 5) { /* buffer too small */ |
| 548 | el->el_keymacro.buf[++cnt] = '"'; |
| 549 | el->el_keymacro.buf[++cnt] = '\0'; |
| 550 | (void) fprintf(el->el_errfile, |
| 551 | "Some extended keys too long for internal print buffer"); |
| 552 | (void) fprintf(el->el_errfile, " \"" FSTR "...\"\n", |
| 553 | el->el_keymacro.buf); |
| 554 | return 0; |
| 555 | } |
| 556 | if (ptr == NULL) { |
| 557 | #ifdef DEBUG_EDIT |
| 558 | (void) fprintf(el->el_errfile, |
| 559 | "node_enum: BUG!! Null ptr passed\n!"); |
| 560 | #endif |
| 561 | return -1; |
| 562 | } |
| 563 | /* put this char at end of str */ |
| 564 | used = ct_visual_char(el->el_keymacro.buf + cnt, KEY_BUFSIZ - cnt, |
| 565 | ptr->ch); |
| 566 | if (ptr->next == NULL) { |
| 567 | /* print this key and function */ |
| 568 | el->el_keymacro.buf[cnt + (size_t)used ] = '"'; |
| 569 | el->el_keymacro.buf[cnt + (size_t)used + 1] = '\0'; |
| 570 | keymacro_kprint(el, el->el_keymacro.buf, &ptr->val, ptr->type); |
| 571 | } else |
| 572 | (void) node_enum(el, ptr->next, cnt + (size_t)used); |
| 573 | |
| 574 | /* go to sibling if there is one */ |
| 575 | if (ptr->sibling) |
| 576 | (void) node_enum(el, ptr->sibling, cnt); |
| 577 | return 0; |
| 578 | } |
| 579 | |
| 580 | |
| 581 | /* keymacro_kprint(): |
no test coverage detected