Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libform goodbye CIRCLEQ, welcome TAILQ
details: https://anonhg.NetBSD.org/src/rev/739b35847a18
branches: trunk
changeset: 791615:739b35847a18
user: christos <christos%NetBSD.org@localhost>
date: Tue Nov 26 01:17:00 2013 +0000
description:
goodbye CIRCLEQ, welcome TAILQ
diffstat:
lib/libform/driver.c | 9 +++--
lib/libform/form.h | 6 ++--
lib/libform/internals.c | 72 ++++++++++++++++++++++++------------------------
3 files changed, 44 insertions(+), 43 deletions(-)
diffs (259 lines):
diff -r b8d2a9ccbbea -r 739b35847a18 lib/libform/driver.c
--- a/lib/libform/driver.c Mon Nov 25 23:53:44 2013 +0000
+++ b/lib/libform/driver.c Tue Nov 26 01:17:00 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: driver.c,v 1.17 2010/02/03 15:34:43 roy Exp $ */
+/* $NetBSD: driver.c,v 1.18 2013/11/26 01:17:00 christos Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: driver.c,v 1.17 2010/02/03 15:34:43 roy Exp $");
+__RCSID("$NetBSD: driver.c,v 1.18 2013/11/26 01:17:00 christos Exp $");
#include <ctype.h>
#include "form.h"
@@ -284,13 +284,14 @@
break;
case REQ_SFIRST_FIELD:
- fieldp = CIRCLEQ_FIRST(&form->sorted_fields);
+ fieldp = TAILQ_FIRST(&form->sorted_fields);
form->cur_field = fieldp->index;
update_field = 1;
break;
case REQ_SLAST_FIELD:
- fieldp = CIRCLEQ_LAST(&form->sorted_fields);
+ fieldp = TAILQ_LAST(&form->sorted_fields,
+ _formi_sort_head);
form->cur_field = fieldp->index;
update_field = 1;
break;
diff -r b8d2a9ccbbea -r 739b35847a18 lib/libform/form.h
--- a/lib/libform/form.h Mon Nov 25 23:53:44 2013 +0000
+++ b/lib/libform/form.h Tue Nov 26 01:17:00 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: form.h,v 1.21 2011/11/28 12:44:18 joerg Exp $ */
+/* $NetBSD: form.h,v 1.22 2013/11/26 01:17:00 christos Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
@@ -231,7 +231,7 @@
void *userptr; /* user defined pointer. */
FIELD *link; /* used if fields are linked */
FIELDTYPE *type; /* type struct for the field */
- CIRCLEQ_ENTRY(_form_field) glue; /* circle queue glue for sorting fields */
+ TAILQ_ENTRY(_form_field) glue; /* tail queue glue for sorting fields */
char *args; /* args for field type. */
_FORMI_FIELD_LINES *alines; /* array of the starts and ends of lines */
_FORMI_FIELD_LINES *free; /* list of lines available for reuse */
@@ -291,7 +291,7 @@
int max_page; /* number of pages in the form */
_FORMI_PAGE_START *page_starts; /* dynamic array of fields that start
the pages */
- CIRCLEQ_HEAD(_formi_sort_head, _form_field) sorted_fields; /* sorted field
+ TAILQ_HEAD(_formi_sort_head, _form_field) sorted_fields; /* sorted field
list */
FIELD **fields; /* array of fields attached to this form. */
};
diff -r b8d2a9ccbbea -r 739b35847a18 lib/libform/internals.c
--- a/lib/libform/internals.c Mon Nov 25 23:53:44 2013 +0000
+++ b/lib/libform/internals.c Tue Nov 26 01:17:00 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: internals.c,v 1.36 2013/01/19 16:11:03 mbalmer Exp $ */
+/* $NetBSD: internals.c,v 1.37 2013/11/26 01:17:00 christos Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: internals.c,v 1.36 2013/01/19 16:11:03 mbalmer Exp $");
+__RCSID("$NetBSD: internals.c,v 1.37 2013/11/26 01:17:00 christos Exp $");
#include <limits.h>
#include <ctype.h>
@@ -390,8 +390,8 @@
cur = form->fields[form->page_starts[form->page].first];
while ((cur->opts & (O_VISIBLE | O_ACTIVE))
!= (O_VISIBLE | O_ACTIVE)) {
- cur = CIRCLEQ_NEXT(cur, glue);
- if (cur == (void *) &form->sorted_fields) {
+ cur = TAILQ_NEXT(cur, glue);
+ if (cur == NULL) {
form->page = old_page;
return E_REQUEST_DENIED;
}
@@ -420,9 +420,10 @@
if (direction == _FORMI_FORWARD) {
if (use_sorted == TRUE) {
if ((form->wrap == FALSE) &&
- (cur == CIRCLEQ_LAST(&form->sorted_fields)))
+ (cur == TAILQ_LAST(&form->sorted_fields,
+ _formi_sort_head)))
return E_REQUEST_DENIED;
- cur = CIRCLEQ_NEXT(cur, glue);
+ cur = TAILQ_NEXT(cur, glue);
i = cur->index;
} else {
if ((form->wrap == FALSE) &&
@@ -435,9 +436,9 @@
} else {
if (use_sorted == TRUE) {
if ((form->wrap == FALSE) &&
- (cur == CIRCLEQ_FIRST(&form->sorted_fields)))
+ (cur == TAILQ_FIRST(&form->sorted_fields)))
return E_REQUEST_DENIED;
- cur = CIRCLEQ_PREV(cur, glue);
+ cur = TAILQ_PREV(cur, _formi_sort_head, glue);
i = cur->index;
} else {
if ((form->wrap == FALSE) && (i <= 0))
@@ -3242,9 +3243,9 @@
FIELD **sort_area;
int i;
- CIRCLEQ_INIT(&form->sorted_fields);
-
- if ((sort_area = (FIELD **) malloc(sizeof(FIELD *) * form->field_count))
+ TAILQ_INIT(&form->sorted_fields);
+
+ if ((sort_area = malloc(sizeof(*sort_area) * form->field_count))
== NULL)
return;
@@ -3254,7 +3255,7 @@
field_sort_compare);
for (i = 0; i < form->field_count; i++)
- CIRCLEQ_INSERT_TAIL(&form->sorted_fields, sort_area[i], glue);
+ TAILQ_INSERT_TAIL(&form->sorted_fields, sort_area[i], glue);
free(sort_area);
}
@@ -3272,7 +3273,7 @@
* check if the sorted fields circle queue is empty, just
* return if it is.
*/
- if (CIRCLEQ_EMPTY(&form->sorted_fields))
+ if (TAILQ_EMPTY(&form->sorted_fields))
return;
/* initially nothing is above..... */
@@ -3281,41 +3282,41 @@
above = NULL;
/* set up the first field as the current... */
- cur = CIRCLEQ_FIRST(&form->sorted_fields);
+ cur = TAILQ_FIRST(&form->sorted_fields);
cur_row = cur->form_row;
/* find the first field on the next row if any */
- below = CIRCLEQ_NEXT(cur, glue);
+ below = TAILQ_NEXT(cur, glue);
below_row = -1;
end_below = TRUE;
real_end = TRUE;
- while (below != (void *)&form->sorted_fields) {
+ while (below != NULL) {
if (below->form_row != cur_row) {
below_row = below->form_row;
end_below = FALSE;
real_end = FALSE;
break;
}
- below = CIRCLEQ_NEXT(below, glue);
+ below = TAILQ_NEXT(below, glue);
}
/* walk the sorted fields, setting the neighbour pointers */
- while (cur != (void *) &form->sorted_fields) {
- if (cur == CIRCLEQ_FIRST(&form->sorted_fields))
+ while (cur != NULL) {
+ if (cur == TAILQ_FIRST(&form->sorted_fields))
cur->left = NULL;
else
- cur->left = CIRCLEQ_PREV(cur, glue);
-
- if (cur == CIRCLEQ_LAST(&form->sorted_fields))
+ cur->left = TAILQ_PREV(cur, _formi_sort_head, glue);
+
+ if (cur == TAILQ_LAST(&form->sorted_fields, _formi_sort_head))
cur->right = NULL;
else
- cur->right = CIRCLEQ_NEXT(cur, glue);
+ cur->right = TAILQ_NEXT(cur, glue);
if (end_above == TRUE)
cur->up = NULL;
else {
cur->up = above;
- above = CIRCLEQ_NEXT(above, glue);
+ above = TAILQ_NEXT(above, glue);
if (above_row != above->form_row) {
end_above = TRUE;
above_row = above->form_row;
@@ -3326,8 +3327,8 @@
cur->down = NULL;
else {
cur->down = below;
- below = CIRCLEQ_NEXT(below, glue);
- if (below == (void *) &form->sorted_fields) {
+ below = TAILQ_NEXT(below, glue);
+ if (below == NULL) {
end_below = TRUE;
real_end = TRUE;
} else if (below_row != below->form_row) {
@@ -3336,20 +3337,21 @@
}
}
- cur = CIRCLEQ_NEXT(cur, glue);
- if ((cur != (void *) &form->sorted_fields)
+ cur = TAILQ_NEXT(cur, glue);
+ if ((cur != NULL)
&& (cur_row != cur->form_row)) {
cur_row = cur->form_row;
if (end_above == FALSE) {
- for (; above != CIRCLEQ_FIRST(&form->sorted_fields);
- above = CIRCLEQ_NEXT(above, glue)) {
+ for (; above !=
+ TAILQ_FIRST(&form->sorted_fields);
+ above = TAILQ_NEXT(above, glue)) {
if (above->form_row != above_row) {
above_row = above->form_row;
break;
}
}
} else if (above == NULL) {
- above = CIRCLEQ_FIRST(&form->sorted_fields);
+ above = TAILQ_FIRST(&form->sorted_fields);
end_above = FALSE;
above_row = above->form_row;
} else
@@ -3357,17 +3359,15 @@
if (end_below == FALSE) {
while (below_row == below->form_row) {
- below = CIRCLEQ_NEXT(below,
- glue);
- if (below ==
- (void *)&form->sorted_fields) {
+ below = TAILQ_NEXT(below, glue);
+ if (below == NULL) {
real_end = TRUE;
end_below = TRUE;
break;
}
}
- if (below != (void *)&form->sorted_fields)
+ if (below != NULL)
below_row = below->form_row;
} else if (real_end == FALSE)
end_below = FALSE;
Home |
Main Index |
Thread Index |
Old Index