Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): remove type information from local var...
details: https://anonhg.NetBSD.org/src/rev/63d3fc48be73
branches: trunk
changeset: 975089:63d3fc48be73
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Aug 21 07:00:32 2020 +0000
description:
make(1): remove type information from local variables in list library
Every node in this file is of type LstNode, which makes the 'l' in the
name 'ln' redundant. The name 'ln' is quite close to the name 'l',
which in turn can easily be confused with the digit '1'. Therefore,
rename 'l' to 'list' and 'ln' to 'node'.
diffstat:
usr.bin/make/lst.c | 383 +++++++++++++++++++++++++---------------------------
usr.bin/make/lst.h | 4 +-
2 files changed, 184 insertions(+), 203 deletions(-)
diffs (truncated from 805 to 300 lines):
diff -r 4e142ca212d7 -r 63d3fc48be73 usr.bin/make/lst.c
--- a/usr.bin/make/lst.c Fri Aug 21 06:38:29 2020 +0000
+++ b/usr.bin/make/lst.c Fri Aug 21 07:00:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.15 2020/08/21 06:38:29 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.16 2020/08/21 07:00:32 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -38,11 +38,11 @@
#include "make_malloc.h"
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.15 2020/08/21 06:38:29 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.16 2020/08/21 07:00:32 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.15 2020/08/21 06:38:29 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.16 2020/08/21 07:00:32 rillig Exp $");
#endif /* not lint */
#endif
@@ -76,49 +76,49 @@
/* Return TRUE if the list is valid. */
static Boolean
-LstValid(Lst l)
+LstValid(Lst list)
{
- return l != NULL;
+ return list != NULL;
}
/* Return TRUE if the list node is valid. */
static Boolean
-LstNodeValid(LstNode ln)
+LstNodeValid(LstNode node)
{
- return ln != NULL;
+ return node != NULL;
}
static LstNode
LstNodeNew(void *datum)
{
- LstNode ln = bmake_malloc(sizeof *ln);
+ LstNode node = bmake_malloc(sizeof *node);
/* prev will be initialized by the calling code. */
/* next will be initialized by the calling code. */
- ln->useCount = 0;
- ln->deleted = FALSE;
- ln->datum = datum;
- return ln;
+ node->useCount = 0;
+ node->deleted = FALSE;
+ node->datum = datum;
+ return node;
}
/* Return TRUE if the list is empty. */
static Boolean
-LstIsEmpty(Lst l)
+LstIsEmpty(Lst list)
{
- return l->first == NULL;
+ return list->first == NULL;
}
/* Create and initialize a new, empty list. */
Lst
Lst_Init(void)
{
- Lst nList = bmake_malloc(sizeof *nList);
+ Lst list = bmake_malloc(sizeof *list);
- nList->first = NULL;
- nList->last = NULL;
- nList->isOpen = FALSE;
- nList->lastAccess = Unknown;
+ list->first = NULL;
+ list->last = NULL;
+ list->isOpen = FALSE;
+ list->lastAccess = Unknown;
- return nList;
+ return list;
}
/* Duplicate an entire list, usually by copying the datum pointers.
@@ -126,35 +126,34 @@
* old datum, usually by creating a copy of it.
* Return the new list, or NULL on failure. */
Lst
-Lst_Duplicate(Lst l, DuplicateProc *copyProc)
+Lst_Duplicate(Lst list, DuplicateProc *copyProc)
{
- Lst nl;
- LstNode ln;
- Lst list = l;
+ Lst newList;
+ LstNode node;
- if (!LstValid(l)) {
+ if (!LstValid(list)) {
return NULL;
}
- nl = Lst_Init();
- if (nl == NULL) {
+ newList = Lst_Init();
+ if (newList == NULL) {
return NULL;
}
- ln = list->first;
- while (ln != NULL) {
+ node = list->first;
+ while (node != NULL) {
if (copyProc != NULL) {
- if (Lst_AtEnd(nl, copyProc(ln->datum)) == FAILURE) {
+ if (Lst_AtEnd(newList, copyProc(node->datum)) == FAILURE) {
return NULL;
}
- } else if (Lst_AtEnd(nl, ln->datum) == FAILURE) {
+ } else if (Lst_AtEnd(newList, node->datum) == FAILURE) {
return NULL;
}
- ln = ln->next;
+ node = node->next;
}
- return nl;
+ return newList;
}
/* Destroy a list and free all its resources. If the freeProc is given, it is
@@ -162,8 +161,8 @@
void
Lst_Destroy(Lst list, FreeProc *freeProc)
{
- LstNode ln;
- LstNode tln = NULL;
+ LstNode node;
+ LstNode next = NULL;
if (list == NULL)
return;
@@ -177,15 +176,15 @@
}
if (freeProc) {
- for (ln = list->first; ln != NULL; ln = tln) {
- tln = ln->next;
- freeProc(ln->datum);
- free(ln);
+ for (node = list->first; node != NULL; node = next) {
+ next = node->next;
+ freeProc(node->datum);
+ free(node);
}
} else {
- for (ln = list->first; ln != NULL; ln = tln) {
- tln = ln->next;
- free(ln);
+ for (node = list->first; node != NULL; node = next) {
+ next = node->next;
+ free(node);
}
}
@@ -199,40 +198,37 @@
/* Insert a new node with the given piece of data before the given node in the
* given list. */
ReturnStatus
-Lst_InsertBefore(Lst l, LstNode ln, void *d)
+Lst_InsertBefore(Lst list, LstNode node, void *datum)
{
- LstNode nLNode; /* new lnode for d */
- LstNode lNode = ln;
- Lst list = l;
-
+ LstNode newNode;
/*
* check validity of arguments
*/
- if (LstValid(l) && (LstIsEmpty(l) && ln == NULL))
+ if (LstValid(list) && (LstIsEmpty(list) && node == NULL))
goto ok;
- if (!LstValid(l) || LstIsEmpty(l) || !LstNodeValid(ln)) {
+ if (!LstValid(list) || LstIsEmpty(list) || !LstNodeValid(node)) {
return FAILURE;
}
ok:
- nLNode = LstNodeNew(d);
+ newNode = LstNodeNew(datum);
- if (ln == NULL) {
- nLNode->prev = nLNode->next = NULL;
- list->first = list->last = nLNode;
+ if (node == NULL) {
+ newNode->prev = newNode->next = NULL;
+ list->first = list->last = newNode;
} else {
- nLNode->prev = lNode->prev;
- nLNode->next = lNode;
+ newNode->prev = node->prev;
+ newNode->next = node;
- if (nLNode->prev != NULL) {
- nLNode->prev->next = nLNode;
+ if (newNode->prev != NULL) {
+ newNode->prev->next = newNode;
}
- lNode->prev = nLNode;
+ node->prev = newNode;
- if (lNode == list->first) {
- list->first = nLNode;
+ if (node == list->first) {
+ list->first = newNode;
}
}
@@ -242,39 +238,34 @@
/* Insert a new node with the given piece of data after the given node in the
* given list. */
ReturnStatus
-Lst_InsertAfter(Lst l, LstNode ln, void *d)
+Lst_InsertAfter(Lst list, LstNode node, void *datum)
{
- Lst list;
- LstNode lNode;
LstNode nLNode;
- if (LstValid(l) && (ln == NULL && LstIsEmpty(l))) {
+ if (LstValid(list) && (node == NULL && LstIsEmpty(list))) {
goto ok;
}
- if (!LstValid(l) || LstIsEmpty(l) || !LstNodeValid(ln)) {
+ if (!LstValid(list) || LstIsEmpty(list) || !LstNodeValid(node)) {
return FAILURE;
}
ok:
- list = l;
- lNode = ln;
+ nLNode = LstNodeNew(datum);
- nLNode = LstNodeNew(d);
-
- if (lNode == NULL) {
+ if (node == NULL) {
nLNode->next = nLNode->prev = NULL;
list->first = list->last = nLNode;
} else {
- nLNode->prev = lNode;
- nLNode->next = lNode->next;
+ nLNode->prev = node;
+ nLNode->next = node->next;
- lNode->next = nLNode;
+ node->next = nLNode;
if (nLNode->next != NULL) {
nLNode->next->prev = nLNode;
}
- if (lNode == list->last) {
+ if (node == list->last) {
list->last = nLNode;
}
}
@@ -284,54 +275,47 @@
/* Add a piece of data at the front of the given list. */
ReturnStatus
-Lst_AtFront(Lst l, void *d)
+Lst_AtFront(Lst list, void *datum)
{
- LstNode front;
-
- front = Lst_First(l);
- return Lst_InsertBefore(l, front, d);
+ LstNode front = Lst_First(list);
+ return Lst_InsertBefore(list, front, datum);
}
/* Add a piece of data at the end of the given list. */
ReturnStatus
-Lst_AtEnd(Lst l, void *d)
+Lst_AtEnd(Lst list, void *datum)
{
- LstNode end;
-
- end = Lst_Last(l);
Home |
Main Index |
Thread Index |
Old Index