mirror of https://github.com/tqfx/liba.git
rename old to cur
This commit is contained in:
parent
257cdd84a2
commit
c17d52500c
|
@ -69,9 +69,9 @@ if env.GetOption('install_sandbox'):
|
|||
target = target[0].get_relpath() + '/a.h'
|
||||
with open(source, "r") as f:
|
||||
text = f.read()
|
||||
old = "#if defined(A_HAVE_H)"
|
||||
new = '#include "a.scons.h"\n' + old
|
||||
text = text.replace(old, new)
|
||||
cur = "#if defined(A_HAVE_H)"
|
||||
new = '#include "a.scons.h"\n' + cur
|
||||
text = text.replace(cur, new)
|
||||
with open(target, "wb") as f:
|
||||
f.write(text.encode())
|
||||
env.AddPostAction(include, install_fixup)
|
||||
|
|
|
@ -437,7 +437,7 @@ A_INTERN void a_list_shift_(a_list *head1, a_list *tail1, a_list *head2, a_list
|
|||
|
||||
/*!
|
||||
@brief shift the node rhs to the node lhs
|
||||
@param[in,out] lhs the old node
|
||||
@param[in,out] lhs the current node
|
||||
@param[in,out] rhs the new node
|
||||
*/
|
||||
A_INTERN void a_list_shift_node(a_list *lhs, a_list *rhs)
|
||||
|
|
|
@ -10,11 +10,11 @@ if args[0].dst:
|
|||
with open(args[0].dst, "r") as f:
|
||||
text = f.read()
|
||||
|
||||
old = "#if defined(A_HAVE_H)"
|
||||
cur = "#if defined(A_HAVE_H)"
|
||||
dst = os.path.dirname(args[0].src)
|
||||
src = os.path.basename(args[0].src)
|
||||
new = '#include "{}"\n{}'.format(src, old)
|
||||
text = text.replace(old, new)
|
||||
new = '#include "{}"\n{}'.format(src, cur)
|
||||
text = text.replace(cur, new)
|
||||
|
||||
with open(os.path.join(dst, os.path.basename(args[0].dst)), "wb") as f:
|
||||
f.write(text.encode())
|
||||
|
|
|
@ -13,9 +13,9 @@ for source in glob(os.path.join("lua/src", "**.c"), recursive=True):
|
|||
new = "%08X" % value
|
||||
if item[0] != new:
|
||||
print("{} -> {} // {}".format(item[0], new, item[1]))
|
||||
old = "0x{}: // {}".format(item[0], item[1])
|
||||
cur = "0x{}: // {}".format(item[0], item[1])
|
||||
new = "0x{}: // {}".format(new, item[1])
|
||||
text = text.replace(old, new)
|
||||
text = text.replace(cur, new)
|
||||
if text != text_:
|
||||
with open(source, "wb") as f:
|
||||
f.write(text.encode("UTF-8"))
|
||||
|
|
|
@ -20,7 +20,7 @@ sources = sorted(sources)
|
|||
|
||||
with open("meson.build", "r") as f:
|
||||
meson = f.read()
|
||||
cur = re.findall(r"sources = ([^\]]+)", meson)[0] + "]\n"
|
||||
new = "[\n '" + "',\n '".join(sources) + "',\n]\n"
|
||||
old = re.findall(r"sources = ([^\]]+)", meson)[0] + "]\n"
|
||||
with open("meson.build", "wb") as f:
|
||||
meson = f.write(meson.replace(old, new).encode())
|
||||
meson = f.write(meson.replace(cur, new).encode())
|
||||
|
|
|
@ -52,13 +52,13 @@ class single(object):
|
|||
include_dirs = [os.path.dirname(name)] + self._include_dirs
|
||||
includes = re.findall(r"#include \"([^\"]+)\"", source)
|
||||
for include in includes:
|
||||
old = '#include "{}"\n'.format(include)
|
||||
cur = '#include "{}"\n'.format(include)
|
||||
for include_dir in include_dirs:
|
||||
new = os.path.join(include_dir, include)
|
||||
if not os.path.exists(new):
|
||||
continue
|
||||
new = self.__call__(new)
|
||||
source = source.replace(old, new)
|
||||
source = source.replace(cur, new)
|
||||
self._include_files.append(name)
|
||||
if name == self.name:
|
||||
for define_macro in self.define_macros:
|
||||
|
|
18
src/avl.c
18
src/avl.c
|
@ -1,11 +1,11 @@
|
|||
#include "a/avl.h"
|
||||
|
||||
/* Replaces the child of the specified AVL tree node. */
|
||||
static A_INLINE void a_avl_new_child(a_avl *root, a_avl_node *parent, a_avl_node *oldnode, a_avl_node *newnode)
|
||||
static A_INLINE void a_avl_new_child(a_avl *root, a_avl_node *parent, a_avl_node *node, a_avl_node *newnode)
|
||||
{
|
||||
if (parent)
|
||||
{
|
||||
if (parent->left == oldnode)
|
||||
if (parent->left == node)
|
||||
{
|
||||
parent->left = newnode;
|
||||
}
|
||||
|
@ -203,15 +203,15 @@ Indeed, a single node insertion cannot require that more than one (single or dou
|
|||
*/
|
||||
static A_INLINE a_bool a_avl_handle_growth(a_avl *root, a_avl_node *parent, a_avl_node *node, int sign)
|
||||
{
|
||||
int const old_factor = a_avl_factor(parent);
|
||||
if (old_factor == 0)
|
||||
int const cur_factor = a_avl_factor(parent);
|
||||
if (cur_factor == 0)
|
||||
{
|
||||
/* $parent is still sufficiently balanced (-1 or +1 balance factor), but must have increased in height. Continue up the tree. */
|
||||
a_avl_set_factor(parent, sign);
|
||||
return A_FALSE;
|
||||
}
|
||||
|
||||
int const new_factor = old_factor + sign;
|
||||
int const new_factor = cur_factor + sign;
|
||||
if (new_factor == 0)
|
||||
{
|
||||
/* $parent is now perfectly balanced (0 balance factor). It cannot have increased in height, so there is nothing more to do. */
|
||||
|
@ -372,8 +372,8 @@ Also in the latter case, *left will be set.
|
|||
*/
|
||||
static A_INLINE a_avl_node *a_avl_handle_shrink(a_avl *root, a_avl_node *parent, int sign, a_bool *left)
|
||||
{
|
||||
int const old_factor = a_avl_factor(parent);
|
||||
if (old_factor == 0)
|
||||
int const cur_factor = a_avl_factor(parent);
|
||||
if (cur_factor == 0)
|
||||
{
|
||||
/*
|
||||
Prior to the deletion, the subtree rooted at $parent was perfectly balanced.
|
||||
|
@ -384,7 +384,7 @@ static A_INLINE a_avl_node *a_avl_handle_shrink(a_avl *root, a_avl_node *parent,
|
|||
}
|
||||
|
||||
a_avl_node *node;
|
||||
int const new_factor = old_factor + sign;
|
||||
int const new_factor = cur_factor + sign;
|
||||
if (new_factor == 0)
|
||||
{
|
||||
/*
|
||||
|
@ -439,7 +439,7 @@ static A_INLINE a_avl_node *a_avl_handle_shrink(a_avl *root, a_avl_node *parent,
|
|||
balance(B) = +1
|
||||
|
||||
A: -2 => -1 (sign < 0) or +2 => +1 (sign > 0)
|
||||
No change needed --- that's the same as old_factor.
|
||||
No change needed --- that's the same as cur_factor.
|
||||
|
||||
B: 0 => +1 (sign < 0) or 0 => -1 (sign > 0)
|
||||
*/
|
||||
|
|
22
src/rbt.c
22
src/rbt.c
|
@ -20,11 +20,11 @@ red-black trees properties: https://en.wikipedia.org/wiki/Rbtree
|
|||
*/
|
||||
|
||||
/* Replaces the child of the specified red–black tree node. */
|
||||
static A_INLINE void a_rbt_new_child(a_rbt *root, a_rbt_node *parent, a_rbt_node *oldnode, a_rbt_node *newnode)
|
||||
static A_INLINE void a_rbt_new_child(a_rbt *root, a_rbt_node *parent, a_rbt_node *node, a_rbt_node *newnode)
|
||||
{
|
||||
if (parent)
|
||||
{
|
||||
if (parent->left == oldnode)
|
||||
if (parent->left == node)
|
||||
{
|
||||
parent->left = newnode;
|
||||
}
|
||||
|
@ -82,20 +82,20 @@ static A_INLINE void a_rbt_set_black(a_rbt_node *node)
|
|||
|
||||
/*
|
||||
Helper function for rotations:
|
||||
- old's parent and color get assigned to new
|
||||
- old gets assigned new as a parent and 'color' as a color.
|
||||
- node's parent and color get assigned to new
|
||||
- node gets assigned new as a parent and 'color' as a color.
|
||||
*/
|
||||
static A_INLINE void a_rbt_set_parents(a_rbt *root, a_rbt_node *oldnode, a_rbt_node *newnode, unsigned int color)
|
||||
static A_INLINE void a_rbt_set_parents(a_rbt *root, a_rbt_node *node, a_rbt_node *newnode, unsigned int color)
|
||||
{
|
||||
a_rbt_node *const parent = a_rbt_parent(oldnode);
|
||||
a_rbt_node *const parent = a_rbt_parent(node);
|
||||
#if defined(A_SIZE_POINTER) && (A_SIZE_POINTER + 0 > 1)
|
||||
newnode->_parent = oldnode->_parent;
|
||||
newnode->_parent = node->_parent;
|
||||
#else /* !A_SIZE_POINTER */
|
||||
newnode->parent = oldnode->parent;
|
||||
newnode->color = oldnode->color;
|
||||
newnode->parent = node->parent;
|
||||
newnode->color = node->color;
|
||||
#endif /* A_SIZE_POINTER */
|
||||
a_rbt_set_parent_color(oldnode, newnode, color);
|
||||
a_rbt_new_child(root, parent, oldnode, newnode);
|
||||
a_rbt_set_parent_color(node, newnode, color);
|
||||
a_rbt_new_child(root, parent, node, newnode);
|
||||
}
|
||||
|
||||
void a_rbt_insert_adjust(a_rbt *root, a_rbt_node *node)
|
||||
|
|
|
@ -175,10 +175,10 @@ on_load(function(target)
|
|||
end)
|
||||
after_install(function(target)
|
||||
if target:installdir() then
|
||||
local old = "#if defined(A_HAVE_H)"
|
||||
local new = '#include "a.xmake.h"\n' .. old
|
||||
local cur = "#if defined(A_HAVE_H)"
|
||||
local new = '#include "a.xmake.h"\n' .. cur
|
||||
local includedir = path.join(target:installdir(), "include")
|
||||
io.replace(path.join(includedir, "a", "a.h"), old, new, { plain = true })
|
||||
io.replace(path.join(includedir, "a", "a.h"), cur, new, { plain = true })
|
||||
end
|
||||
end)
|
||||
-- add the dependent target
|
||||
|
|
Loading…
Reference in New Issue