metascene initial implementation
[laserbrain_demo] / src / datamap.cc
index 19aaf44..ee7de51 100644 (file)
@@ -112,7 +112,7 @@ int datamap_lookup(const char *in, char *buf, int bsz)
                res = it->second;
        } else {
                // try matching with the available mappings
-               res = std::string(in);
+               res = root.empty() ? std::string(in) : root + "/" + std::string(in);
 
                int num = dmap.size();
                for(int i=0; i<num; i++) {
@@ -130,7 +130,7 @@ int datamap_lookup(const char *in, char *buf, int bsz)
        if(buf) {
                int n = std::min(bsz - 1, (int)res.length());
                memcpy(buf, res.c_str(), n);
-               buf[bsz - 1] = 0; // make sure it's null-terminated even if it got truncated
+               buf[n] = 0; // make sure it's null-terminated even if it got truncated
        }
        return res.length() + 1;
 }