fix use of uninitialized values in JarElement; use system-specific path separator in finder

This commit is contained in:
Joel Dice 2007-10-24 09:46:09 -06:00
parent ea6f67a7c7
commit 394d80a07a
4 changed files with 19 additions and 4 deletions

View File

@ -59,6 +59,11 @@ class DirectoryElement: public Element {
const char* file = append(s, this->name, "/", name);
System::Region* region;
System::Status status = s->map(&region, file);
if (status) {
fprintf(stderr, "%s not found\n", file);
}
s->free(file);
if (s->success(status)) {
@ -325,7 +330,7 @@ class JarIndex {
class JarElement: public Element {
public:
JarElement(System* s, const char* name):
s(s), name(name)
s(s), name(name), region(0), index(0)
{ }
void init() {
@ -401,12 +406,14 @@ parsePath(System* s, const char* path)
Element* first = 0;
Element* prev = 0;
for (Tokenizer t(path, ':'); t.hasMore();) {
for (Tokenizer t(path, s->pathSeparator()); t.hasMore();) {
Tokenizer::Token token(t.next());
char* name = static_cast<char*>(s->allocate(token.length + 1));
memcpy(name, token.s, token.length);
name[token.length] = 0;
fprintf(stderr, "path element: %s\n", name);
Element* e;
switch (s->identify(name)) {
case System::File: {

View File

@ -550,6 +550,10 @@ class MySystem: public System {
}
}
virtual char pathSeparator() {
return ':';
}
virtual int64_t now() {
timeval tv = { 0, 0 };
gettimeofday(&tv, 0);

View File

@ -94,8 +94,9 @@ class System: public Allocator {
virtual FileType identify(const char* name) = 0;
virtual Status load(Library**, const char* name, bool mapName, Library* next)
= 0;
virtual void exit(int code) = 0;
virtual char pathSeparator() = 0;
virtual int64_t now() = 0;
virtual void exit(int code) = 0;
virtual void abort() = 0;
virtual void dispose() = 0;

View File

@ -462,7 +462,7 @@ class MySystem: public System {
virtual Status attach(Runnable* r) {
Thread* t = new (System::allocate(sizeof(Thread))) Thread(this, r);
bool success = DuplicateHandle
bool success UNUSED = DuplicateHandle
(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(),
&(t->thread), 0, false, DUPLICATE_SAME_ACCESS);
assert(this, success);
@ -581,6 +581,9 @@ class MySystem: public System {
}
}
virtual char pathSeparator() {
return ';';
}
virtual int64_t now() {
static LARGE_INTEGER frequency;