PR/50919: David Binderman: Re-do all the debug stuff in a more sustainable way.
This commit is contained in:
parent
8da07e54f6
commit
23a151b438
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: field.c,v 1.30 2015/12/11 21:22:57 joerg Exp $ */
|
/* $NetBSD: field.c,v 1.31 2016/03/09 19:47:13 christos Exp $ */
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998-1999 Brett Lymn
|
* Copyright (c) 1998-1999 Brett Lymn
|
||||||
* (blymn@baea.com.au, brett_lymn@yahoo.com.au)
|
* (blymn@baea.com.au, brett_lymn@yahoo.com.au)
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: field.c,v 1.30 2015/12/11 21:22:57 joerg Exp $");
|
__RCSID("$NetBSD: field.c,v 1.31 2016/03/09 19:47:13 christos Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -425,26 +425,19 @@ set_field_buffer(FIELD *field, int buffer, const char *value)
|
||||||
&& ((field->rows + field->nrows) == 1))
|
&& ((field->rows + field->nrows) == 1))
|
||||||
len = field->cols;
|
len = field->cols;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf( "%s: len = %d, value = %s, buffer=%d\n", __func__,
|
||||||
if (_formi_create_dbg_file() != E_OK)
|
len, value, buffer);
|
||||||
return E_SYSTEM_ERROR;
|
|
||||||
|
|
||||||
fprintf(dbg,
|
|
||||||
"set_field_buffer: entry: len = %d, value = %s, buffer=%d\n",
|
|
||||||
len, value, buffer);
|
|
||||||
fprintf(dbg, "set_field_buffer: entry: string = ");
|
|
||||||
if (field->buffers[buffer].string != NULL)
|
if (field->buffers[buffer].string != NULL)
|
||||||
fprintf(dbg, "%s, len = %d\n", field->buffers[buffer].string,
|
_formi_dbg_printf("%s: string=%s, len = %d\n", __func__,
|
||||||
field->buffers[buffer].length);
|
field->buffers[buffer].string,
|
||||||
|
field->buffers[buffer].length);
|
||||||
else
|
else
|
||||||
fprintf(dbg, "(null), len = 0\n");
|
_formi_dbg_printf("%s: string=(null), len = 0\n", __func__);
|
||||||
fprintf(dbg, "set_field_buffer: entry: lines.len = %d\n",
|
_formi_dbg_printf("%s: lines.len = %d\n", __func__,
|
||||||
field->alines[0].length);
|
field->alines[0].length);
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((field->buffers[buffer].string =
|
if ((field->buffers[buffer].string = realloc(
|
||||||
(char *) realloc(field->buffers[buffer].string,
|
field->buffers[buffer].string, (size_t) len + 1)) == NULL)
|
||||||
(size_t) len + 1)) == NULL)
|
|
||||||
return E_SYSTEM_ERROR;
|
return E_SYSTEM_ERROR;
|
||||||
|
|
||||||
strlcpy(field->buffers[buffer].string, value, (size_t) len + 1);
|
strlcpy(field->buffers[buffer].string, value, (size_t) len + 1);
|
||||||
|
@ -452,14 +445,11 @@ set_field_buffer(FIELD *field, int buffer, const char *value)
|
||||||
field->buffers[buffer].allocated = len + 1;
|
field->buffers[buffer].allocated = len + 1;
|
||||||
status = field_buffer_init(field, buffer, len);
|
status = field_buffer_init(field, buffer, len);
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: len = %d, value = %s\n", __func__, len, value);
|
||||||
fprintf(dbg, "set_field_buffer: exit: len = %d, value = %s\n",
|
_formi_dbg_printf("%s: string = %s, len = %d\n", __func__,
|
||||||
len, value);
|
field->buffers[buffer].string, field->buffers[buffer].length);
|
||||||
fprintf(dbg, "set_field_buffer: exit: string = %s, len = %d\n",
|
_formi_dbg_printf("%s: lines.len = %d\n", __func__,
|
||||||
field->buffers[buffer].string, field->buffers[buffer].length);
|
|
||||||
fprintf(dbg, "set_field_buffer: exit: lines.len = %d\n",
|
|
||||||
field->alines[0].length);
|
field->alines[0].length);
|
||||||
#endif
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: form.c,v 1.15 2004/11/24 11:57:09 blymn Exp $ */
|
/* $NetBSD: form.c,v 1.16 2016/03/09 19:47:13 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998-1999 Brett Lymn
|
* Copyright (c) 1998-1999 Brett Lymn
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: form.c,v 1.15 2004/11/24 11:57:09 blymn Exp $");
|
__RCSID("$NetBSD: form.c,v 1.16 2016/03/09 19:47:13 christos Exp $");
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
@ -603,9 +603,7 @@ pos_form_cursor(FORM *form)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: row=%d, col=%d\n", __func__, row, col);
|
||||||
fprintf(dbg, "pos_cursor: row=%d, col=%d\n", row, col);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wmove(form->scrwin, row, col);
|
wmove(form->scrwin, row, col);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: internals.c,v 1.37 2013/11/26 01:17:00 christos Exp $ */
|
/* $NetBSD: internals.c,v 1.38 2016/03/09 19:47:13 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998-1999 Brett Lymn
|
* Copyright (c) 1998-1999 Brett Lymn
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: internals.c,v 1.37 2013/11/26 01:17:00 christos Exp $");
|
__RCSID("$NetBSD: internals.c,v 1.38 2016/03/09 19:47:13 christos Exp $");
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -38,6 +38,8 @@ __RCSID("$NetBSD: internals.c,v 1.37 2013/11/26 01:17:00 christos Exp $");
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
#include "form.h"
|
#include "form.h"
|
||||||
|
|
||||||
|
@ -46,12 +48,11 @@ __RCSID("$NetBSD: internals.c,v 1.37 2013/11/26 01:17:00 christos Exp $");
|
||||||
* file handle to write debug info to, this will be initialised when
|
* file handle to write debug info to, this will be initialised when
|
||||||
* the form is first posted.
|
* the form is first posted.
|
||||||
*/
|
*/
|
||||||
FILE *dbg = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* map the request numbers to strings for debug
|
* map the request numbers to strings for debug
|
||||||
*/
|
*/
|
||||||
char *reqs[] = {
|
static const char *reqs[] = {
|
||||||
"NEXT_PAGE", "PREV_PAGE", "FIRST_PAGE", "LAST_PAGE", "NEXT_FIELD",
|
"NEXT_PAGE", "PREV_PAGE", "FIRST_PAGE", "LAST_PAGE", "NEXT_FIELD",
|
||||||
"PREV_FIELD", "FIRST_FIELD", "LAST_FIELD", "SNEXT_FIELD",
|
"PREV_FIELD", "FIRST_FIELD", "LAST_FIELD", "SNEXT_FIELD",
|
||||||
"SPREV_FIELD", "SFIRST_FIELD", "SLAST_FIELD", "LEFT_FIELD",
|
"SPREV_FIELD", "SFIRST_FIELD", "SLAST_FIELD", "LEFT_FIELD",
|
||||||
|
@ -317,18 +318,21 @@ _formi_init_field_xpos(FIELD *field)
|
||||||
* Open the debug file if it is not already open....
|
* Open the debug file if it is not already open....
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int
|
static FILE *dbg;
|
||||||
_formi_create_dbg_file(void)
|
static const char dbg_file[] = "___form_dbg.out";
|
||||||
{
|
|
||||||
if (dbg == NULL) {
|
|
||||||
dbg = fopen("___form_dbg.out", "w");
|
|
||||||
if (dbg == NULL) {
|
|
||||||
fprintf(stderr, "Cannot open debug file!\n");
|
|
||||||
return E_SYSTEM_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return E_OK;
|
void
|
||||||
|
_formi_dbg_printf(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
if (dbg == NULL && (dbg = fopen(dbg_file, "w")) == NULL) {
|
||||||
|
warn("Cannot open debug file `%s'", dbg_file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vfprintf(dbg, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -709,18 +713,9 @@ _formi_join_line(FIELD *field, _FORMI_FIELD_LINES **rowp, int direction)
|
||||||
struct _formi_field_lines *saved;
|
struct _formi_field_lines *saved;
|
||||||
char *newp;
|
char *newp;
|
||||||
_FORMI_FIELD_LINES *row = *rowp;
|
_FORMI_FIELD_LINES *row = *rowp;
|
||||||
#ifdef DEBUG
|
|
||||||
int dbg_ok = FALSE;
|
|
||||||
|
|
||||||
if (_formi_create_dbg_file() == E_OK) {
|
_formi_dbg_printf("%s: working on row %p, row_count = %d\n",
|
||||||
dbg_ok = TRUE;
|
__func__, row, field->row_count);
|
||||||
}
|
|
||||||
|
|
||||||
if (dbg_ok == TRUE) {
|
|
||||||
fprintf(dbg, "join_line: working on row %p, row_count = %d\n",
|
|
||||||
row, field->row_count);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((direction == JOIN_NEXT) || (direction == JOIN_NEXT_NW)) {
|
if ((direction == JOIN_NEXT) || (direction == JOIN_NEXT_NW)) {
|
||||||
/*
|
/*
|
||||||
|
@ -732,16 +727,12 @@ _formi_join_line(FIELD *field, _FORMI_FIELD_LINES **rowp, int direction)
|
||||||
return E_REQUEST_DENIED;
|
return E_REQUEST_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf(
|
||||||
if (dbg_ok == TRUE) {
|
"%s: join_next before length = %d, expanded = %d",
|
||||||
fprintf(dbg,
|
__func__, row->length, row->expanded);
|
||||||
"join_line: join_next before length = %d, expanded = %d",
|
_formi_dbg_printf(
|
||||||
row->length, row->expanded);
|
" :: next row length = %d, expanded = %d\n",
|
||||||
fprintf(dbg,
|
row->length, row->expanded);
|
||||||
" :: next row length = %d, expanded = %d\n",
|
|
||||||
row->length, row->expanded);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (row->allocated < (row->length + row->next->length + 1)) {
|
if (row->allocated < (row->length + row->next->length + 1)) {
|
||||||
if ((newp = realloc(row->string, (size_t)(row->length +
|
if ((newp = realloc(row->string, (size_t)(row->length +
|
||||||
|
@ -787,13 +778,9 @@ _formi_join_line(FIELD *field, _FORMI_FIELD_LINES **rowp, int direction)
|
||||||
/* remove joined line record from the row list */
|
/* remove joined line record from the row list */
|
||||||
add_to_free(field, row->next);
|
add_to_free(field, row->next);
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf(
|
||||||
if (dbg_ok == TRUE) {
|
"%s: exit length = %d, expanded = %d\n",
|
||||||
fprintf(dbg,
|
__func__, row->length, row->expanded);
|
||||||
"join_line: exit length = %d, expanded = %d\n",
|
|
||||||
row->length, row->expanded);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
if (row->prev == NULL) {
|
if (row->prev == NULL) {
|
||||||
return E_REQUEST_DENIED;
|
return E_REQUEST_DENIED;
|
||||||
|
@ -809,16 +796,12 @@ _formi_join_line(FIELD *field, _FORMI_FIELD_LINES **rowp, int direction)
|
||||||
return E_REQUEST_DENIED;
|
return E_REQUEST_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf(
|
||||||
if (dbg_ok == TRUE) {
|
"%s: join_prev before length = %d, expanded = %d",
|
||||||
fprintf(dbg,
|
__func__, row->length, row->expanded);
|
||||||
"join_line: join_prev before length = %d, expanded = %d",
|
_formi_dbg_printf(
|
||||||
row->length, row->expanded);
|
" :: prev row length = %d, expanded = %d\n",
|
||||||
fprintf(dbg,
|
saved->length, saved->expanded);
|
||||||
" :: prev row length = %d, expanded = %d\n",
|
|
||||||
saved->length, saved->expanded);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (saved->allocated < (row->length + saved->length + 1)) {
|
if (saved->allocated < (row->length + saved->length + 1)) {
|
||||||
if ((newp = realloc(saved->string,
|
if ((newp = realloc(saved->string,
|
||||||
|
@ -855,13 +838,9 @@ _formi_join_line(FIELD *field, _FORMI_FIELD_LINES **rowp, int direction)
|
||||||
|
|
||||||
add_to_free(field, row);
|
add_to_free(field, row);
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf(
|
||||||
if (dbg_ok == TRUE) {
|
"%s: exit length = %d, expanded = %d\n", __func__,
|
||||||
fprintf(dbg,
|
saved->length, saved->expanded);
|
||||||
"join_line: exit length = %d, expanded = %d\n",
|
|
||||||
saved->length, saved->expanded);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
row = saved;
|
row = saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,9 +889,6 @@ split_line(FIELD *field, bool hard_split, unsigned pos,
|
||||||
struct _formi_field_lines *new_line;
|
struct _formi_field_lines *new_line;
|
||||||
char *newp;
|
char *newp;
|
||||||
_FORMI_FIELD_LINES *row = *rowp;
|
_FORMI_FIELD_LINES *row = *rowp;
|
||||||
#ifdef DEBUG
|
|
||||||
short dbg_ok = FALSE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* if asked to split right where the line already starts then
|
/* if asked to split right where the line already starts then
|
||||||
* just return - nothing to do unless we are appending a line
|
* just return - nothing to do unless we are appending a line
|
||||||
|
@ -921,12 +897,7 @@ split_line(FIELD *field, bool hard_split, unsigned pos,
|
||||||
if ((pos == 0) && (hard_split == FALSE))
|
if ((pos == 0) && (hard_split == FALSE))
|
||||||
return E_OK;
|
return E_OK;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: splitting line at %d\n", __func__, pos);
|
||||||
if (_formi_create_dbg_file() == E_OK) {
|
|
||||||
fprintf(dbg, "split_line: splitting line at %d\n", pos);
|
|
||||||
dbg_ok = TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Need an extra line struct, check free list first */
|
/* Need an extra line struct, check free list first */
|
||||||
if (field->free != NULL) {
|
if (field->free != NULL) {
|
||||||
|
@ -935,8 +906,7 @@ split_line(FIELD *field, bool hard_split, unsigned pos,
|
||||||
if (field->free != NULL)
|
if (field->free != NULL)
|
||||||
field->free->prev = NULL;
|
field->free->prev = NULL;
|
||||||
} else {
|
} else {
|
||||||
if ((new_line = (struct _formi_field_lines *)
|
if ((new_line = malloc(sizeof(*new_line))) == NULL)
|
||||||
malloc(sizeof(struct _formi_field_lines))) == NULL)
|
|
||||||
return E_SYSTEM_ERROR;
|
return E_SYSTEM_ERROR;
|
||||||
new_line->prev = NULL;
|
new_line->prev = NULL;
|
||||||
new_line->next = NULL;
|
new_line->next = NULL;
|
||||||
|
@ -948,13 +918,8 @@ split_line(FIELD *field, bool hard_split, unsigned pos,
|
||||||
new_line->tabs = NULL;
|
new_line->tabs = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: enter: length = %d, expanded = %d\n", __func__,
|
||||||
if (dbg_ok == TRUE) {
|
row->length, row->expanded);
|
||||||
fprintf(dbg,
|
|
||||||
"split_line: enter: length = %d, expanded = %d\n",
|
|
||||||
row->length, row->expanded);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
assert((row->length < INT_MAX) && (row->expanded < INT_MAX));
|
assert((row->length < INT_MAX) && (row->expanded < INT_MAX));
|
||||||
|
|
||||||
|
@ -1043,17 +1008,12 @@ split_line(FIELD *field, bool hard_split, unsigned pos,
|
||||||
(row->length < INT_MAX) &&
|
(row->length < INT_MAX) &&
|
||||||
(new_line->length < INT_MAX)));
|
(new_line->length < INT_MAX)));
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: exit: ", __func__);
|
||||||
if (dbg_ok == TRUE) {
|
_formi_dbg_printf("row.length = %d, row.expanded = %d, ",
|
||||||
fprintf(dbg, "split_line: exit: ");
|
row->length, row->expanded);
|
||||||
fprintf(dbg, "row.length = %d, row.expanded = %d, ",
|
_formi_dbg_printf("next_line.length = %d, next_line.expanded = %d, ",
|
||||||
row->length, row->expanded);
|
new_line->length, new_line->expanded);
|
||||||
fprintf(dbg,
|
_formi_dbg_printf("row_count = %d\n", field->row_count + 1);
|
||||||
"next_line.length = %d, next_line.expanded = %d, ",
|
|
||||||
new_line->length, new_line->expanded);
|
|
||||||
fprintf(dbg, "row_count = %d\n", field->row_count + 1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
field->row_count++;
|
field->row_count++;
|
||||||
*rowp = new_line;
|
*rowp = new_line;
|
||||||
|
@ -1662,40 +1622,35 @@ _formi_redraw_field(FORM *form, int field)
|
||||||
str = &row->string[cur->start_char];
|
str = &row->string[cur->start_char];
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (_formi_create_dbg_file() == E_OK) {
|
_formi_dbg_printf(
|
||||||
fprintf(dbg,
|
"%s: start=%d, pre=%d, slen=%d, flen=%d, post=%d, "
|
||||||
"redraw_field: start=%d, pre=%d, slen=%d, flen=%d, post=%d, start_char=%d\n",
|
"start_char=%d\n", __func__,
|
||||||
start, pre, slen, flen, post, cur->start_char);
|
start, pre, slen, flen, post, cur->start_char);
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
if (row->expanded != 0) {
|
if (row->expanded != 0) {
|
||||||
strncpy(buffer, str, flen);
|
strncpy(buffer, str, flen);
|
||||||
} else {
|
|
||||||
strcpy(buffer, "(empty)");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
strcpy(buffer, "(null)");
|
strcpy(buffer, "(empty)");
|
||||||
}
|
}
|
||||||
buffer[flen] = '\0';
|
} else {
|
||||||
fprintf(dbg, "redraw_field: %s\n", buffer);
|
strcpy(buffer, "(null)");
|
||||||
}
|
}
|
||||||
|
buffer[flen] = '\0';
|
||||||
|
_formi_dbg_printf("%s: %s\n", __func__, buffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = start + cur->start_char; i < pre; i++)
|
for (i = start + cur->start_char; i < pre; i++)
|
||||||
waddch(form->scrwin, cur->pad);
|
waddch(form->scrwin, cur->pad);
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: will add %d chars\n", __func__,
|
||||||
fprintf(dbg, "redraw_field: will add %d chars\n",
|
|
||||||
min(slen, flen));
|
min(slen, flen));
|
||||||
#endif
|
|
||||||
for (i = 0, cpos = cur->start_char; i < min(slen, flen);
|
for (i = 0, cpos = cur->start_char; i < min(slen, flen);
|
||||||
i++, str++, cpos++)
|
i++, str++, cpos++)
|
||||||
{
|
{
|
||||||
c = *str;
|
c = *str;
|
||||||
tab = 0; /* just to shut gcc up */
|
tab = 0; /* just to shut gcc up */
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("adding char str[%d]=%c\n",
|
||||||
fprintf(dbg, "adding char str[%d]=%c\n",
|
cpos + cur->start_char, c);
|
||||||
cpos + cur->start_char, c);
|
|
||||||
#endif
|
|
||||||
if (((cur->opts & O_PUBLIC) != O_PUBLIC)) {
|
if (((cur->opts & O_PUBLIC) != O_PUBLIC)) {
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
tab = add_tab(form, row, cpos,
|
tab = add_tab(form, row, cpos,
|
||||||
|
@ -1817,28 +1772,23 @@ _formi_add_char(FIELD *field, unsigned int pos, char c)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_formi_validate_char(field, c) != E_OK) {
|
if (_formi_validate_char(field, c) != E_OK) {
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: char %c failed char validation\n",
|
||||||
fprintf(dbg, "add_char: char %c failed char validation\n", c);
|
__func__, c);
|
||||||
#endif
|
|
||||||
return E_INVALID_FIELD;
|
return E_INVALID_FIELD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((c == '\t') && (field->cols <= 8)) {
|
if ((c == '\t') && (field->cols <= 8)) {
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: field too small for a tab\n", __func__);
|
||||||
fprintf(dbg, "add_char: field too small for a tab\n");
|
|
||||||
#endif
|
|
||||||
return E_NO_ROOM;
|
return E_NO_ROOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: pos=%d, char=%c\n", __func__, pos, c);
|
||||||
fprintf(dbg, "add_char: pos=%d, char=%c\n", pos, c);
|
_formi_dbg_printf("%s: xpos=%d, row_pos=%d, start=%d\n", __func__,
|
||||||
fprintf(dbg, "add_char enter: xpos=%d, row_pos=%d, start=%d\n",
|
|
||||||
field->cursor_xpos, field->row_xpos, field->start_char);
|
field->cursor_xpos, field->row_xpos, field->start_char);
|
||||||
fprintf(dbg, "add_char enter: length=%d(%d), allocated=%d\n",
|
_formi_dbg_printf("%s: length=%d(%d), allocated=%d\n", __func__,
|
||||||
row->expanded, row->length, row->allocated);
|
row->expanded, row->length, row->allocated);
|
||||||
fprintf(dbg, "add_char enter: %s\n", row->string);
|
_formi_dbg_printf("%s: %s\n", __func__, row->string);
|
||||||
fprintf(dbg, "add_char enter: buf0_status=%d\n", field->buf0_status);
|
_formi_dbg_printf("%s: buf0_status=%d\n", __func__, field->buf0_status);
|
||||||
#endif
|
|
||||||
if (((field->opts & O_BLANK) == O_BLANK) &&
|
if (((field->opts & O_BLANK) == O_BLANK) &&
|
||||||
(field->buf0_status == FALSE) &&
|
(field->buf0_status == FALSE) &&
|
||||||
((field->row_xpos + field->start_char) == 0)) {
|
((field->row_xpos + field->start_char) == 0)) {
|
||||||
|
@ -1980,18 +1930,16 @@ _formi_add_char(FIELD *field, unsigned int pos, char c)
|
||||||
assert((field->cursor_xpos <= field->cols)
|
assert((field->cursor_xpos <= field->cols)
|
||||||
&& (field->cursor_ypos < 400000));
|
&& (field->cursor_ypos < 400000));
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: xpos=%d, row_pos=%d, start=%d\n", __func__,
|
||||||
fprintf(dbg, "add_char exit: xpos=%d, row_pos=%d, start=%d\n",
|
|
||||||
field->cursor_xpos, field->row_xpos, field->start_char);
|
field->cursor_xpos, field->row_xpos, field->start_char);
|
||||||
fprintf(dbg, "add_char_exit: length=%d(%d), allocated=%d\n",
|
_formi_dbg_printf("%s: length=%d(%d), allocated=%d\n", __func__,
|
||||||
row->expanded, row->length, row->allocated);
|
row->expanded, row->length, row->allocated);
|
||||||
fprintf(dbg, "add_char exit: ypos=%d, start_line=%p\n",
|
_formi_dbg_printf("%s: ypos=%d, start_line=%p\n", __func__,
|
||||||
field->cursor_ypos, field->start_line);
|
field->cursor_ypos, field->start_line);
|
||||||
fprintf(dbg,"add_char exit: %s\n", row->string);
|
_formi_dbg_printf("%s: %s\n", __func__, row->string);
|
||||||
fprintf(dbg, "add_char exit: buf0_status=%d\n", field->buf0_status);
|
_formi_dbg_printf("%s: buf0_status=%d\n", __func__, field->buf0_status);
|
||||||
fprintf(dbg, "add_char exit: status = %s\n",
|
_formi_dbg_printf("%s: status = %s\n", __func__,
|
||||||
(status == E_OK)? "OK" : "FAILED");
|
(status == E_OK)? "OK" : "FAILED");
|
||||||
#endif
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2009,11 +1957,9 @@ _formi_set_cursor_xpos(FIELD *field, int noscroll)
|
||||||
just = field->justification;
|
just = field->justification;
|
||||||
pos = field->start_char + field->row_xpos;
|
pos = field->start_char + field->row_xpos;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf(
|
||||||
fprintf(dbg,
|
"%s: pos %d, start_char %d, row_xpos %d, xpos %d\n", __func__,
|
||||||
"cursor_xpos enter: pos %d, start_char %d, row_xpos %d, xpos %d\n",
|
pos, field->start_char, field->row_xpos, field->cursor_xpos);
|
||||||
pos, field->start_char, field->row_xpos, field->cursor_xpos);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make sure we apply the correct justification to non-static
|
* make sure we apply the correct justification to non-static
|
||||||
|
@ -2097,11 +2043,9 @@ _formi_set_cursor_xpos(FIELD *field, int noscroll)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf(
|
||||||
fprintf(dbg,
|
"%s: pos %d, start_char %d, row_xpos %d, xpos %d\n", __func__,
|
||||||
"cursor_xpos exit: pos %d, start_char %d, row_xpos %d, xpos %d\n",
|
pos, field->start_char, field->row_xpos, field->cursor_xpos);
|
||||||
pos, field->start_char, field->row_xpos, field->cursor_xpos);
|
|
||||||
#endif
|
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2125,20 +2069,19 @@ _formi_manipulate_field(FORM *form, int c)
|
||||||
if (cur->cur_line->string == NULL)
|
if (cur->cur_line->string == NULL)
|
||||||
return E_REQUEST_DENIED;
|
return E_REQUEST_DENIED;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: request is REQ_%s\n",
|
||||||
fprintf(dbg, "entry: request is REQ_%s\n", reqs[c - REQ_MIN_REQUEST]);
|
__func__, reqs[c - REQ_MIN_REQUEST]);
|
||||||
fprintf(dbg,
|
_formi_dbg_printf(
|
||||||
"entry: xpos=%d, row_pos=%d, start_char=%d, length=%d, allocated=%d\n",
|
"%s: xpos=%d, row_pos=%d, start_char=%d, length=%d, allocated=%d\n",
|
||||||
cur->cursor_xpos, cur->row_xpos, cur->start_char,
|
__func__, cur->cursor_xpos, cur->row_xpos, cur->start_char,
|
||||||
cur->cur_line->length, cur->cur_line->allocated);
|
cur->cur_line->length, cur->cur_line->allocated);
|
||||||
fprintf(dbg, "entry: start_line=%p, ypos=%d\n", cur->start_line,
|
_formi_dbg_printf("%s: start_line=%p, ypos=%d\n", __func__,
|
||||||
cur->cursor_ypos);
|
cur->start_line, cur->cursor_ypos);
|
||||||
fprintf(dbg, "entry: string=");
|
|
||||||
if (cur->cur_line->string == NULL)
|
if (cur->cur_line->string == NULL)
|
||||||
fprintf(dbg, "(null)\n");
|
_formi_dbg_printf("%s: string=(null)\n", __func__);
|
||||||
else
|
else
|
||||||
fprintf(dbg, "\"%s\"\n", cur->cur_line->string);
|
_formi_dbg_printf("%s: string=\"%s\"\n", __func__,
|
||||||
#endif
|
cur->cur_line->string);
|
||||||
|
|
||||||
/* Cannot manipulate a null string! */
|
/* Cannot manipulate a null string! */
|
||||||
if (cur->cur_line->string == NULL)
|
if (cur->cur_line->string == NULL)
|
||||||
|
@ -2981,17 +2924,16 @@ _formi_manipulate_field(FORM *form, int c)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf(
|
||||||
fprintf(dbg,
|
"%s: cursor_xpos=%d, row_xpos=%d, start_char=%d, length=%d, "
|
||||||
"exit: cursor_xpos=%d, row_xpos=%d, start_char=%d, length=%d, allocated=%d\n",
|
"allocated=%d\n", __func__, cur->cursor_xpos, cur->row_xpos,
|
||||||
cur->cursor_xpos, cur->row_xpos, cur->start_char,
|
cur->start_char, cur->cur_line->length, cur->cur_line->allocated);
|
||||||
cur->cur_line->length, cur->cur_line->allocated);
|
_formi_dbg_printf("%s: start_line=%p, ypos=%d\n", __func__,
|
||||||
fprintf(dbg, "exit: start_line=%p, ypos=%d\n", cur->start_line,
|
cur->start_line, cur->cursor_ypos);
|
||||||
cur->cursor_ypos);
|
_formi_dbg_printf("%s: string=\"%s\"\n", __func__,
|
||||||
fprintf(dbg, "exit: string=\"%s\"\n", cur->cur_line->string);
|
cur->cur_line->string);
|
||||||
assert ((cur->cursor_xpos < INT_MAX) && (cur->row_xpos < INT_MAX)
|
assert ((cur->cursor_xpos < INT_MAX) && (cur->row_xpos < INT_MAX)
|
||||||
&& (cur->cursor_xpos >= cur->row_xpos));
|
&& (cur->cursor_xpos >= cur->row_xpos));
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3415,13 +3357,9 @@ _formi_tab_expanded_length(char *str, unsigned int start, unsigned int end)
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf(
|
||||||
if (dbg != NULL) {
|
"%s: start=%d, end=%d, expanded=%d (diff=%d)\n", __func__,
|
||||||
fprintf(dbg,
|
start, end, (len - start_len), (end - start));
|
||||||
"tab_expanded: start=%d, end=%d, expanded=%d (diff=%d)\n",
|
|
||||||
start, end, (len - start_len), (end - start));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (len - start_len);
|
return (len - start_len);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: internals.h,v 1.10 2004/11/24 11:57:09 blymn Exp $ */
|
/* $NetBSD: internals.h,v 1.11 2016/03/09 19:47:13 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998-1999 Brett Lymn
|
* Copyright (c) 1998-1999 Brett Lymn
|
||||||
|
@ -35,10 +35,6 @@
|
||||||
#ifndef FORMI_INTERNALS_H
|
#ifndef FORMI_INTERNALS_H
|
||||||
#define FORMI_INTERNALS_H 1
|
#define FORMI_INTERNALS_H 1
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
extern FILE *dbg;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* direction definitions for _formi_pos_new_field */
|
/* direction definitions for _formi_pos_new_field */
|
||||||
#define _FORMI_BACKWARD 1
|
#define _FORMI_BACKWARD 1
|
||||||
#define _FORMI_FORWARD 2
|
#define _FORMI_FORWARD 2
|
||||||
|
@ -141,11 +137,9 @@ int
|
||||||
_formi_sync_buffer(FIELD *field);
|
_formi_sync_buffer(FIELD *field);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int
|
void _formi_dbg_printf(const char *, ...) __printflike(1, 2);
|
||||||
_formi_create_dbg_file(void);
|
#else
|
||||||
|
#define _formi_dbg_printf(a,...)
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: post.c,v 1.9 2003/03/09 00:57:19 lukem Exp $ */
|
/* $NetBSD: post.c,v 1.10 2016/03/09 19:47:13 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998-2000 Brett Lymn
|
* Copyright (c) 1998-2000 Brett Lymn
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: post.c,v 1.9 2003/03/09 00:57:19 lukem Exp $");
|
__RCSID("$NetBSD: post.c,v 1.10 2016/03/09 19:47:13 christos Exp $");
|
||||||
|
|
||||||
#include "form.h"
|
#include "form.h"
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
|
@ -63,11 +63,6 @@ post_form(FORM *form)
|
||||||
return E_NO_ROOM;
|
return E_NO_ROOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (_formi_create_dbg_file() != E_OK)
|
|
||||||
return E_SYSTEM_ERROR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
form->in_init = 1;
|
form->in_init = 1;
|
||||||
if (form->form_init != NULL)
|
if (form->form_init != NULL)
|
||||||
form->form_init(form);
|
form->form_init(form);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: type_enum.c,v 1.11 2010/05/13 17:52:12 tnozaki Exp $ */
|
/* $NetBSD: type_enum.c,v 1.12 2016/03/09 19:47:13 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998-1999 Brett Lymn
|
* Copyright (c) 1998-1999 Brett Lymn
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: type_enum.c,v 1.11 2010/05/13 17:52:12 tnozaki Exp $");
|
__RCSID("$NetBSD: type_enum.c,v 1.12 2016/03/09 19:47:13 christos Exp $");
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -87,39 +87,28 @@ create_enum_args(va_list *args)
|
||||||
enum_args *new;
|
enum_args *new;
|
||||||
char **choices;
|
char **choices;
|
||||||
|
|
||||||
new = (enum_args *) malloc(sizeof(enum_args));
|
new = malloc(sizeof(*new));
|
||||||
|
if (new == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (new != NULL) {
|
new->choices = va_arg(*args, char **);
|
||||||
new->choices = va_arg(*args, char **);
|
new->ignore_case = (va_arg(*args, int)) ? TRUE : FALSE;
|
||||||
new->ignore_case = (va_arg(*args, int)) ? TRUE : FALSE;
|
new->exact = (va_arg(*args, int)) ? TRUE : FALSE;
|
||||||
new->exact = (va_arg(*args, int)) ? TRUE : FALSE;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: ignore_case %d, no_blanks %d\n", __func__,
|
||||||
if (_formi_create_dbg_file() != E_OK)
|
new->ignore_case, new->exact);
|
||||||
return NULL;
|
|
||||||
fprintf(dbg,
|
/* count the choices we have */
|
||||||
"create_enum_args: ignore_case %d, no_blanks %d\n",
|
choices = new->choices;
|
||||||
new->ignore_case, new->exact);
|
new->num_choices = 0;
|
||||||
#endif
|
while (*choices != NULL) {
|
||||||
|
_formi_dbg_printf("%s: choice[%u] = \'%s\'\n", __func__,
|
||||||
/* count the choices we have */
|
new->num_choices, new->choices[new->num_choices]);
|
||||||
choices = new->choices;
|
new->num_choices++;
|
||||||
new->num_choices = 0;
|
choices++;
|
||||||
while (*choices != NULL) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(dbg, "create_enum_args: choice[%d] = \'%s\'\n",
|
|
||||||
new->num_choices,
|
|
||||||
new->choices[new->num_choices]);
|
|
||||||
#endif
|
|
||||||
new->num_choices++;
|
|
||||||
choices++;
|
|
||||||
}
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(dbg, "create_enum_args: have %d choices\n",
|
|
||||||
new->num_choices);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
_formi_dbg_printf("%s: have %u choices\n", __func__,
|
||||||
|
new->num_choices);
|
||||||
|
|
||||||
return (void *) new;
|
return (void *) new;
|
||||||
}
|
}
|
||||||
|
@ -171,9 +160,7 @@ match_enum(char **choices, unsigned num_choices, bool ignore_case,
|
||||||
else
|
else
|
||||||
blen = 0;
|
blen = 0;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: start %u, blen %u\n", __func__, start, blen);
|
||||||
fprintf(dbg, "match_enum: start %d, blen %d\n", start, blen);
|
|
||||||
#endif
|
|
||||||
for (i = 0; i < num_choices; i++) {
|
for (i = 0; i < num_choices; i++) {
|
||||||
enum_start = _formi_skip_blanks(choices[i], 0);
|
enum_start = _formi_skip_blanks(choices[i], 0);
|
||||||
enum_end = trim_blanks(choices[i]);
|
enum_end = trim_blanks(choices[i]);
|
||||||
|
@ -184,12 +171,10 @@ match_enum(char **choices, unsigned num_choices, bool ignore_case,
|
||||||
else
|
else
|
||||||
elen = 0;
|
elen = 0;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: checking choice \'%s\'\n", __func__,
|
||||||
fprintf(dbg, "match_enum: checking choice \'%s\'\n",
|
|
||||||
choices[i]);
|
choices[i]);
|
||||||
fprintf(dbg, "match_enum: enum_start %d, elen %d\n",
|
_formi_dbg_printf("%s: enum_start %u, elen %u\n", __func__,
|
||||||
enum_start, elen);
|
enum_start, elen);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* don't bother if we are after an exact match
|
/* don't bother if we are after an exact match
|
||||||
* and the test length is not equal to the enum
|
* and the test length is not equal to the enum
|
||||||
|
@ -217,10 +202,8 @@ match_enum(char **choices, unsigned num_choices, bool ignore_case,
|
||||||
(size_t) blen) == 0) ?
|
(size_t) blen) == 0) ?
|
||||||
TRUE : FALSE;
|
TRUE : FALSE;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: curmatch is %s\n", __func__,
|
||||||
fprintf(dbg, "match_enum: curmatch is %s\n",
|
|
||||||
(cur_match == TRUE)? "TRUE" : "FALSE");
|
(cur_match == TRUE)? "TRUE" : "FALSE");
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cur_match == TRUE) {
|
if (cur_match == TRUE) {
|
||||||
*match_num = i;
|
*match_num = i;
|
||||||
|
@ -229,9 +212,7 @@ match_enum(char **choices, unsigned num_choices, bool ignore_case,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: no match found\n", __func__);
|
||||||
fprintf(dbg, "match_enum: no match found\n");
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,12 +232,10 @@ enum_check_field(FIELD *field, char *args)
|
||||||
|
|
||||||
if (match_enum(ta->choices, ta->num_choices, ta->ignore_case,
|
if (match_enum(ta->choices, ta->num_choices, ta->ignore_case,
|
||||||
ta->exact, args, &match_num) == TRUE) {
|
ta->exact, args, &match_num) == TRUE) {
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: We matched, match_num %u\n", __func__,
|
||||||
fprintf(dbg, "enum_check_field: We matched, match_num %d\n",
|
match_num);
|
||||||
match_num);
|
_formi_dbg_printf("%s: buffer is \'%s\'\n", __func__,
|
||||||
fprintf(dbg, "enum_check_field: buffer is \'%s\'\n",
|
ta->choices[match_num]);
|
||||||
ta->choices[match_num]);
|
|
||||||
#endif
|
|
||||||
set_field_buffer(field, 0, ta->choices[match_num]);
|
set_field_buffer(field, 0, ta->choices[match_num]);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -278,31 +257,23 @@ next_enum(FIELD *field, char *args)
|
||||||
|
|
||||||
ta = (enum_args *) (void *) field->args;
|
ta = (enum_args *) (void *) field->args;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: attempt to match \'%s\'\n", __func__, args);
|
||||||
fprintf(dbg, "next_enum: attempt to match \'%s\'\n", args);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (match_enum(ta->choices, ta->num_choices, ta->ignore_case,
|
if (match_enum(ta->choices, ta->num_choices, ta->ignore_case,
|
||||||
ta->exact, args, &cur_choice) == FALSE) {
|
ta->exact, args, &cur_choice) == FALSE) {
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: match failed\n", __func__);
|
||||||
fprintf(dbg, "next_enum: match failed\n");
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: cur_choice is %u\n", __func__, cur_choice);
|
||||||
fprintf(dbg, "next_enum: cur_choice is %d\n", cur_choice);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cur_choice++;
|
cur_choice++;
|
||||||
|
|
||||||
if (cur_choice >= ta->num_choices)
|
if (cur_choice >= ta->num_choices)
|
||||||
cur_choice = 0;
|
cur_choice = 0;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: cur_choice is %u on exit\n", __func__,
|
||||||
fprintf(dbg, "next_enum: cur_choice is %d on exit\n",
|
cur_choice);
|
||||||
cur_choice);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
set_field_buffer(field, 0, ta->choices[cur_choice]);
|
set_field_buffer(field, 0, ta->choices[cur_choice]);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -322,29 +293,22 @@ prev_enum(FIELD *field, char *args)
|
||||||
|
|
||||||
ta = (enum_args *) (void *) field->args;
|
ta = (enum_args *) (void *) field->args;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: attempt to match \'%s\'\n", __func__, args);
|
||||||
fprintf(dbg, "prev_enum: attempt to match \'%s\'\n", args);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (match_enum(ta->choices, ta->num_choices, ta->ignore_case,
|
if (match_enum(ta->choices, ta->num_choices, ta->ignore_case,
|
||||||
ta->exact, args, &cur_choice) == FALSE) {
|
ta->exact, args, &cur_choice) == FALSE) {
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: match failed\n", __func__);
|
||||||
fprintf(dbg, "prev_enum: match failed\n");
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: cur_choice is %u\n", __func__, cur_choice);
|
||||||
fprintf(dbg, "prev_enum: cur_choice is %d\n", cur_choice);
|
|
||||||
#endif
|
|
||||||
if (cur_choice == 0)
|
if (cur_choice == 0)
|
||||||
cur_choice = ta->num_choices - 1;
|
cur_choice = ta->num_choices - 1;
|
||||||
else
|
else
|
||||||
cur_choice--;
|
cur_choice--;
|
||||||
|
|
||||||
#ifdef DEBUG
|
_formi_dbg_printf("%s: cur_choice is %u on exit\n",
|
||||||
fprintf(dbg, "prev_enum: cur_choice is %d on exit\n", cur_choice);
|
__func__, cur_choice);
|
||||||
#endif
|
|
||||||
|
|
||||||
set_field_buffer(field, 0, ta->choices[cur_choice]);
|
set_field_buffer(field, 0, ta->choices[cur_choice]);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: type_ipv4.c,v 1.10 2007/01/17 23:24:22 hubertf Exp $ */
|
/* $NetBSD: type_ipv4.c,v 1.11 2016/03/09 19:47:13 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1998-1999 Brett Lymn
|
* Copyright (c) 1998-1999 Brett Lymn
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: type_ipv4.c,v 1.10 2007/01/17 23:24:22 hubertf Exp $");
|
__RCSID("$NetBSD: type_ipv4.c,v 1.11 2016/03/09 19:47:13 christos Exp $");
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -72,7 +72,7 @@ ipv4_check_field(FIELD *field, char *args)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(dbg, "ipv4_check_field: enter with args of %s\n", keeper);
|
_formi_dbg_printf("%s: enter with args of %s\n", __func__, keeper);
|
||||||
#endif
|
#endif
|
||||||
style = FORMI_DOTTED_QUAD;
|
style = FORMI_DOTTED_QUAD;
|
||||||
buf = keeper;
|
buf = keeper;
|
||||||
|
@ -168,8 +168,8 @@ ipv4_check_field(FIELD *field, char *args)
|
||||||
set_field_buffer(field, 1, buf1);
|
set_field_buffer(field, 1, buf1);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(dbg, "ipv4_check_field: buf0 set to %s\n", buf);
|
_formi_dbg_printf("%s: buf0 set to %s\n", __func__, buf);
|
||||||
fprintf(dbg, "ipv4_check_field: buf1 set to %s\n", buf1);
|
_formi_dbg_printf("%s: buf1 set to %s\n", __func__, buf1);
|
||||||
#endif
|
#endif
|
||||||
free(buf);
|
free(buf);
|
||||||
free(buf1);
|
free(buf1);
|
||||||
|
|
Loading…
Reference in New Issue