Apply revised patch from bin/24647 by Peter Postma:

Adds a confirmation check before processing the data you have entered, or
sushi has entered for you on a form.
This commit is contained in:
garbled 2004-03-09 20:26:24 +00:00
parent ca430e5111
commit 8a2d792237
2 changed files with 19 additions and 3 deletions

View File

@ -55,6 +55,7 @@ $set 3 run.c stuff
14 be edited by issuing the List(F4) command, and toggling desired options 14 be edited by issuing the List(F4) command, and toggling desired options
15 with the spacebar. Press the ENTER key to return from the list popup. 15 with the spacebar. Press the ENTER key to return from the list popup.
16 No help is available for this screen. 16 No help is available for this screen.
17 Are you sure? (Y/n)
$set 4 menu titles and stuff $set 4 menu titles and stuff
1 Select choice 1 Select choice
2 Generating form data, please wait 2 Generating form data, please wait

View File

@ -1,4 +1,4 @@
/* $NetBSD: scanform.c,v 1.32 2004/03/09 19:10:20 garbled Exp $ */ /* $NetBSD: scanform.c,v 1.33 2004/03/09 20:26:24 garbled Exp $ */
/* /*
* Copyright (c) 2000 The NetBSD Foundation, Inc. * Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -551,10 +551,12 @@ my_driver(FORM * form, int c, char *path)
case QUIT: case QUIT:
/* do something useful */ /* do something useful */
if (form_driver(form, REQ_VALIDATION) == E_OK) { if (form_driver(form, REQ_VALIDATION) == E_OK) {
if (process_form(form, path) == 0) if ((i = process_form(form, path)) == 0)
return TRUE; return TRUE;
else if (i == -1)
return FALSE;
else else
return(2); /* special meaning */ return 2; /* special meaning */
} }
/* NOTREACHED */ /* NOTREACHED */
break; break;
@ -850,11 +852,24 @@ process_form(FORM *form, char *path)
int fc, lcnt, i, j; int fc, lcnt, i, j;
FIELD **f; FIELD **f;
char **args, **nargs; char **args, **nargs;
CDKLABEL *label;
char *msg[1];
int key;
/* handle the preform somewhere else */ /* handle the preform somewhere else */
if (strcmp("pre", form_userptr(form)) == 0) if (strcmp("pre", form_userptr(form)) == 0)
return(process_preform(form, path)); return(process_preform(form, path));
*msg = catgets(catalog, 3, 17, "Are you sure? (Y/n)");
label = newCDKLabel(cdkscreen, CENTER, CENTER, msg, 1, TRUE, FALSE);
activateCDKLabel(label, NULL);
key = waitCDKLabel(label, 0);
destroyCDKLabel(label);
touchwin(stdscr);
wrefresh(stdscr);
if (key != 13 && key != 10 && key != 121 && key != 89) /* enter y Y */
return -1;
if (lang_id == NULL) { if (lang_id == NULL) {
snprintf(file, sizeof(file), "%s/%s", path, EXECFILE); snprintf(file, sizeof(file), "%s/%s", path, EXECFILE);
snprintf(file2, sizeof(file2), "%s/%s", path, SCRIPTFILE); snprintf(file2, sizeof(file2), "%s/%s", path, SCRIPTFILE);