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

Function node__delete

extern/editline/src/keymacro.c:380–422  ·  view source on GitHub ↗

node__delete(): * Delete node that matches str */

Source from the content-addressed store, hash-verified

378 * Delete node that matches str
379 */
380private int
381node__delete(EditLine *el, keymacro_node_t **inptr, const Char *str)
382{
383 keymacro_node_t *ptr;
384 keymacro_node_t *prev_ptr = NULL;
385
386 ptr = *inptr;
387
388 if (ptr->ch != *str) {
389 keymacro_node_t *xm;
390
391 for (xm = ptr; xm->sibling != NULL; xm = xm->sibling)
392 if (xm->sibling->ch == *str)
393 break;
394 if (xm->sibling == NULL)
395 return 0;
396 prev_ptr = xm;
397 ptr = xm->sibling;
398 }
399 if (*++str == '\0') {
400 /* we're there */
401 if (prev_ptr == NULL)
402 *inptr = ptr->sibling;
403 else
404 prev_ptr->sibling = ptr->sibling;
405 ptr->sibling = NULL;
406 node__put(el, ptr);
407 return 1;
408 } else if (ptr->next != NULL &&
409 node__delete(el, &ptr->next, str) == 1) {
410 if (ptr->next != NULL)
411 return 0;
412 if (prev_ptr == NULL)
413 *inptr = ptr->sibling;
414 else
415 prev_ptr->sibling = ptr->sibling;
416 ptr->sibling = NULL;
417 node__put(el, ptr);
418 return 1;
419 } else {
420 return 0;
421 }
422}
423
424
425/* node__put():

Callers 1

keymacro_deleteFunction · 0.85

Calls 1

node__putFunction · 0.85

Tested by

no test coverage detected