"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "buf.h" between
bmake-20201101.tar.gz and bmake-20201117.tar.gz

About: bmake a BSD make tool (derived from NetBSD’s make).

buf.h  (bmake-20201101):buf.h  (bmake-20201117)
/* $NetBSD: buf.h,v 1.34 2020/09/27 16:59:02 rillig Exp $ */ /* $NetBSD: buf.h,v 1.36 2020/11/10 00:32:12 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California. * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* *
* This code is derived from software contributed to Berkeley by * This code is derived from software contributed to Berkeley by
* Adam de Boor. * Adam de Boor.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
skipping to change at line 97 skipping to change at line 97
} Buffer; } Buffer;
/* If we aren't on NetBSD, __predict_false() might not be defined. */ /* If we aren't on NetBSD, __predict_false() might not be defined. */
#ifndef __predict_false #ifndef __predict_false
#define __predict_false(x) (x) #define __predict_false(x) (x)
#endif #endif
void Buf_Expand_1(Buffer *); void Buf_Expand_1(Buffer *);
/* Buf_AddByte adds a single byte to a buffer. */ /* Buf_AddByte adds a single byte to a buffer. */
static inline MAKE_ATTR_UNUSED void MAKE_INLINE void
Buf_AddByte(Buffer *buf, char byte) Buf_AddByte(Buffer *buf, char byte)
{ {
size_t old_len = buf->len++; size_t old_len = buf->len++;
char *end; char *end;
if (__predict_false(old_len + 1 >= buf->cap)) if (__predict_false(old_len + 1 >= buf->cap))
Buf_Expand_1(buf); Buf_Expand_1(buf);
end = buf->data + old_len; end = buf->data + old_len;
end[0] = byte; end[0] = byte;
end[1] = '\0'; end[1] = '\0';
} }
static inline MAKE_ATTR_UNUSED size_t MAKE_INLINE size_t
Buf_Len(const Buffer *buf) Buf_Len(const Buffer *buf)
{ {
return buf->len; return buf->len;
} }
static inline MAKE_ATTR_UNUSED Boolean MAKE_INLINE Boolean
Buf_EndsWith(const Buffer *buf, char ch) Buf_EndsWith(const Buffer *buf, char ch)
{ {
return buf->len > 0 && buf->data[buf->len - 1] == ch; return buf->len > 0 && buf->data[buf->len - 1] == ch;
} }
void Buf_AddBytes(Buffer *, const char *, size_t); void Buf_AddBytes(Buffer *, const char *, size_t);
void Buf_AddBytesBetween(Buffer *, const char *, const char *); void Buf_AddBytesBetween(Buffer *, const char *, const char *);
void Buf_AddStr(Buffer *, const char *); void Buf_AddStr(Buffer *, const char *);
void Buf_AddInt(Buffer *, int); void Buf_AddInt(Buffer *, int);
char *Buf_GetAll(Buffer *, size_t *); char *Buf_GetAll(Buffer *, size_t *);
void Buf_Empty(Buffer *); void Buf_Empty(Buffer *);
void Buf_Init(Buffer *, size_t); void Buf_Init(Buffer *);
void Buf_InitSize(Buffer *, size_t);
char *Buf_Destroy(Buffer *, Boolean); char *Buf_Destroy(Buffer *, Boolean);
char *Buf_DestroyCompact(Buffer *); char *Buf_DestroyCompact(Buffer *);
#endif /* MAKE_BUF_H */ #endif /* MAKE_BUF_H */
 End of changes. 5 change blocks. 
5 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)