Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
f597ea48
Commit
f597ea48
authored
10 years ago
by
Martin Nilsson
Browse files
Options
Downloads
Patches
Plain Diff
A bit more modernization.
parent
d74030b4
Loading
Loading
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Yabu.pmod/module.pmod
+18
-17
18 additions, 17 deletions
lib/modules/Yabu.pmod/module.pmod
with
18 additions
and
17 deletions
lib/modules/Yabu.pmod/module.pmod
+
18
−
17
View file @
f597ea48
...
@@ -79,7 +79,7 @@ protected private class ProcessLock {
...
@@ -79,7 +79,7 @@ protected private class ProcessLock {
}
}
if(!file_stat(combine_path(lock_file, "../")))
if(!file_stat(combine_path(lock_file, "../")))
ERR("The database does not exist (use the
`c'
flag).");
ERR("The database does not exist (use the
\"c\"
flag).");
/* Failed to obtain lock, now trying some obscure techniques... */
/* Failed to obtain lock, now trying some obscure techniques... */
int pid = get_locked_pid();
int pid = get_locked_pid();
...
@@ -208,7 +208,7 @@ class Chunk {
...
@@ -208,7 +208,7 @@ class Chunk {
{
{
string s = sprintf("%08x", x);
string s = sprintf("%08x", x);
if(sizeof(s) != 8)
if(sizeof(s) != 8)
ERR("Encoded number way too large (
"+s+")"
);
ERR("Encoded number way too large (
%O)", s
);
return s;
return s;
}
}
...
@@ -377,7 +377,7 @@ class Chunk {
...
@@ -377,7 +377,7 @@ class Chunk {
if(attributes)
if(attributes)
return 0;
return 0;
else
else
ERR("Unknown key
'
%O
'
, keys: %O", key, keys);
ERR("Unknown key %O, keys: %O", key, keys);
}
}
int offset, type;
int offset, type;
...
@@ -403,7 +403,7 @@ class Chunk {
...
@@ -403,7 +403,7 @@ class Chunk {
if(!write)
if(!write)
ERR("Cannot free in read mode");
ERR("Cannot free in read mode");
if(zero_type(keys[key]))
if(zero_type(keys[key]))
ERR("Unknown key
'
%O
'
", key);
ERR("Unknown key %O", key);
int offset, type;
int offset, type;
DECODE_KEY(key, offset, type);
DECODE_KEY(key, offset, type);
...
@@ -421,7 +421,7 @@ class Chunk {
...
@@ -421,7 +421,7 @@ class Chunk {
mapping m_keys = copy_value(keys);
mapping m_keys = copy_value(keys);
foreach(almost_free||({}), string key) {
foreach(almost_free||({}), string key) {
if(zero_type(keys[key]))
if(zero_type(keys[key]))
ERR("Unknown state key
'
%O
'
", key);
ERR("Unknown state key %O", key);
int offset, type;
int offset, type;
DECODE_KEY(key, offset, type);
DECODE_KEY(key, offset, type);
...
@@ -473,9 +473,9 @@ class Chunk {
...
@@ -473,9 +473,9 @@ class Chunk {
this_program::parent = parent;
this_program::parent = parent;
start_time = encode_num(time());
start_time = encode_num(time());
if(
search
(mode, "C")
+1
)
if(
has_value
(mode, "C"))
compress = 1;
compress = 1;
if(
search
(mode, "w")
+1
) {
if(
has_value
(mode, "w")) {
write = 1;
write = 1;
file::create(filename, "cwr");
file::create(filename, "cwr");
} else
} else
...
@@ -723,7 +723,7 @@ class Table {
...
@@ -723,7 +723,7 @@ class Table {
{
{
LOCK();
LOCK();
if(!write) ERR("Cannot delete in read mode");
if(!write) ERR("Cannot delete in read mode");
if(!handles[handle]) ERR("Unknown handle
'
%O
'
", handle);
if(!handles[handle]) ERR("Unknown handle %O", handle);
m_delete(handles, handle);
m_delete(handles, handle);
if(changes)
if(changes)
...
@@ -1166,7 +1166,7 @@ class db {
...
@@ -1166,7 +1166,7 @@ class db {
{
{
LOCK();
LOCK();
if(!tables[handle])
if(!tables[handle])
tables[handle] = Table(
dir+"/"+
handle, mode, lock_file);
tables[handle] = Table(
combine_path(dir,
handle
)
, mode, lock_file);
table_refs[handle]++;
table_refs[handle]++;
return _Table(handle, tables[handle], _table_destroyed);
return _Table(handle, tables[handle], _table_destroyed);
UNLOCK();
UNLOCK();
...
@@ -1202,7 +1202,7 @@ class db {
...
@@ -1202,7 +1202,7 @@ class db {
f = f[..<1];
f = f[..<1];
if(Stdio.is_dir(f))
if(Stdio.is_dir(f))
foreach(get_dir(f)||({}), string file)
foreach(get_dir(f)||({}), string file)
rm(
f+"/"+
file);
rm(
combine_path(f,
file)
)
;
rm(f);
rm(f);
}
}
...
@@ -1265,9 +1265,9 @@ class db {
...
@@ -1265,9 +1265,9 @@ class db {
if(search(mode, "w")+1) {
if(search(mode, "w")+1) {
write = 1;
write = 1;
if(search(mode, "c")+1)
if(search(mode, "c")+1)
Stdio.mkdirhier(dir
+"/"
);
Stdio.mkdirhier(dir);
}
}
lock_file = ProcessLock(
dir+"/
lock.pid", mode);
lock_file = ProcessLock(
combine_path(dir, "
lock.pid"
)
, mode);
}
}
}
}
...
@@ -1292,7 +1292,7 @@ class LookupTable {
...
@@ -1292,7 +1292,7 @@ class LookupTable {
mixed get(string handle)
mixed get(string handle)
{
{
LOCK();
LOCK();
return
(
table->get(h(handle))
||([]))
[handle];
return table->get(h(handle))[
?
handle];
UNLOCK();
UNLOCK();
}
}
...
@@ -1351,15 +1351,16 @@ class lookup {
...
@@ -1351,15 +1351,16 @@ class lookup {
{
{
LOCK();
LOCK();
return (tables[handle] =
return (tables[handle] =
tables[handle]||LookupTable(
dir+"/"+
handle, mode, minx));
tables[handle]||LookupTable(
combine_path(dir,
handle
)
, mode, minx));
UNLOCK();
UNLOCK();
}
}
protected void create(string dir, string mode, mapping|void opt)
protected void create(string dir, string mode, mapping|void opt)
{
{
::create(dir, (mode-"t"));
::create(dir, (mode-"t"));
minx = (opt||([]))->index_size || 0x7ff;
minx = opt?->index_size || 0x7ff;
if(!sscanf(Stdio.read_bytes(dir+"/hs")||"", "%4c", minx))
string file = combine_path(dir, "hs");
Stdio.write_file(dir+"/hs", sprintf("%4c", minx));
if(!sscanf(Stdio.read_bytes(file)||"", "%4c", minx))
Stdio.write_file(file, sprintf("%4c", minx));
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment