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 alias Byte = char
details: https://anonhg.NetBSD.org/src/rev/200fda43bf8d
branches: trunk
changeset: 974833:200fda43bf8d
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Aug 13 04:12:13 2020 +0000
description:
make(1): remove type alias Byte = char
This alias was only actually used in very few places, and changing it to
unsigned char or any other type would not be possible without generating
lots of compile-time errors. Therefore there was no abstraction, only
unnecessary complexity.
diffstat:
usr.bin/make/buf.c | 20 ++++++++++----------
usr.bin/make/buf.h | 20 +++++++++-----------
usr.bin/make/var.c | 14 +++++++-------
3 files changed, 26 insertions(+), 28 deletions(-)
diffs (200 lines):
diff -r 0ad7979c10c0 -r 200fda43bf8d usr.bin/make/buf.c
--- a/usr.bin/make/buf.c Thu Aug 13 03:54:57 2020 +0000
+++ b/usr.bin/make/buf.c Thu Aug 13 04:12:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.c,v 1.34 2020/08/09 19:51:02 rillig Exp $ */
+/* $NetBSD: buf.c,v 1.35 2020/08/13 04:12:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: buf.c,v 1.34 2020/08/09 19:51:02 rillig Exp $";
+static char rcsid[] = "$NetBSD: buf.c,v 1.35 2020/08/13 04:12:13 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: buf.c,v 1.34 2020/08/09 19:51:02 rillig Exp $");
+__RCSID("$NetBSD: buf.c,v 1.35 2020/08/13 04:12:13 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -104,10 +104,10 @@
/* Add the given bytes to the buffer. */
void
-Buf_AddBytes(Buffer *bp, const Byte *bytesPtr, size_t numBytes)
+Buf_AddBytes(Buffer *bp, const char *bytesPtr, size_t numBytes)
{
size_t count = bp->count;
- Byte *ptr;
+ char *ptr;
if (__predict_false(count + numBytes >= bp->size)) {
bp->size += max(bp->size, numBytes + 16);
@@ -159,7 +159,7 @@
*
* Returns the pointer to the data and optionally the length of the
* data in the buffer. */
-Byte *
+char *
Buf_GetAll(Buffer *bp, size_t *numBytesPtr)
{
if (numBytesPtr != NULL)
@@ -192,10 +192,10 @@
/* Reset the buffer.
* If freeData is TRUE, the data from the buffer is freed as well.
* Otherwise it is kept and returned. */
-Byte *
+char *
Buf_Destroy(Buffer *buf, Boolean freeData)
{
- Byte *data = buf->buffer;
+ char *data = buf->buffer;
if (freeData) {
free(data);
data = NULL;
@@ -216,13 +216,13 @@
*
* If the buffer size is much greater than its content,
* a new buffer will be allocated and the old one freed. */
-Byte *
+char *
Buf_DestroyCompact(Buffer *buf)
{
#if BUF_COMPACT_LIMIT > 0
if (buf->size - buf->count >= BUF_COMPACT_LIMIT) {
/* We trust realloc to be smart */
- Byte *data = bmake_realloc(buf->buffer, buf->count + 1);
+ char *data = bmake_realloc(buf->buffer, buf->count + 1);
data[buf->count] = 0;
Buf_Destroy(buf, FALSE);
return data;
diff -r 0ad7979c10c0 -r 200fda43bf8d usr.bin/make/buf.h
--- a/usr.bin/make/buf.h Thu Aug 13 03:54:57 2020 +0000
+++ b/usr.bin/make/buf.h Thu Aug 13 04:12:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.h,v 1.23 2020/08/08 18:54:04 rillig Exp $ */
+/* $NetBSD: buf.h,v 1.24 2020/08/13 04:12:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@
/*-
* buf.h --
- * Header for users of the buf library.
+ * Automatically growing null-terminated buffer of characters.
*/
#ifndef MAKE_BUF_H
@@ -82,12 +82,10 @@
#include <stddef.h>
-typedef char Byte;
-
typedef struct Buffer {
size_t size; /* Current size of the buffer */
size_t count; /* Number of bytes in buffer */
- Byte *buffer; /* The buffer itself (zero terminated) */
+ char *buffer; /* The buffer itself (zero terminated) */
} Buffer;
/* If we aren't on NetBSD, __predict_false() might not be defined. */
@@ -98,7 +96,7 @@
/* Buf_AddByte adds a single byte to a buffer. */
#define Buf_AddByte(bp, byte) do { \
size_t _count = ++(bp)->count; \
- Byte *_ptr; \
+ char *_ptr; \
if (__predict_false(_count >= (bp)->size)) \
Buf_Expand_1(bp); \
_ptr = (bp)->buffer + _count; \
@@ -111,14 +109,14 @@
#define Buf_Size(bp) ((bp)->count)
void Buf_Expand_1(Buffer *);
-void Buf_AddBytes(Buffer *, const Byte *, size_t);
-void Buf_AddBytesBetween(Buffer *, const Byte *, const Byte *);
+void Buf_AddBytes(Buffer *, const char *, size_t);
+void Buf_AddBytesBetween(Buffer *, const char *, const char *);
void Buf_AddStr(Buffer *, const char *);
void Buf_AddInt(Buffer *, int);
-Byte *Buf_GetAll(Buffer *, size_t *);
+char *Buf_GetAll(Buffer *, size_t *);
void Buf_Empty(Buffer *);
void Buf_Init(Buffer *, size_t);
-Byte *Buf_Destroy(Buffer *, Boolean);
-Byte *Buf_DestroyCompact(Buffer *);
+char *Buf_Destroy(Buffer *, Boolean);
+char *Buf_DestroyCompact(Buffer *);
#endif /* MAKE_BUF_H */
diff -r 0ad7979c10c0 -r 200fda43bf8d usr.bin/make/var.c
--- a/usr.bin/make/var.c Thu Aug 13 03:54:57 2020 +0000
+++ b/usr.bin/make/var.c Thu Aug 13 04:12:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.448 2020/08/12 19:14:38 rillig Exp $ */
+/* $NetBSD: var.c,v 1.449 2020/08/13 04:12:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.448 2020/08/12 19:14:38 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.449 2020/08/13 04:12:13 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.448 2020/08/12 19:14:38 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.449 2020/08/13 04:12:13 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1474,7 +1474,7 @@
* to scan the list backwards if first > last.
*/
static char *
-VarSelectWords(Byte sep, Boolean oneBigWord, const char *str, int first,
+VarSelectWords(char sep, Boolean oneBigWord, const char *str, int first,
int last)
{
char **av; /* word list */
@@ -1561,7 +1561,7 @@
*-----------------------------------------------------------------------
*/
static char *
-ModifyWords(GNode *ctx, Byte sep, Boolean oneBigWord,
+ModifyWords(GNode *ctx, char sep, Boolean oneBigWord,
const char *str, ModifyWordsCallback modifyWord, void *data)
{
SepBuf result;
@@ -1927,7 +1927,7 @@
* to the expression */
char missing_delim; /* For error reporting */
- Byte sep; /* Word separator in expansions
+ char sep; /* Word separator in expansions
* (see the :ts modifier) */
Boolean oneBigWord; /* TRUE if the variable value is treated as a
* single big word, even if it contains
@@ -2487,7 +2487,7 @@
get_numeric:
{
char *end;
- st->sep = (Byte)strtoul(xp, &end, base);
+ st->sep = (char)strtoul(xp, &end, base);
if (*end != ':' && *end != st->endc)
return AMR_BAD;
*pp = end;
Home |
Main Index |
Thread Index |
Old Index