# HG changeset patch # User Baptiste Daroussin # Date 1427902652 -7200 # Wed Apr 01 17:37:32 2015 +0200 # Node ID faf6bdf30db3efb11c923550f0db7fdcdd7908d4 # Parent 69e5db13fb270523d27f0b72c64e7dce41b898a3 Use atexit to ensure end_dialog() is always called once init_dialog has been done diff -r 69e5db13fb27 -r faf6bdf30db3 dialog4ports.c --- a/dialog4ports.c Wed May 21 21:40:00 2014 +0000 +++ b/dialog4ports.c Wed Apr 01 17:37:32 2015 +0200 @@ -206,10 +206,9 @@ int i = 0; int res; - if (list_no == 0) { - end_dialog(); + if (list_no == 0) err(EXIT_FAILURE, "List of items should not be empty"); - } else + else res = dlg_mixedlist(title, cprompt, height, min_height, width, list_no, items, &i, align_center); @@ -256,6 +255,7 @@ argv += optind; init_dialog(stdin, stdout); + atexit(end_dialog); temp = getenv("D4PHEIGHT"); if (temp != NULL) { @@ -301,16 +301,13 @@ portname = getenv("PKGNAME"); if (portname == NULL) { - end_dialog(); fprintf(stderr, "env PKGNAME is NULL\n"); usage(); } if ((helpfile = getenv("PKGHELP")) != NULL) { - if (eaccess(helpfile, R_OK) != 0) { - end_dialog(); + if (eaccess(helpfile, R_OK) != 0) err(EXIT_FAILURE, "%s", helpfile); - } dialog_vars.help_file = helpfile; }