projects
/
laserbrain_demo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- fixed bug in mirror matching
[laserbrain_demo]
/
src
/
datamap.cc
diff --git
a/src/datamap.cc
b/src/datamap.cc
index
e466082
..
dcbae78
100644
(file)
--- a/
src/datamap.cc
+++ b/
src/datamap.cc
@@
-1,9
+1,10
@@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <algorithm>
#include "datamap.h"
#include "datamap.h"
-#ifdef WIN32
+#if defined(WIN32) || defined(__WIN32__)
#include <malloc.h>
#else
#include <alloca.h>
#include <malloc.h>
#else
#include <alloca.h>
@@
-11,6
+12,11
@@
static char *clean_line(char *s);
static char *clean_line(char *s);
+DataMap::DataMap()
+{
+ strip_paths = false;
+}
+
void DataMap::clear()
{
dmap.clear();
void DataMap::clear()
{
dmap.clear();
@@
-22,6
+28,11
@@
void DataMap::set_path(const char *path)
root = std::string(path);
}
root = std::string(path);
}
+void DataMap::set_strip(bool s)
+{
+ strip_paths = s;
+}
+
bool DataMap::load_map(const char *fname)
{
std::string path = root.empty() ? fname : root + std::string("/") + fname;
bool DataMap::load_map(const char *fname)
{
std::string path = root.empty() ? fname : root + std::string("/") + fname;
@@
-91,6
+102,13
@@
int DataMap::lookup(const char *in, char *buf, int bsz) const
{
std::string res;
{
std::string res;
+ if(strip_paths) {
+ const char *ptr = strrchr(in, '/');
+ if(ptr) {
+ in = ptr + 1;
+ }
+ }
+
char *inbuf = (char*)alloca(strlen(in) + 1);
strcpy(inbuf, in);
in = clean_line(inbuf);
char *inbuf = (char*)alloca(strlen(in) + 1);
strcpy(inbuf, in);
in = clean_line(inbuf);