[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r465 - doodle/src/doodle
From: |
grothoff |
Subject: |
[GNUnet-SVN] r465 - doodle/src/doodle |
Date: |
Sun, 20 Mar 2005 15:55:27 -0800 (PST) |
Author: grothoff
Date: 2005-03-20 15:55:26 -0800 (Sun, 20 Mar 2005)
New Revision: 465
Modified:
doodle/src/doodle/convert.c
doodle/src/doodle/doodle.c
doodle/src/doodle/doodle.h
doodle/src/doodle/doodled.c
doodle/src/doodle/files.c
doodle/src/doodle/grow.c
doodle/src/doodle/help.c
doodle/src/doodle/helper1.h
doodle/src/doodle/helper2.h
doodle/src/doodle/index.c
doodle/src/doodle/logreplay.c
doodle/src/doodle/proftree.c
doodle/src/doodle/proftree2.c
doodle/src/doodle/proftree3.c
doodle/src/doodle/semaphore.c
doodle/src/doodle/semaphore.h
doodle/src/doodle/shutdown.c
doodle/src/doodle/testio.c
doodle/src/doodle/testtree.c
doodle/src/doodle/testtree2.c
doodle/src/doodle/testtree3.c
doodle/src/doodle/testtree4.c
doodle/src/doodle/tree.c
Log:
whitespace
Modified: doodle/src/doodle/convert.c
===================================================================
--- doodle/src/doodle/convert.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/convert.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -41,7 +41,7 @@
char * ret;
char * itmp;
iconv_t cd;
-
+
cd = iconv_open("UTF-8", charset);
if (cd == (iconv_t) -1)
return strdup(charset);
@@ -52,7 +52,7 @@
if (iconv(cd,
(char**) &input,
&len,
- &itmp,
+ &itmp,
&finSize) == (size_t)-1) {
iconv_close(cd);
free(tmp);
Modified: doodle/src/doodle/doodle.c
===================================================================
--- doodle/src/doodle/doodle.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/doodle.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -68,7 +68,7 @@
{ 'b', "build", NULL,
gettext_noop("build database (default is to search)") },
{ 'B', "binary", "LANG",
- gettext_noop("use the generic plaintext extractor for the language with
the 2-letter language code LANG (use when building database)") },
+ gettext_noop("use the generic plaintext extractor for the language with
the 2-letter language code LANG (use when building database)") },
{ 'd', "database", "FILENAME",
gettext_noop("use location FILENAME to store doodle database") },
{ 'e', "extract", NULL,
@@ -82,9 +82,9 @@
{ 'i', "ignore-case", NULL,
gettext_noop("be case-insensitive (use when searching)") },
{ 'l', "library", "LIBRARY",
- gettext_noop("load an extractor plugin named LIBRARY") },
+ gettext_noop("load an extractor plugin named LIBRARY") },
{ 'L', "log", "FILENAME",
- gettext_noop("log keywords to a file named FILENAME") },
+ gettext_noop("log keywords to a file named FILENAME") },
{ 'n', "nodefault", NULL,
gettext_noop("do not load default set of extractor plugins") },
{ 'm', "memory", "SIZE",
@@ -101,7 +101,7 @@
};
formatHelp(_("doodle [OPTIONS] ([FILENAMES]*|[KEYWORDS]*)"),
_("Index and search meta-data of files."),
- help);
+ help);
}
static int do_extract = 0;
@@ -124,17 +124,17 @@
va_list args;
if ( (level == 0) ||
(verbose && (level == 1)) ||
- (very_verbose && (level == 2) ) ) {
+ (very_verbose && (level == 2) ) ) {
va_start(args, msg);
vfprintf(stdout, msg, args);
va_end(args);
- }
+ }
}
static int isPruned(const char * filename) {
int i;
int last;
-
+
i = strlen(prunepaths);
last = i;
while (i > 0) {
@@ -159,7 +159,7 @@
/**
* @brief closure for do_index
- */
+ */
typedef struct {
EXTRACTOR_ExtractorList * elist;
struct DOODLE_SuffixTree * tree;
@@ -174,15 +174,15 @@
struct stat sbuf;
if (isPruned(filename))
- return 0;
+ return 0;
j = -1;
- for (i=DOODLE_getFileCount(dic->tree)-1;i>=0;i--)
+ for (i=DOODLE_getFileCount(dic->tree)-1;i>=0;i--)
if (0 == strcmp(filename,
DOODLE_getFileAt(dic->tree,i)->filename)) {
j = i;
break;
}
- if (j != -1)
+ if (j != -1)
return 0; /* already processed */
if (0 != stat(filename,
&sbuf)) {
@@ -249,14 +249,14 @@
if (verbose)
printf(_("Loading default set of libextractor plugins.\n"));
cls.elist = EXTRACTOR_loadDefaultLibraries();
- } else
+ } else
cls.elist = NULL;
if (libraries != NULL) {
if (verbose)
printf(_("Loading libextractor plugins: '%s'\n"),
libraries);
cls.elist = EXTRACTOR_loadConfigLibraries(cls.elist,
- libraries);
+ libraries);
}
if (cls.elist == NULL) {
printf(_("Failed to load any libextractor plugins. Aborting.\n"));
@@ -289,7 +289,7 @@
free(exp);
break;
}
- free(exp);
+ free(exp);
}
EXTRACTOR_removeAll(cls.elist);
DOODLE_tree_destroy(cls.tree);
@@ -316,7 +316,7 @@
EXTRACTOR_KeywordList * head;
const char * filename;
int i;
-
+
filename = fileinfo->filename;
if (isPruned(filename))
return;
@@ -324,7 +324,7 @@
if (0 == strcmp(filename,
args->filenames_seen[i]))
return;
- if (args->seen_count == args->seen_size) {
+ if (args->seen_count == args->seen_size) {
GROW(args->filenames_seen,
args->seen_size,
args->seen_size*2 + 128);
@@ -337,7 +337,7 @@
head = EXTRACTOR_removeDuplicateKeywords
(head,
EXTRACTOR_DUPLICATES_REMOVE_UNKNOWN);
-
+
/* print */
printf(_("Keywords for matching file '%s':\n"),
filename);
@@ -364,7 +364,7 @@
char * ename;
struct stat buf;
int ret;
-
+
if (dbName == NULL) {
printf(_("No database specified. Aborting.\n"));
return -1;
@@ -382,7 +382,7 @@
NULL,
ename);
free(ename);
- if (tree == NULL)
+ if (tree == NULL)
return -1;
ret = DOODLE_tree_dump(stdout,
tree);
@@ -396,7 +396,7 @@
int argc,
char * argv[]) {
int ret;
- struct stat buf;
+ struct stat buf;
char * ename;
struct DOODLE_SuffixTree * tree;
EXTRACTOR_ExtractorList * extractors;
@@ -425,16 +425,16 @@
mem_limit);
free(ename);
- if (tree == NULL)
+ if (tree == NULL)
return -1;
if (do_extract) {
if (do_default)
extractors = EXTRACTOR_loadDefaultLibraries();
- else
+ else
extractors = NULL;
- if (libraries != NULL)
+ if (libraries != NULL)
extractors = EXTRACTOR_loadConfigLibraries(extractors,
- libraries);
+ libraries);
} else
extractors = NULL;
@@ -467,7 +467,7 @@
&args)) {
printf(_("\tNot found!\n"));
ret++;
- }
+ }
} else {
if (0 == DOODLE_tree_search_approx(tree,
do_approx,
@@ -480,7 +480,7 @@
}
}
free(utf);
- }
+ }
DOODLE_tree_destroy(tree);
EXTRACTOR_removeAll(extractors);
@@ -526,7 +526,7 @@
{"extract", 0, 0, 'e'},
{"filenames", 0, 0, 'f'} ,
{"help", 0, 0, 'h'},
- {"hash", 1, 0, 'H'},
+ {"hash", 1, 0, 'H'},
{"ignore-case", 0, 0, 'i'},
{"library", 1, 0, 'l'},
{"log", 1, 0, 'L'},
@@ -540,14 +540,14 @@
};
option_index = 0;
c = getopt_long(argc,
- argv, "VvhbB:eH:nm:il:L:vd:fa:p",
- long_options,
+ argv, "VvhbB:eH:nm:il:L:vd:fa:p",
+ long_options,
&option_index);
-
+
if (c == -1)
break; /* No more flags to process */
switch (c) {
- case 'a':
+ case 'a':
if (1 != sscanf(optarg, "%ud", &do_approx)) {
printf(_("You must pass a number to the '%s' option.\n"),
"-a");
@@ -578,7 +578,7 @@
printf(_("The options '%s' and '%s' cannot be used together!\n"),
"-b", "-i");
return -1;
- }
+ }
break;
case 'd':
dbName = optarg;
@@ -602,14 +602,14 @@
"-b", "-i");
return -1;
}
- break;
+ break;
case 'l':
libraries = optarg;
break;
case 'L':
log = optarg;
break;
- case 'm':
+ case 'm':
if (1 != sscanf(optarg, "%ud", &mem_limit)) {
printf(_("You must pass a number to the '%s' option.\n"),
"-m");
@@ -623,7 +623,7 @@
break;
case 'n':
do_default = 0;
- break;
+ break;
case 'p':
do_print = 1;
if (do_build == 1) {
@@ -650,25 +650,25 @@
return -1;
} /* end of parsing commandline */
} /* while (1) */
-
+
if ( (do_print == 0) &&
- (argc - optind < 1) ) {
+ (argc - optind < 1) ) {
fprintf(stderr,
- do_build ?
+ do_build ?
_("Invoke with filenames or directories to index!\n") :
_("Invoke with query terms to search for!\n"));
return -1;
}
-
+
if (libraries != NULL)
libraries = strdup(libraries);
- if (binary != NULL) {
+ if (binary != NULL) {
if (libraries == NULL)
- tmp = MALLOC(strlen("libextractor_printable_") + 1 +
+ tmp = MALLOC(strlen("libextractor_printable_") + 1 +
strlen(binary));
else
- tmp = MALLOC(strlen(libraries) +
- strlen(":libextractor_printable_") + 1 +
+ tmp = MALLOC(strlen(libraries) +
+ strlen(":libextractor_printable_") + 1 +
strlen(binary));
if (libraries == NULL) {
strcpy(tmp, "libextractor_printable_");
@@ -680,15 +680,15 @@
if (libraries != NULL)
free(libraries);
libraries = tmp;
- }
+ }
- if (hash != NULL) {
+ if (hash != NULL) {
if (libraries == NULL)
- tmp = MALLOC(strlen("libextractor_hash_") + 1 +
+ tmp = MALLOC(strlen("libextractor_hash_") + 1 +
strlen(hash));
else
- tmp = MALLOC(strlen(libraries) +
- strlen(":libextractor_hash_") + 1 +
+ tmp = MALLOC(strlen(libraries) +
+ strlen(":libextractor_hash_") + 1 +
strlen(hash));
if (libraries == NULL) {
strcpy(tmp, "libextractor_hash_");
@@ -700,7 +700,7 @@
if (libraries != NULL)
free(libraries);
libraries = tmp;
- }
+ }
if (do_build) {
ret = build(libraries,
@@ -711,16 +711,16 @@
&argv[optind]);
if (libraries != NULL)
free(libraries);
- return ret;
+ return ret;
} else if (do_print) {
int i;
char * name;
-
+
ret = 0;
- name = strdup(dbName);
+ name = strdup(dbName);
for (i=strlen(name)-1;i>=0;i--) {
if (name[i] == ':') {
- ret += print(&name[i+1]);
+ ret += print(&name[i+1]);
name[i] = '\0';
}
}
@@ -732,9 +732,9 @@
} else {
int i;
char * name;
-
+
ret = 0;
- name = strdup(dbName);
+ name = strdup(dbName);
for (i=strlen(name)-1;i>=0;i--) {
if (name[i] == ':') {
ret += search(libraries,
Modified: doodle/src/doodle/doodle.h
===================================================================
--- doodle/src/doodle/doodle.h 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/doodle.h 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -87,7 +87,7 @@
const char * database);
/**
- * Open an existing database READ-ONLY.
+ * Open an existing database READ-ONLY.
* @return NULL on error (i.e. DB does not exist)
*/
struct DOODLE_SuffixTree * DOODLE_tree_open_RDONLY(DOODLE_Logger log,
@@ -148,7 +148,7 @@
void * arg);
/**
- * Search the suffix tree for matching strings.
+ * Search the suffix tree for matching strings.
*
* @param substring the string to search for
* @param callback function to call for each matching file
@@ -183,7 +183,7 @@
* Change the memory limit (how much memory the
* tree may use). Note that the limit only refers
* to the tree nodes, memory used for keywords and
- * filenames is excluded since the current code
+ * filenames is excluded since the current code
* does not support keeping those on disk.
*
* @param limit new memory limit in bytes
Modified: doodle/src/doodle/doodled.c
===================================================================
--- doodle/src/doodle/doodled.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/doodled.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -58,7 +58,7 @@
static Help help[] = {
{ 'B', "binary", "LANG",
gettext_noop("use the generic plaintext extractor"
- " for the language with the 2-letter language code LANG") },
+ " for the language with the 2-letter language code LANG") },
{ 'd', "database", "FILENAME",
gettext_noop("use location FILENAME to store doodle database") },
{ 'D', "debug", NULL,
@@ -70,9 +70,9 @@
{ 'H', "hash", "ALGORITHM",
gettext_noop("compute hash using the given ALGORITHM") },
{ 'l', "library", "LIBRARY",
- gettext_noop("load an extractor plugin named LIBRARY") },
+ gettext_noop("load an extractor plugin named LIBRARY") },
{ 'L', "log", "FILENAME",
- gettext_noop("log activity to a file named FILENAME") },
+ gettext_noop("log activity to a file named FILENAME") },
{ 'n', "nodefault", NULL,
gettext_noop("do not load default set of extractor plugins") },
{ 'm', "memory", "SIZE",
@@ -87,7 +87,7 @@
};
formatHelp(_("doodled [OPTIONS] [FILENAMES]"),
_("Continuously index files in the background."),
- help);
+ help);
}
static int do_debug = 0;
@@ -100,7 +100,7 @@
static int isPruned(const char * filename) {
int i;
int last;
-
+
i = strlen(prunepaths);
last = i;
while (i > 0) {
@@ -134,18 +134,18 @@
if ( (0) ||
(level == 0) ||
(verbose && (level == 1)) ||
- (very_verbose && (level == 2) ) ) {
+ (very_verbose && (level == 2) ) ) {
va_start(args, msg);
vfprintf(logfile, msg, args);
va_end(args);
- }
+ }
}
/* ************** actual functionality code ************* */
/**
* @brief closure for do_index and other processing functions
- */
+ */
typedef struct {
EXTRACTOR_ExtractorList * elist;
struct DOODLE_SuffixTree * tree;
@@ -187,16 +187,16 @@
DOODLE_LOG_VERY_VERBOSE,
_("Event processing thread created.\n"));
while ( (0 == testShutdown()) &&
- (cls->continueRunning) ) {
+ (cls->continueRunning) ) {
char * name;
-
+
FD_ZERO(&r);
FD_ZERO(&w);
FD_ZERO(&e);
FD_SET(fd, &r);
i = select(fd+1, &r, &w, &e, NULL);
if (i == -1) {
- if (errno == EINTR)
+ if (errno == EINTR)
continue;
cls->log(cls->logContext,
DOODLE_LOG_CRITICAL,
@@ -214,7 +214,7 @@
sleep(1);
continue;
}
-
+
MUTEX_LOCK(&cls->lock);
if (-1 == FAMNextEvent(&cls->fc, &fe)) {
cls->log(cls->logContext,
@@ -244,12 +244,12 @@
MUTEX_UNLOCK(&cls->lock);
continue;
}
-
-
+
+
cls->log(cls->logContext,
DOODLE_LOG_INSANELY_VERBOSE,
"FAM EVENT (%d,%s,%s) on file '%s'.\n",
- fe.code,
+ fe.code,
fe.userdata,
fe.filename,
name);
@@ -259,8 +259,8 @@
case FAMDeleted:
case FAMMoved:
case FAMAcknowledge:
- case FAMExists:
- case FAMEndExist:
+ case FAMExists:
+ case FAMEndExist:
GROW(cls->events,
cls->eventCount,
cls->eventCount+1);
@@ -290,9 +290,9 @@
dic->ename,
strlen(dic->ename)))
return 0; /* database (and database-temp file) is always pruned! */
-
+
if (isPruned(filename))
- return 0;
+ return 0;
for (i=dic->deferredCount-1;i>=0;i--) {
if (0 == strcmp(filename,
dic->deferredTruncations[i])) {
@@ -313,7 +313,7 @@
break;
}
}
-
+
k = -1;
for (i=0;i<dic->frPos;i++) {
if (0 == strcmp(filename,
@@ -336,7 +336,7 @@
GROW(dic->deferredTruncations,
dic->deferredCount,
dic->deferredCount + 1);
- dic->deferredTruncations[dic->deferredCount-1]
+ dic->deferredTruncations[dic->deferredCount-1]
= strdup(filename);
}
if (k != -1) {
@@ -355,15 +355,15 @@
dic->frNames[dic->frPos-1] = NULL;
dic->frPos--;
}
- return 0;
- }
+ return 0;
+ }
if ( (S_ISDIR(sbuf.st_mode)) &&
#ifdef S_ISLNK
- (! S_ISLNK(sbuf.st_mode)) &&
+ (! S_ISLNK(sbuf.st_mode)) &&
#endif
#ifdef S_ISSOCK
- (! S_ISSOCK(sbuf.st_mode)) &&
+ (! S_ISSOCK(sbuf.st_mode)) &&
#endif
(k == -1) ) {
char * fn;
@@ -414,9 +414,9 @@
GROW(dic->deferredTruncations,
dic->deferredCount,
dic->deferredCount + 2);
- dic->deferredTruncations[dic->deferredCount-2]
+ dic->deferredTruncations[dic->deferredCount-2]
= strdup(filename);
-
+
DOODLE_tree_truncate_multiple(dic->tree,
(const char**)dic->deferredTruncations);
for (i=dic->deferredCount-2;i>=0;i--)
@@ -471,7 +471,7 @@
run_shutdown(0);
return NULL;
}
-
+
DOODLE_tree_truncate_modified(cls->tree,
cls->log,
cls->logContext);
@@ -492,7 +492,7 @@
free(exp);
break;
}
- free(exp);
+ free(exp);
}
DOODLE_tree_destroy(cls->tree);
cls->treePresent = 0;
@@ -529,7 +529,7 @@
if (cls->treePresent == 1)
cls->tree = DOODLE_tree_create((DOODLE_Logger) cls->log,
cls->logContext,
- cls->ename);
+ cls->ename);
}
MUTEX_UNLOCK(&cls->lock);
if (fn != NULL) {
@@ -564,7 +564,7 @@
const char * dbName,
size_t mem_limit,
const char * log,
- int argc,
+ int argc,
char * argv[]) {
int i;
int ret;
@@ -579,7 +579,7 @@
cls.argv = argv;
cls.deferredCount = 0;
cls.deferredTruncations = NULL;
- logfile = NULL;
+ logfile = NULL;
if (log != NULL) {
logfile = fopen(log, "w+");
if (logfile == NULL)
@@ -627,7 +627,7 @@
DOODLE_LOG_VERY_VERBOSE,
_("Loading default set of libextractor plugins.\n"));
cls.elist = EXTRACTOR_loadDefaultLibraries();
- } else
+ } else
cls.elist = NULL;
if (libraries != NULL) {
my_log(logfile,
@@ -635,7 +635,7 @@
_("Loading libextractor plugins: '%s'\n"),
libraries);
cls.elist = EXTRACTOR_loadConfigLibraries(cls.elist,
- libraries);
+ libraries);
}
if (cls.elist == NULL) {
my_log(logfile,
@@ -664,7 +664,7 @@
128);
ret = 0;
-
+
MUTEX_CREATE(&cls.lock);
if (0 != PTHREAD_CREATE(&workerThread,
(PThreadMain)&worker,
@@ -689,8 +689,8 @@
DOODLE_LOG_CRITICAL,
_("No files exist that doodled would monitor for changes.
Exiting.\n"));
}
-
+
for (i=0;i<cls.frSize;i++) {
/* flush fam-event queue */
while (FAMPending(&cls.fc))
@@ -707,7 +707,7 @@
DOODLE_LOG_VERBOSE,
_("Cancling fam monitor '%s'.\n"),
cls.frNames[i]);
- if (-1 == FAMCancelMonitor(&cls.fc,
+ if (-1 == FAMCancelMonitor(&cls.fc,
&cls.fr[i])) {
cls.log(cls.logContext,
DOODLE_LOG_CRITICAL,
@@ -735,8 +735,8 @@
if (0 != FAMClose(&cls.fc)) {
my_log(logfile,
DOODLE_LOG_CRITICAL,
- _("Error disconnecting from fam.\n"));
- }
+ _("Error disconnecting from fam.\n"));
+ }
my_log(logfile,
DOODLE_LOG_VERBOSE,
_("Unloading libextractor plugins.\n"));
@@ -759,7 +759,7 @@
pid_t pid;
int nullfd;
#endif
-
+
/* Don't hold the wrong FS mounted */
if (chdir("/") < 0) {
perror("chdir");
@@ -776,16 +776,16 @@
if (pid) { /* Parent */
int ok;
char c;
-
+
close(filedes[1]); /* we only read */
ok = -1;
while (0 < read(filedes[0], &c, sizeof(char))) {
- if (c == '.')
+ if (c == '.')
ok = 0;
- }
+ }
fflush(stdout);
if (ok == 0)
- exit(0);
+ exit(0);
else
exit(1); /* child reported error */
}
@@ -795,13 +795,13 @@
if (nullfd < 0) {
perror("/dev/null");
exit(1);
- }
+ }
/* child - close fds linking to invoking terminal, but
* close usual incoming fds, but redirect them somewhere
* useful so the fds don't get reallocated elsewhere.
*/
- if (dup2(nullfd,0) < 0 ||
- dup2(nullfd,1) < 0 ||
+ if (dup2(nullfd,0) < 0 ||
+ dup2(nullfd,1) < 0 ||
dup2(nullfd,2) < 0) {
perror("dup2"); /* Should never happen */
exit(1);
@@ -852,7 +852,7 @@
{"debug", 0, 0, 'D'},
{"filenames", 0, 0, 'f'} ,
{"help", 0, 0, 'h'},
- {"hash", 1, 0, 'H'},
+ {"hash", 1, 0, 'H'},
{"library", 1, 0, 'l'},
{"log", 1, 0, 'L'},
{"memory", 1, 0, 'm'},
@@ -864,10 +864,10 @@
};
option_index = 0;
c = getopt_long(argc,
- argv, "B:d:DfhH:l:L:m:nP:vV",
- long_options,
+ argv, "B:d:DfhH:l:L:m:nP:vV",
+ long_options,
&option_index);
-
+
if (c == -1)
break; /* No more flags to process */
switch (c) {
@@ -895,7 +895,7 @@
case 'L':
log = optarg;
break;
- case 'm':
+ case 'm':
if (1 != sscanf(optarg, "%ud", &mem_limit)) {
printf(_("You must pass a number to the '%s' option.\n"),
"-m");
@@ -909,7 +909,7 @@
break;
case 'n':
do_default = 0;
- break;
+ break;
case 'P':
prunepaths = optarg;
break;
@@ -928,22 +928,22 @@
return -1;
} /* end of parsing commandline */
} /* while (1) */
-
- if (argc - optind < 1) {
+
+ if (argc - optind < 1) {
fprintf(stderr,
_("Invoke with filenames or directories to monitor!\n"));
return -1;
}
-
+
if (libraries != NULL)
libraries = strdup(libraries);
- if (binary != NULL) {
+ if (binary != NULL) {
if (libraries == NULL)
- tmp = MALLOC(strlen("libextractor_printable_") + 1 +
+ tmp = MALLOC(strlen("libextractor_printable_") + 1 +
strlen(binary));
else
- tmp = MALLOC(strlen(libraries) +
- strlen(":libextractor_printable_") + 1 +
+ tmp = MALLOC(strlen(libraries) +
+ strlen(":libextractor_printable_") + 1 +
strlen(binary));
if (libraries == NULL) {
strcpy(tmp, "libextractor_printable_");
@@ -955,15 +955,15 @@
if (libraries != NULL)
free(libraries);
libraries = tmp;
- }
+ }
- if (hash != NULL) {
+ if (hash != NULL) {
if (libraries == NULL)
- tmp = MALLOC(strlen("libextractor_hash_") + 1 +
+ tmp = MALLOC(strlen("libextractor_hash_") + 1 +
strlen(hash));
else
- tmp = MALLOC(strlen(libraries) +
- strlen(":libextractor_hash_") + 1 +
+ tmp = MALLOC(strlen(libraries) +
+ strlen(":libextractor_hash_") + 1 +
strlen(hash));
if (libraries == NULL) {
strcpy(tmp, "libextractor_hash_");
@@ -975,8 +975,8 @@
if (libraries != NULL)
free(libraries);
libraries = tmp;
- }
-
+ }
+
if (do_debug == 0)
detachFromTerminal(filedes);
initializeShutdownHandlers();
@@ -988,11 +988,11 @@
mem_limit,
log,
argc - optind,
- &argv[optind]);
+ &argv[optind]);
doneShutdownHandlers();
if (libraries != NULL)
free(libraries);
- return ret;
+ return ret;
}
/* end of doodled.c */
Modified: doodle/src/doodle/files.c
===================================================================
--- doodle/src/doodle/files.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/files.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -76,7 +76,7 @@
DOODLE_LOG_VERBOSE,
_("Call to '%s' for file '%s' failed: %s\n"),
"lstat",
- dirName,
+ dirName,
strerror(errno));
return 0;
}
@@ -88,12 +88,12 @@
if (S_ISSOCK(istat.st_mode))
return 0;
#endif
- if (S_ISCHR(istat.st_mode) ||
+ if (S_ISCHR(istat.st_mode) ||
S_ISBLK(istat.st_mode) ||
S_ISFIFO(istat.st_mode) )
return 0;
if ( (S_ISREG(istat.st_mode)) ||
- (S_ISDIR(istat.st_mode)) )
+ (S_ISDIR(istat.st_mode)) )
if (-1 == callback(dirName,
cb_arg))
return -1;
@@ -120,7 +120,7 @@
if (finfo->d_name[0] == '.')
continue;
- dn = MALLOC(strlen(dirName) +
+ dn = MALLOC(strlen(dirName) +
strlen(finfo->d_name) + 2);
strcpy(dn, dirName);
if (dirName[strlen(dirName)-1] != DIR_SEPARATOR)
@@ -130,9 +130,9 @@
logger,
context,
callback,
- cb_arg);
+ cb_arg);
free(dn);
- if (ret >= 0)
+ if (ret >= 0)
count += ret;
else
return -1;
@@ -144,9 +144,9 @@
/**
* Complete filename (a la shell) from abbrevition.
- * @param fil the name of the file, may contain ~/ or
+ * @param fil the name of the file, may contain ~/ or
* be relative to the current directory
- * @returns the full file name,
+ * @returns the full file name,
* NULL is returned on error
*/
char * expandFileName(const char * fil) {
@@ -177,9 +177,9 @@
/* do not copy '~' */
fil_ptr = fil + 1;
- /* skip over dir seperator to be consistent */
- if (fil_ptr[0] == DIR_SEPARATOR)
- fil_ptr++;
+ /* skip over dir seperator to be consistent */
+ if (fil_ptr[0] == DIR_SEPARATOR)
+ fil_ptr++;
} else {
fil_ptr = fil;
if (getcwd(buffer, 512) != NULL)
@@ -188,7 +188,7 @@
fm = "$PWD";
}
fn = MALLOC(strlen(fm) + 1 + strlen(fil_ptr) + 1);
-
+
sprintf(fn, "%s/%s", fm, fil_ptr);
#else
fn = MALLOC(MAX_PATH + 1);
@@ -200,7 +200,7 @@
return NULL;
}
/* is the path relative? */
- if ((strncmp(buffer + 1, ":\\", 2) != 0) &&
+ if ((strncmp(buffer + 1, ":\\", 2) != 0) &&
(strncmp(buffer, "\\\\", 2) != 0))
{
char szCurDir[MAX_PATH + 1];
@@ -208,7 +208,7 @@
if (lRet + strlen(fn) + 1 > (_MAX_PATH + 1))
{
SetErrnoFromWinError(ERROR_BUFFER_OVERFLOW);
-
+
return NULL;
}
sprintf(fn, "%s\\%s", szCurDir, buffer);
Modified: doodle/src/doodle/grow.c
===================================================================
--- doodle/src/doodle/grow.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/grow.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -35,7 +35,7 @@
void * MALLOC(size_t size) {
void * ret;
-
+
if (size == 0) {
fprintf(stderr,
_("FATAL: MALLOC called with size 0!\n"));
@@ -105,12 +105,12 @@
if (size == 0) {
tmp = NULL;
} else {
- tmp = MALLOC(size);
+ tmp = MALLOC(size);
memset(tmp, 0, size); /* client code should not rely on this, though... */
if (*oldCount > newCount)
*oldCount = newCount; /* shrink is also allowed! */
- memcpy(tmp,
- *old,
+ memcpy(tmp,
+ *old,
elementSize * (*oldCount));
}
Modified: doodle/src/doodle/help.c
===================================================================
--- doodle/src/doodle/help.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/help.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -47,7 +47,7 @@
int p;
char * scp;
const char * trans;
-
+
printf(_("Usage: %s\n%s\n\n"),
gettext(general),
gettext(description));
@@ -67,7 +67,7 @@
printf("=%s",
opt[i].mandatoryArg);
slen += 1+strlen(opt[i].mandatoryArg);
- }
+ }
if (slen > BORDER) {
printf("\n%*s", BORDER, "");
slen = BORDER;
Modified: doodle/src/doodle/helper1.h
===================================================================
--- doodle/src/doodle/helper1.h 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/helper1.h 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
Modified: doodle/src/doodle/helper2.h
===================================================================
--- doodle/src/doodle/helper2.h 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/helper2.h 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -62,9 +62,9 @@
/**
* Complete filename (a la shell) from abbrevition.
- * @param fil the name of the file, may contain ~/ or
+ * @param fil the name of the file, may contain ~/ or
* be relative to the current directory
- * @returns the full file name,
+ * @returns the full file name,
* NULL is returned on error
*/
char * expandFileName(const char * fil);
Modified: doodle/src/doodle/index.c
===================================================================
--- doodle/src/doodle/index.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/index.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -20,7 +20,7 @@
/**
* @file index.c
- * @brief index file using libextractor
+ * @brief index file using libextractor
* @author Christian Grothoff
*
* This function effectively describes the bridge between libextractor
@@ -95,10 +95,10 @@
while (cpos[0] != '\0') {
if (0 != DOODLE_tree_expand(tree,
cpos,
- filename))
+ filename))
return 0;
cpos++;
}
- }
+ }
return 1;
}
Modified: doodle/src/doodle/logreplay.c
===================================================================
--- doodle/src/doodle/logreplay.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/logreplay.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -65,7 +65,7 @@
return;
va_start(args, msg);
vfprintf(stdout, msg, args);
- va_end(args);
+ va_end(args);
}
static void add(struct DOODLE_SuffixTree * tree,
@@ -77,7 +77,7 @@
char section[MAX_LENGTH+1];
char * xpos;
int j;
-
+
for (j=0;j<slen;j+=MAX_LENGTH/2) {
strncpy(section,
&key[j],
@@ -117,7 +117,7 @@
FILE * in;
char key[MAX_KEYWORD_LEN+1];
int i;
-
+
if (argc != 2) {
fprintf(stderr,
"Call with log file as argument!\n");
@@ -143,7 +143,7 @@
printf("Processed %8u keywords...\n", i);
add(tree, key);
printf("ADDING: %s\n", key);
- DOODLE_tree_dump(stdout, tree);
+ DOODLE_tree_dump(stdout, tree);
}
fclose(in);
Modified: doodle/src/doodle/proftree.c
===================================================================
--- doodle/src/doodle/proftree.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/proftree.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -37,7 +37,7 @@
#define DBNAME "/tmp/doodle-tree-test"
#define DEPTH 6
-#define DIST 4
+#define DIST 4
#define COUNT 100000
@@ -59,16 +59,16 @@
if (level == 0) {
va_start(args, msg);
vfprintf(stdout, msg, args);
- va_end(args);
+ va_end(args);
}
}
/**
* Complete filename (a la shell) from abbrevition.
- * @param fil the name of the file, may contain ~/ or
+ * @param fil the name of the file, may contain ~/ or
* be relative to the current directory
- * @returns the full file name,
+ * @returns the full file name,
* NULL is returned on error
*/
static char * expandFileName(const char * fil) {
@@ -99,9 +99,9 @@
/* do not copy '~' */
fil_ptr = fil + 1;
- /* skip over dir seperator to be consistent */
- if (fil_ptr[0] == DIR_SEPARATOR)
- fil_ptr++;
+ /* skip over dir seperator to be consistent */
+ if (fil_ptr[0] == DIR_SEPARATOR)
+ fil_ptr++;
} else {
fil_ptr = fil;
if (getcwd(buffer, 512) != NULL)
@@ -110,7 +110,7 @@
fm = "$PWD";
}
fn = MALLOC(strlen(fm) + 1 + strlen(fil_ptr) + 1);
-
+
sprintf(fn, "%s/%s", fm, fil_ptr);
#else
fn = MALLOC(MAX_PATH + 1);
@@ -122,7 +122,7 @@
return NULL;
}
/* is the path relative? */
- if ((strncmp(buffer + 1, ":\\", 2) != 0) &&
+ if ((strncmp(buffer + 1, ":\\", 2) != 0) &&
(strncmp(buffer, "\\\\", 2) != 0))
{
char szCurDir[MAX_PATH + 1];
@@ -130,7 +130,7 @@
if (lRet + strlen(fn) + 1 > (_MAX_PATH + 1))
{
SetErrnoFromWinError(ERROR_BUFFER_OVERFLOW);
-
+
return NULL;
}
sprintf(fn, "%s\\%s", szCurDir, buffer);
@@ -141,7 +141,7 @@
}
#endif
return fn;
-}
+}
int main(int argc,
char * argv[]) {
@@ -173,13 +173,13 @@
astring[j++]++;
} while (astring[j-1] == 'H');
j--;
- while (j > 0)
- astring[--j] = 'A';
+ while (j > 0)
+ astring[--j] = 'A';
if (0 != DOODLE_tree_expand(tree,
astring,
exp))
- ABORT();
+ ABORT();
}
time(&end);
printf("%d expansions took %us.\n",
@@ -190,7 +190,7 @@
bstring[i] = 'A';
bstring[DEPTH+DIST] = '\0';
time(&start);
- for (i=0;i<COUNT;i++)
+ for (i=0;i<COUNT;i++)
if (0 != DOODLE_tree_search(tree,
bstring,
NULL,
@@ -200,10 +200,10 @@
printf("%d (cached) searches took %us.\n",
COUNT,
(unsigned int) (end - start));
-
+
for (j=0;j<DIST-1;j++) {
time(&start);
- for (i=0;i<COUNT;i++)
+ for (i=0;i<COUNT;i++)
if (0 != DOODLE_tree_search_approx(tree,
j,
0,
Modified: doodle/src/doodle/proftree2.c
===================================================================
--- doodle/src/doodle/proftree2.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/proftree2.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -63,7 +63,7 @@
if (level == 0) {
va_start(args, msg);
vfprintf(stdout, msg, args);
- va_end(args);
+ va_end(args);
}
}
@@ -81,7 +81,7 @@
test[SIZE] = '\0';
for (i=SIZE-1;i>=0;i--)
test[i] = 'A' + (lrand48() % 26);
-
+
unlink(DBNAME);
time(&start);
tree = DOODLE_tree_create(&my_log,
Modified: doodle/src/doodle/proftree3.c
===================================================================
--- doodle/src/doodle/proftree3.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/proftree3.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -61,11 +61,11 @@
const char * msg,
...) {
va_list args;
- if ( (0) ||
+ if ( (0) ||
(level == 0) ) {
va_start(args, msg);
vfprintf(stdout, msg, args);
- va_end(args);
+ va_end(args);
}
}
@@ -89,15 +89,15 @@
DBNAME,
rand() % FILECOUNT);
fclose(fopen(fn, "a+"));
-
+
if ((rand() % 100) == 0) {
DOODLE_tree_truncate(tree,
fn);
} else {
memset(test, 0, SIZE+1);
- for (j=rand() % SIZE;j>=0;j--)
+ for (j=rand() % SIZE;j>=0;j--)
test[j] = 'A' + (rand() % 26);
-
+
DOODLE_tree_expand(tree,
test,
fn);
Modified: doodle/src/doodle/semaphore.c
===================================================================
--- doodle/src/doodle/semaphore.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/semaphore.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -22,7 +22,7 @@
* @file doodle/semaphore.c
* @brief functions related to threading and synchronization
*
- * In particular, functions for mutexes, semaphores
+ * In particular, functions for mutexes, semaphores
* and thread creation are provided.
*/
@@ -78,14 +78,14 @@
/**
- * Shall we use error-checking (slow)
+ * Shall we use error-checking (slow)
* mutexes (e.g. for debugging)
*/
#define USE_CHECKING_MUTEX 1
typedef struct {
-#if SOLARIS
+#if SOLARIS
sem_t * internal;
#elif LINUX
int internal;
@@ -133,7 +133,7 @@
#if WINDOWS
attr = NULL;
#endif
-
+
pthread_mutexattr_init(&attr);
#if USE_CHECKING_MUTEX
#if LINUX
@@ -156,7 +156,7 @@
pthread_mutexattr_init(&attr);
#if LINUX
GNUNET_ASSERT(0 == pthread_mutexattr_setkind_np
- (&attr,
+ (&attr,
PTHREAD_MUTEX_RECURSIVE_NP));
#elif SOMEBSD
GNUNET_ASSERT(0 == pthread_mutexattr_setkind_np
@@ -232,7 +232,7 @@
abort();
if (ret == EPERM)
abort();
- }
+ }
}
/**
@@ -277,9 +277,9 @@
pthread_cond_t * cond;
cond = s->cond;
- MUTEX_LOCK(&(s->mutex));
+ MUTEX_LOCK(&(s->mutex));
(s->v)++;
- value_after_op = s->v;
+ value_after_op = s->v;
GNUNET_ASSERT(0 == pthread_cond_signal(cond));
MUTEX_UNLOCK(&(s->mutex));
return value_after_op;
@@ -295,7 +295,7 @@
int value_after_op;
int return_value;
pthread_cond_t * cond;
-
+
cond = s->cond;
MUTEX_LOCK(&(s->mutex));
while (s->v <= 0) {
@@ -305,7 +305,7 @@
}
(s->v)--;
value_after_op = s->v;
- MUTEX_UNLOCK(&(s->mutex));
+ MUTEX_UNLOCK(&(s->mutex));
return value_after_op;
}
@@ -323,7 +323,7 @@
return SYSERR;
}
(s->v)--;
- MUTEX_UNLOCK(&(s->mutex));
+ MUTEX_UNLOCK(&(s->mutex));
return OK;
}
@@ -370,10 +370,10 @@
* @param handle handle to the pthread (for detaching, join)
* @param main the main method of the thread
* @param arg the argument to main
- * @param stackSize the size of the stack of the thread in bytes.
- * Note that if the stack overflows, some OSes (seen under BSD)
+ * @param stackSize the size of the stack of the thread in bytes.
+ * Note that if the stack overflows, some OSes (seen under BSD)
* will just segfault and gdb will give a messed-up stacktrace.
- * @return see pthread_create
+ * @return see pthread_create
*/
int PTHREAD_CREATE(PTHREAD_T * pt,
PThreadMain main,
@@ -391,10 +391,10 @@
pthread_attr_init(&stack_size_custom_attr);
pthread_attr_setstacksize(&stack_size_custom_attr,
stackSize);
- ret = pthread_create(handle,
+ ret = pthread_create(handle,
&stack_size_custom_attr,
- main,
- arg);
+ main,
+ arg);
if (ret != 0) {
FREE(handle);
pt->internal = NULL;
@@ -412,7 +412,7 @@
handle = pt->internal;
GNUNET_ASSERT(handle != NULL);
switch ((k=pthread_join(*handle, ret))) {
- case 0:
+ case 0:
FREE(handle);
pt->internal = NULL;
return;
Modified: doodle/src/doodle/semaphore.h
===================================================================
--- doodle/src/doodle/semaphore.h 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/semaphore.h 2005-03-20 23:55:26 UTC (rev 465)
@@ -23,7 +23,7 @@
* @file doodle/semaphore.h
* @brief functions related to threading and synchronization
*
- * In particular, functions for mutexes, semaphores
+ * In particular, functions for mutexes, semaphores
* and thread creation are provided.
*/
@@ -46,10 +46,10 @@
/**
- * @brief Structure for MUTual EXclusion (Mutex).
+ * @brief Structure for MUTual EXclusion (Mutex).
*
* Essentially a wrapper around pthread_mutex_t.
- */
+ */
typedef struct Mutex {
void * internal;
} Mutex;
@@ -139,10 +139,10 @@
* @param handle handle to the pthread (for detaching, join)
* @param main the main method of the thread
* @param arg the argument to main
- * @param stackSize the size of the stack of the thread in bytes.
- * Note that if the stack overflows, some OSes (seen under BSD)
+ * @param stackSize the size of the stack of the thread in bytes.
+ * Note that if the stack overflows, some OSes (seen under BSD)
* will just segfault and gdb will give a messed-up stacktrace.
- * @return see pthread_create
+ * @return see pthread_create
*/
int PTHREAD_CREATE(PTHREAD_T * handle,
PThreadMain main,
@@ -160,19 +160,19 @@
/**
* While we must define these globally to make the
* compiler happy, always use the macros in the sources
- * instead!
+ * instead!
*/
void create_mutex_(Mutex * mutex);
void create_recursive_mutex_(Mutex * mutex);
void create_fast_mutex_(Mutex * mutex);
void destroy_mutex_(Mutex * mutex);
-void mutex_lock_(Mutex * mutex,
+void mutex_lock_(Mutex * mutex,
const char * filename,
const int linenumber);
-void mutex_unlock_(Mutex * mutex,
+void mutex_unlock_(Mutex * mutex,
const char * filename,
const int linenumber);
-Semaphore * semaphore_new_(int value,
+Semaphore * semaphore_new_(int value,
const char * filename,
const int linenumber);
void semaphore_free_(Semaphore * s,
@@ -186,5 +186,5 @@
const int linenumber);
int semaphore_up_(Semaphore * s,
const char * filename,
- const int linenumber);
+ const int linenumber);
#endif
Modified: doodle/src/doodle/shutdown.c
===================================================================
--- doodle/src/doodle/shutdown.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/shutdown.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -47,7 +47,7 @@
/* printf("Shutdown handler %d\n", signum); */
if (shutdown_signal != NULL) {
shutdown_active = 1;
- SEMAPHORE_UP(shutdown_signal);
+ SEMAPHORE_UP(shutdown_signal);
}
}
@@ -66,7 +66,7 @@
case CTRL_LOGOFF_EVENT:
run_shutdown(1);
}
-
+
return TRUE;
}
#endif
@@ -91,7 +91,7 @@
if (shutdown_signal != NULL)
abort(); /* initializeShutdownHandlers called twice! */
- shutdown_signal = SEMAPHORE_NEW(0);
+ shutdown_signal = SEMAPHORE_NEW(0);
shutdown_active = 0;
#ifndef MINGW
sig.sa_handler = &run_shutdown;
@@ -100,7 +100,7 @@
sig.sa_flags = SA_INTERRUPT; /* SunOS */
#else
sig.sa_flags = SA_RESTART;
-#endif
+#endif
sigaction(SIGINT, &sig, &oldsig);
sigaction(SIGTERM, &sig, &oldsig);
sigaction(SIGQUIT, &sig, &oldsig);
Modified: doodle/src/doodle/testio.c
===================================================================
--- doodle/src/doodle/testio.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/testio.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -37,7 +37,7 @@
va_list args;
va_start(args, msg);
vfprintf(stdout, msg, args);
- va_end(args);
+ va_end(args);
if (level == DOODLE_LOG_CRITICAL)
abort();
}
@@ -54,7 +54,7 @@
unlink("/tmp/doodle_bio_test");
fd = open("/tmp/doodle_bio_test",
- O_CREAT | O_EXCL | O_RDWR,
+ O_CREAT | O_EXCL | O_RDWR,
S_IRWXU);
if (fd == -1) {
printf("Open failed: %s\n",
@@ -92,7 +92,7 @@
READUINT(bio, &v1);
if (v1 != i*i)
return -1;
- }
+ }
IO_FREE(bio);
#define EVAL 0
#if EVAL
Modified: doodle/src/doodle/testtree.c
===================================================================
--- doodle/src/doodle/testtree.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/testtree.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -51,7 +51,7 @@
void * arg) {
if (0 != strcmp(fn->filename,
DBNAME)) {
- printf("Assertion failed at %s:%d\n", __FILE__, __LINE__);
+ printf("Assertion failed at %s:%d\n", __FILE__, __LINE__);
abort();
}
}
@@ -69,16 +69,16 @@
if (level == 0) {
va_start(args, msg);
vfprintf(stdout, msg, args);
- va_end(args);
+ va_end(args);
}
}
/**
* Complete filename (a la shell) from abbrevition.
- * @param fil the name of the file, may contain ~/ or
+ * @param fil the name of the file, may contain ~/ or
* be relative to the current directory
- * @returns the full file name,
+ * @returns the full file name,
* NULL is returned on error
*/
static char * expandFileName(const char * fil) {
@@ -109,9 +109,9 @@
/* do not copy '~' */
fil_ptr = fil + 1;
- /* skip over dir seperator to be consistent */
- if (fil_ptr[0] == DIR_SEPARATOR)
- fil_ptr++;
+ /* skip over dir seperator to be consistent */
+ if (fil_ptr[0] == DIR_SEPARATOR)
+ fil_ptr++;
} else {
fil_ptr = fil;
if (getcwd(buffer, 512) != NULL)
@@ -120,7 +120,7 @@
fm = "$PWD";
}
fn = MALLOC(strlen(fm) + 1 + strlen(fil_ptr) + 1);
-
+
sprintf(fn, "%s/%s", fm, fil_ptr);
#else
fn = MALLOC(MAX_PATH + 1);
@@ -132,7 +132,7 @@
return NULL;
}
/* is the path relative? */
- if ((strncmp(buffer + 1, ":\\", 2) != 0) &&
+ if ((strncmp(buffer + 1, ":\\", 2) != 0) &&
(strncmp(buffer, "\\\\", 2) != 0))
{
char szCurDir[MAX_PATH + 1];
@@ -140,7 +140,7 @@
if (lRet + strlen(fn) + 1 > (_MAX_PATH + 1))
{
SetErrnoFromWinError(ERROR_BUFFER_OVERFLOW);
-
+
return NULL;
}
sprintf(fn, "%s\\%s", szCurDir, buffer);
@@ -156,7 +156,7 @@
int main(int argc,
char * argv[]) {
struct DOODLE_SuffixTree * tree;
- unsigned int nc;
+ unsigned int nc;
char * exp;
exp = expandFileName(argv[0]);
@@ -213,8 +213,8 @@
if (0 != DOODLE_tree_search(tree,
"bcd",
NULL,
- NULL))
- ABORT();
+ NULL))
+ ABORT();
if (0 != DOODLE_tree_truncate(tree,
exp))
ABORT();
@@ -244,24 +244,24 @@
NULL,
NULL))
ABORT();
-
+
if (1 != DOODLE_tree_search_approx(tree,
1,
0,
"xyz",
NULL,
NULL))
- ABORT();
+ ABORT();
if (1 != DOODLE_tree_search_approx(tree,
1,
0,
"xz",
NULL,
NULL))
- ABORT();
+ ABORT();
if (1 != DOODLE_tree_search_approx(tree,
1,
- 0,
+ 0,
"xYxz",
(DOODLE_ResultCallback)&checkFN,
NULL))
@@ -273,8 +273,8 @@
NULL,
NULL))
ABORT();
-
- DOODLE_tree_destroy(tree);
+
+ DOODLE_tree_destroy(tree);
unlink(DBNAME);
tree = DOODLE_tree_create(&my_log,
NULL,
Modified: doodle/src/doodle/testtree2.c
===================================================================
--- doodle/src/doodle/testtree2.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/testtree2.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -54,7 +54,7 @@
if (level == 0) {
va_start(args, msg);
vfprintf(stdout, msg, args);
- va_end(args);
+ va_end(args);
}
}
@@ -94,7 +94,7 @@
static void testEquals(const DOODLE_FileInfo * fi,
void * arg) {
if (0 == strcmp(fi->filename,
- (char*) arg))
+ (char*) arg))
found = 1;
}
@@ -128,7 +128,7 @@
"zardine",
"zardine",
"zardine",
- "zardine",
+ "zardine",
NULL,
};
@@ -139,7 +139,7 @@
i = 0;
while (testStrings[i] != NULL) {
/*fprintf(stderr, "Adding %s:\n", testStrings[i]);*/
- add(tree, testStrings[i++]);
+ add(tree, testStrings[i++]);
/* DOODLE_tree_dump(stderr, tree); */
}
Modified: doodle/src/doodle/testtree3.c
===================================================================
--- doodle/src/doodle/testtree3.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/testtree3.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -54,7 +54,7 @@
if (level == 0) {
va_start(args, msg);
vfprintf(stdout, msg, args);
- va_end(args);
+ va_end(args);
}
}
@@ -94,7 +94,7 @@
static void testEquals(const DOODLE_FileInfo * fi,
void * arg) {
if (0 == strcmp(fi->filename,
- (char*) arg))
+ (char*) arg))
found = 1;
}
@@ -109,7 +109,7 @@
NULL,
};
static char * testStrings2[] = {
- "zardine",
+ "zardine",
NULL,
};
@@ -118,8 +118,8 @@
NULL,
DBNAME);
i = 0;
- while (testStrings[i] != NULL)
- add(tree, testStrings[i++]);
+ while (testStrings[i] != NULL)
+ add(tree, testStrings[i++]);
/* full serialization / deserialization */
DOODLE_tree_destroy(tree);
@@ -127,7 +127,7 @@
NULL,
DBNAME);
- /* truncate! */
+ /* truncate! */
if (0 != DOODLE_tree_truncate(tree,
records->fn))
ABORT();
@@ -146,11 +146,11 @@
next = records->next;
free(records);
records = next;
-
+
i = 0;
- while (testStrings2[i] != NULL)
- add(tree, testStrings2[i++]);
-
+ while (testStrings2[i] != NULL)
+ add(tree, testStrings2[i++]);
+
/* full serialization / deserialization */
DOODLE_tree_destroy(tree);
tree = DOODLE_tree_create(&my_log,
@@ -169,7 +169,7 @@
DOODLE_tree_dump(stderr,
tree);
ABORT();
- }
+ }
unlink(records->fn);
free(records->fn);
free(records);
Modified: doodle/src/doodle/testtree4.c
===================================================================
--- doodle/src/doodle/testtree4.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/testtree4.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -60,16 +60,16 @@
if (level == 0) {
va_start(args, msg);
vfprintf(stdout, msg, args);
- va_end(args);
+ va_end(args);
}
}
/**
* Complete filename (a la shell) from abbrevition.
- * @param fil the name of the file, may contain ~/ or
+ * @param fil the name of the file, may contain ~/ or
* be relative to the current directory
- * @returns the full file name,
+ * @returns the full file name,
* NULL is returned on error
*/
static char * expandFileName(const char * fil) {
@@ -100,9 +100,9 @@
/* do not copy '~' */
fil_ptr = fil + 1;
- /* skip over dir seperator to be consistent */
- if (fil_ptr[0] == DIR_SEPARATOR)
- fil_ptr++;
+ /* skip over dir seperator to be consistent */
+ if (fil_ptr[0] == DIR_SEPARATOR)
+ fil_ptr++;
} else {
fil_ptr = fil;
if (getcwd(buffer, 512) != NULL)
@@ -111,7 +111,7 @@
fm = "$PWD";
}
fn = MALLOC(strlen(fm) + 1 + strlen(fil_ptr) + 1);
-
+
sprintf(fn, "%s/%s", fm, fil_ptr);
#else
fn = MALLOC(MAX_PATH + 1);
@@ -123,7 +123,7 @@
return NULL;
}
/* is the path relative? */
- if ((strncmp(buffer + 1, ":\\", 2) != 0) &&
+ if ((strncmp(buffer + 1, ":\\", 2) != 0) &&
(strncmp(buffer, "\\\\", 2) != 0))
{
char szCurDir[MAX_PATH + 1];
@@ -131,7 +131,7 @@
if (lRet + strlen(fn) + 1 > (_MAX_PATH + 1))
{
SetErrnoFromWinError(ERROR_BUFFER_OVERFLOW);
-
+
return NULL;
}
sprintf(fn, "%s\\%s", szCurDir, buffer);
@@ -147,7 +147,7 @@
int main(int argc,
char * argv[]) {
struct DOODLE_SuffixTree * tree;
- unsigned int nc;
+ unsigned int nc;
char * exp;
exp = expandFileName(argv[0]);
Modified: doodle/src/doodle/tree.c
===================================================================
--- doodle/src/doodle/tree.c 2005-03-20 23:54:53 UTC (rev 464)
+++ doodle/src/doodle/tree.c 2005-03-20 23:55:26 UTC (rev 465)
@@ -1,4 +1,4 @@
-/*
+/*
This file is part of doodle.
(C) 2004 Christian Grothoff (and other contributing authors)
@@ -69,7 +69,7 @@
#define USE_CI_CACHE 1
/**
- * Default memory limit.
+ * Default memory limit.
*
* Try not to use more than 8 MB for nodes. Note that additional
* memory will be used for various auxiliary datastructures (keywords
@@ -77,7 +77,7 @@
* expensive) to limit that memory. Also, hopefully, nodes are likely
* to be the bulk of the data. A smaller limit will result in more
* frequent serializations of the data from memory to disk while
- * indexing, which will result in both reduced performance and
+ * indexing, which will result in both reduced performance and
* increased disk space requirements (in effect, if we run above
* the limit k-times, we are going to serialize a certain portion of
* the tree k-times -- using fresh space each time. Worse, when
@@ -85,9 +85,9 @@
* memory. Hence it's best to be generous with the limit, and today
* I believe any reasonable machine has 8 MB to spare for that.
*
- * Note that even with an 8 MB limit here Doodle can still easily
+ * Note that even with an 8 MB limit here Doodle can still easily
* take 64 MB total (if the number of files and keywords is large
- * enough).
+ * enough).
*/
#ifndef MEMORY_LIMIT
#define MEMORY_LIMIT (8 * 1024 * 1024)
@@ -175,7 +175,7 @@
char * buf,
unsigned long long cnt) {
int ret;
- if (off != lseek(fd, off, SEEK_SET)) {
+ if (off != lseek(fd, off, SEEK_SET)) {
log(context,
DOODLE_LOG_CRITICAL,
_("Call to '%s' failed: %s\n"),
@@ -206,7 +206,7 @@
const char * buf,
unsigned long long cnt) {
int ret;
- if (off != lseek(fd, off, SEEK_SET)) {
+ if (off != lseek(fd, off, SEEK_SET)) {
log(context,
DOODLE_LOG_CRITICAL,
_("'%s' failed: %s\n"),
@@ -233,9 +233,9 @@
void * context,
int fd) {
BIO * bio;
- struct stat buf;
+ struct stat buf;
- if (0 != fstat(fd, &buf))
+ if (0 != fstat(fd, &buf))
log(context,
DOODLE_LOG_CRITICAL,
_("Call to '%s' failed: %s\n"),
@@ -314,13 +314,13 @@
len);
bio->off += len;
return ret;
- }
+ }
ret = 0;
if ( (bio->off < bio->bstart) ||
- (bio->off + len > bio->bstart + bio->bsize) )
+ (bio->off + len > bio->bstart + bio->bsize) )
ret = retarget_buffer(bio,
bio->off,
- len);
+ len);
if ( (bio->off < bio->bstart) ||
(bio->off + len > bio->bstart + bio->bsize) ) {
bio->log(bio->context,
@@ -345,7 +345,7 @@
bio->context,
bio->fd,
bio->off,
- buf,
+ buf,
len);
bio->off += len;
#else
@@ -361,7 +361,7 @@
return;
}
if ( (bio->off < bio->bstart) ||
- (bio->off != bio->bstart + bio->dirty) ||
+ (bio->off != bio->bstart + bio->dirty) ||
(bio->off + len > bio->bstart + BUF_SIZE) ) {
flush_buffer(bio);
bio->bsize = len;
@@ -396,7 +396,7 @@
}
static void IO_FREE(BIO * bio) {
- flush_buffer(bio);
+ flush_buffer(bio);
close(bio->fd);
free(bio->buffer);
free(bio);
@@ -411,9 +411,9 @@
return -1;
if ( (c > 4) || (c < 0) ) {
fd->log(fd->context,
- DOODLE_LOG_CRITICAL,
+ DOODLE_LOG_CRITICAL,
_("Assertion failed at %s:%d.\nDatabase format error!\n"),
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
return -1;
}
*val = 0;
@@ -433,9 +433,9 @@
return -1;
if ( (c > 8) || (c < 0) ) {
fd->log(fd->context,
- DOODLE_LOG_CRITICAL,
+ DOODLE_LOG_CRITICAL,
_("Assertion failed at %s:%d.\nDatabase format error!\n"),
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
return -1;
}
*val = 0;
@@ -527,10 +527,10 @@
WRITEALL(fd, &c, sizeof(unsigned char));
for (d=(c&15)-1;d>=0;d--)
v[(unsigned char)d] = (unsigned char) (val2 >> (8*d));
- WRITEALL(fd, &v[0], (unsigned char) c & 15);
+ WRITEALL(fd, &v[0], (unsigned char) c & 15);
for (d=(c>>4)-1;d>=0;d--)
v[(unsigned char)d] = (unsigned char) (val1 >> (8*d));
- WRITEALL(fd, &v[0], (unsigned char) c >> 4);
+ WRITEALL(fd, &v[0], (unsigned char) c >> 4);
}
static void WRITEULONGPAIR(BIO * fd,
@@ -556,10 +556,10 @@
WRITEALL(fd, &c, sizeof(unsigned char));
for (d=(c&15)-1;d>=0;d--)
v[(unsigned char)d] = (unsigned char) (val2 >> (8*d));
- WRITEALL(fd, &v[0], (unsigned char) c & 15);
+ WRITEALL(fd, &v[0], (unsigned char) c & 15);
for (d=(c>>4)-1;d>=0;d--)
v[(unsigned char)d] = (unsigned char) (val1 >> (8*d));
- WRITEALL(fd, &v[0], (unsigned char) c >> 4);
+ WRITEALL(fd, &v[0], (unsigned char) c >> 4);
}
static void WRITEUINT(BIO * fd,
@@ -578,7 +578,7 @@
WRITEALL(fd, &c, sizeof(char));
for (d=c-1;d>=0;d--)
v[(unsigned char)d] = (unsigned char) (xval >> (8*d));
- WRITEALL(fd, &v[0], (int) c);
+ WRITEALL(fd, &v[0], (int) c);
}
static void WRITEULONG(BIO * fd,
@@ -597,7 +597,7 @@
WRITEALL(fd, &c, sizeof(char));
for (d=c-1;d>=0;d--)
v[(unsigned char)d] = (unsigned char) (xval >> (8*d));
- WRITEALL(fd, &v[0], (int) c);
+ WRITEALL(fd, &v[0], (int) c);
}
static char * readZT(BIO * fd) {
@@ -698,10 +698,10 @@
*
* @brief a node in the doodle suffix tree
*/
-typedef struct DOODLE_Node {
+typedef struct DOODLE_Node {
/* if link == NULL and link_off != 0, then
the link exists but is still on-disk */
- unsigned long long link_off;
+ unsigned long long link_off;
/* ifchild == NULL and next_off != 0, then
the child exists but is still on-disk */
unsigned long long next_off;
@@ -717,7 +717,7 @@
pointer into tree->cis. */
unsigned char * c;
/* list of indices into tree->filenames */
- unsigned int * matches;
+ unsigned int * matches;
/* how many files match here? */
unsigned int matchCount;
#if USE_CI_CACHE
@@ -754,7 +754,7 @@
/* number of entries used in filenames array */
unsigned int fnc;
/* interned filenames from entire tree */
- DOODLE_FileInfo * filenames;
+ DOODLE_FileInfo * filenames;
/* root of the suffix tree, maybe null! */
STNode * root;
/* the keyword/character index string */
@@ -763,11 +763,11 @@
unsigned int cisPos;
/* how much space do we have in cis? */
unsigned int cisLen;
- /* was this suffix tree modified? 1: yes, 0: no */
- int modified;
- /* force full dump (even of unmodified nodes)? 1: yes, 0: no */
- int force_dump;
- /* how much memory is used at the moment for the tree?
+ /* was this suffix tree modified? 1: yes, 0: no */
+ int modified;
+ /* force full dump (even of unmodified nodes)? 1: yes, 0: no */
+ int force_dump;
+ /* how much memory is used at the moment for the tree?
(excluding filenames, cis, matches; just Nodes!) */
size_t used_memory;
/* memory limit */
@@ -790,31 +790,31 @@
}
static unsigned char CIS[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
- 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
- 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
- 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
- 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
- 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
- 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
- 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
- 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
+ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
+ 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
+ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
+ 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
+ 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
+ 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+ 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+ 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
+ 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
- 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
- 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
- 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
- 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
- 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
+ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
+ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
+ 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
+ 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255,
};
@@ -863,17 +863,17 @@
if (node[mls].child != NULL) {
tmp = node[mls].child;
node[mls].child = NULL;
- freeNode(tree, tmp);
+ freeNode(tree, tmp);
}
if (node[mls].matches != NULL)
- free(node[mls].matches);
- }
+ free(node[mls].matches);
+ }
last = node;
- node = node[last->mls_size-1].link;
+ node = node[last->mls_size-1].link;
tree->used_memory -= sizeof(STNode) * last->mls_size;
free(last);
- }
+ }
}
/**
@@ -886,8 +886,8 @@
/**
* Shrink the given subtree of tree starting at node pos.
* The ktC index into keepThese describes the next node
- * that must not be freed since it is referenced from
- * the calling context.
+ * that must not be freed since it is referenced from
+ * the calling context.
*/
static void processShrink(SuffixTree * tree,
STNode ** keepThese,
@@ -903,7 +903,7 @@
next = NULL;
mark = 0;
if (ktP >= 0) {
- if (pos->link == keepThese[ktP])
+ if (pos->link == keepThese[ktP])
mark |= 1;
if (pos->child == keepThese[ktP])
mark |= 2;
@@ -922,7 +922,7 @@
abort();
}
#endif
- if ( ( (mark & 1) == 0) &&
+ if ( ( (mark & 1) == 0) &&
(pos->link != NULL) &&
(pos->link->mls_size == 1) &&
(pos->mls_size == 1) ) {
@@ -966,22 +966,22 @@
continue;
}
- if ( ( (mark & 2) == 0) &&
+ if ( ( (mark & 2) == 0) &&
(pos->child != NULL) ) {
/* we are allowed to swap, do we want to? */
if ( (pos->child->useCounter <= tree->swapLimit) &&
( (0 == tree->read_only) ||
(pos->child->modified == 0) ) ) {
- if ( (tree->force_dump != 0) ||
+ if ( (tree->force_dump != 0) ||
(pos->child->modified != 0) ) {
pos->next_off = writeNode(tree->fd,
tree,
pos->child);
- }
+ }
freeNode(tree,
pos->child);
pos->child = NULL;
- CHECK(tree);
+ CHECK(tree);
pos = NULL;
} else {
pos->child->useCounter = 0;
@@ -997,7 +997,7 @@
}
CHECK(tree);
}
-
+
/**
* Reduce the memory consumption by dumping unused portions of
* the suffix tree to disk.
@@ -1021,7 +1021,7 @@
tree->mutationCount = 0;
tree->log(tree->context,
DOODLE_LOG_VERY_VERBOSE,
- _("Memory limit (%u bytes) hit, serializing some data.\n"),
+ _("Memory limit (%u bytes) hit, serializing some data.\n"),
tree->used_memory);
pos = keep;
keepThese = NULL;
@@ -1082,15 +1082,15 @@
if (off == 0)
return NULL;
LSEEK(tree->fd, off, SEEK_SET);
- if (-1 == READALL(tree->fd,
- &c_length,
+ if (-1 == READALL(tree->fd,
+ &c_length,
sizeof(char)))
- return NULL;
+ return NULL;
if (c_length == 0) {
- if (-1 == READALL(tree->fd,
- &mls_size,
+ if (-1 == READALL(tree->fd,
+ &mls_size,
sizeof(char)))
- return NULL;
+ return NULL;
if (mls_size == 0) { /* not legal! */
tree->log(tree->context,
DOODLE_LOG_CRITICAL,
@@ -1111,27 +1111,27 @@
ret[mls].mls_size = (unsigned char) (mls_size - mls);
if (mls > 0) {
ret[mls-1].link_off = 0;
- ret[mls-1].link = &ret[mls];
+ ret[mls-1].link = &ret[mls];
ret[mls].parent = &ret[mls-1];
- }
-
+ }
+
if (ret[mls].clength == 0) {
unsigned char c;
if (mls == 0) {
- if (-1 == READALL(tree->fd, &c, sizeof(unsigned char)))
+ if (-1 == READALL(tree->fd, &c, sizeof(unsigned char)))
goto ERROR_ABORT;
} else {
c = ret[mls-1].c[0] + 1;
}
ret[mls].c = &CIS[(unsigned char) c];
- ret[mls].clength = 1;
+ ret[mls].clength = 1;
} else {
unsigned int cix;
unsigned int ciy;
- if (-1 == READUINTPAIR(tree->fd, &cix, &ciy))
+ if (-1 == READUINTPAIR(tree->fd, &cix, &ciy))
goto ERROR_ABORT;
- if ( (cix >= tree->cisLen) ||
+ if ( (cix >= tree->cisLen) ||
(ciy >= strlen(tree->cis[cix])) ) {
tree->log(tree->context,
DOODLE_LOG_CRITICAL,
@@ -1145,13 +1145,13 @@
#endif
}
- if (mls == mls_size-1) {
- if (-1 == READULONGPAIR(tree->fd, &off_link, &off_child))
+ if (mls == mls_size-1) {
+ if (-1 == READULONGPAIR(tree->fd, &off_link, &off_child))
goto ERROR_ABORT;
/* off_link and off_child are serialized relative
to off and negative (since child and link are
- always stored before off in the file).
- ASSERT and compute the absolute offsets. */
+ always stored before off in the file).
+ ASSERT and compute the absolute offsets. */
if ( (off_link > off) ||
(off_child > off) ) {
tree->log(tree->context,
@@ -1166,12 +1166,12 @@
off_child = off - off_child;
} else {
off_link = 0; /* to be set in the next iteration! */
- if (-1 == READULONG(tree->fd, &off_child))
+ if (-1 == READULONG(tree->fd, &off_child))
goto ERROR_ABORT;
/* off_child is serialized relative
to off and negative (since child and link are
- always stored before off in the file).
- ASSERT and compute the absolute offsets. */
+ always stored before off in the file).
+ ASSERT and compute the absolute offsets. */
if (off_child > off) {
tree->log(tree->context,
DOODLE_LOG_CRITICAL,
@@ -1182,7 +1182,7 @@
off_child = off - off_child;
}
ret[mls].link_off = off_link;
- ret[mls].next_off = off_child;
+ ret[mls].next_off = off_child;
if ( (ret[mls].link_off > tree->fd->fsize) ||
(ret[mls].next_off > tree->fd->fsize) ) {
@@ -1193,19 +1193,19 @@
goto ERROR_ABORT;
}
- if (-1 == READUINT(tree->fd, &ret[mls].matchCount))
+ if (-1 == READUINT(tree->fd, &ret[mls].matchCount))
goto ERROR_ABORT;
if (ret[mls].matchCount == 0) {
ret[mls].matches = NULL;
} else {
- ret[mls].matches
+ ret[mls].matches
= MALLOC(ret[mls].matchCount*sizeof(unsigned int));
for (i=ret[mls].matchCount/2-1;i>=0;i--) {
unsigned int idx1;
unsigned int idx2;
if (-1 == READUINTPAIR(tree->fd,
&idx1,
- &idx2))
+ &idx2))
goto ERROR_ABORT;
if (idx1 >= tree->fnc) {
tree->log(tree->context,
@@ -1226,7 +1226,7 @@
}
if (1 == (ret[mls].matchCount & 1) ) {
unsigned int idx;
- if (-1 == READUINT(tree->fd, &idx))
+ if (-1 == READUINT(tree->fd, &idx))
goto ERROR_ABORT;
if ( idx >= tree->fnc ) {
tree->log(tree->context,
@@ -1240,7 +1240,7 @@
}
} /* end for mls */
#if DEBUG > 1
- printf("%llu: Read %u-Node (%c, %u, %u, %u) L:%llu, C:%llu until %llu\n",
+ printf("%llu: Read %u-Node (%c, %u, %u, %u) L:%llu, C:%llu until %llu\n",
off,
ret->mls_size,
ret->c[0],
@@ -1254,7 +1254,7 @@
tree->used_memory += sizeof(STNode) * mls_size;
return ret;
ERROR_ABORT:
- for (mls=0;mls<mls_size;mls++)
+ for (mls=0;mls<mls_size;mls++)
if (ret[mls].matches != NULL)
free(ret[mls].matches);
free(ret);
@@ -1270,8 +1270,8 @@
#endif
return -1;
}
- if (tree->used_memory > tree->memory_limit)
- shrinkMemoryFootprint(tree, node);
+ if (tree->used_memory > tree->memory_limit)
+ shrinkMemoryFootprint(tree, node);
node->child = lazyReadNode(tree,
node->next_off);
if (node->child == NULL) {
@@ -1293,8 +1293,8 @@
#endif
return -1;
}
- if (tree->used_memory > tree->memory_limit)
- shrinkMemoryFootprint(tree, node);
+ if (tree->used_memory > tree->memory_limit)
+ shrinkMemoryFootprint(tree, node);
node->link = lazyReadNode(tree,
node->link_off);
@@ -1331,29 +1331,29 @@
if ( (node[mls].child == NULL) &&
(node[mls].next_off != 0) &&
(tree->force_dump != 0) )
- loadChild(tree, &node[mls]);
+ loadChild(tree, &node[mls]);
if ( (node[mls].child != NULL) &&
( (node[mls].child->modified != 0) ||
(tree->force_dump != 0) ) )
- node[mls].next_off
- = writeNode(fd,
- tree,
+ node[mls].next_off
+ = writeNode(fd,
+ tree,
node[mls].child);
}
if ( (node[node->mls_size-1].link == NULL) &&
(node[node->mls_size-1].link_off != 0) &&
- (tree->force_dump != 0) ) {
- loadLink(tree, &node[node->mls_size-1]);
+ (tree->force_dump != 0) ) {
+ loadLink(tree, &node[node->mls_size-1]);
}
if ( (node[node->mls_size-1].link != NULL) &&
( (node[node->mls_size-1].link->modified != 0) ||
(tree->force_dump != 0) ) ) {
- node[node->mls_size-1].link_off
- = writeNode(fd,
- tree,
+ node[node->mls_size-1].link_off
+ = writeNode(fd,
+ tree,
node[node->mls_size-1].link);
}
- ret = LSEEK(fd, 0, SEEK_END);
+ ret = LSEEK(fd, 0, SEEK_END);
#if ASSERTS
if (node->clength == 0) {
/* clength must not be 0! */
@@ -1380,21 +1380,21 @@
abort();
return 0;
}
-
+
if (node->clength == 1) {
unsigned char o = 0;
WRITEALL(fd, &o, sizeof(unsigned char));
- WRITEALL(fd, &node->mls_size, sizeof(unsigned char));
+ WRITEALL(fd, &node->mls_size, sizeof(unsigned char));
WRITEALL(fd, node->c, sizeof(unsigned char));
} else {
int cix;
int ciy;
- WRITEALL(fd, &node->clength, sizeof(unsigned char));
+ WRITEALL(fd, &node->clength, sizeof(unsigned char));
#if USE_CI_CACHE
cix = node->cix;
ciy = node->c - tree->cis[node->cix];
-#else
+#else
cix = -1;
ciy = -1;
for (i=0;i<tree->cisPos;i++) {
@@ -1427,7 +1427,7 @@
tree->log(tree->context,
DOODLE_LOG_CRITICAL,
_("Assertion failed at %s:%d.\n"),
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
}
#endif
if (node[mls].link_off != 0)
@@ -1447,34 +1447,34 @@
tree->log(tree->context,
DOODLE_LOG_CRITICAL,
_("Assertion failed at %s:%d.\n"),
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
}
#endif
nextRel = ret - node[mls].next_off;
- WRITEULONG(fd, nextRel);
- }
+ WRITEULONG(fd, nextRel);
+ }
WRITEUINT(fd, node[mls].matchCount);
for (i=node[mls].matchCount/2-1;i>=0;i--) {
unsigned int idx1;
unsigned int idx2;
-
+
idx1 = node[mls].matches[i*2+1];
idx2 = node[mls].matches[i*2];
WRITEUINTPAIR(fd,
idx1,
- idx2);
+ idx2);
}
if (1 == (node[mls].matchCount & 1) ) {
unsigned int idx;
-
+
idx = node[mls].matches[node[mls].matchCount-1];
WRITEUINT(fd,
- idx);
+ idx);
}
} /* for mls */
#if DEBUG > 1
- printf("%llu: Wrote %u-node (%c, %u, %u, %u) L:%llu, C:%llu until %llu\n",
+ printf("%llu: Wrote %u-node (%c, %u, %u, %u) L:%llu, C:%llu until %llu\n",
ret,
node->mls_size,
node->c[0],
@@ -1482,7 +1482,7 @@
node->matchCount,
(node->matchCount > 0) ? node->matches[0] : -1,
node[node->mls_size-1].link_off,
- node->next_off,
+ node->next_off,
LSEEK(fd, 0, SEEK_CUR));
#endif
@@ -1505,23 +1505,23 @@
* currently always "0002" to indicate compatibility with doodle
* 0.2.0. ("0000" used SHA-1 instead of timestamps and is no longer
* supported; "0001" was never used (see TRAGIC)).
- *
+ *
* Doodle 0.5.0 is incompatible with 0.2.0 to 0.4.0, hence a new
* version number. The major differences are support for 64-bit
* offsets (which would allow reading an 0.4.0 db per-se), but
- * also relative file offsets (which reduces the DB size and
+ * also relative file offsets (which reduces the DB size and
* breaks compatibility even for DB-sizes smaller than 2^31).
*
* Doodle 0.6.0 is again incompatible with 0.5.0, this
* time introducing the 'mls' node groups (which has the potential
* to significantly improve performance).
- */
+ */
static char * MAGIC = "DOO\0000006";
/**
* Magic string to indicate an temporary doodle database that
* could not be completely created (the indexing/building process
- * was aborted).
+ * was aborted).
*/
static char * TRAGIC = "XOO\0000001";
@@ -1535,14 +1535,14 @@
int ifd;
BIO * fd;
SuffixTree * ret;
- struct stat buf;
+ struct stat buf;
int i;
unsigned long long off;
char ** pathTab;
unsigned int ptc;
char magic[8];
- ret = MALLOC(sizeof(SuffixTree));
+ ret = MALLOC(sizeof(SuffixTree));
ret->log = log;
ret->context = context;
ret->database = STRDUP(database);
@@ -1556,11 +1556,11 @@
if (0 == stat(database, &buf)) {
#ifdef O_LARGEFILE
- ifd = open(database,
+ ifd = open(database,
flags | O_LARGEFILE,
S_IRUSR | S_IWUSR | S_IRGRP);
#else
- ifd = open(database,
+ ifd = open(database,
flags,
S_IRUSR | S_IWUSR | S_IRGRP);
#endif
@@ -1586,11 +1586,11 @@
}
fd = IO_WRAP(log,
context,
- ifd);
+ ifd);
if (-1 == READALL(fd,
magic,
8)) {
- memcpy(magic,
+ memcpy(magic,
"garbage!",
8);
}
@@ -1610,14 +1610,14 @@
DOODLE_LOG_CRITICAL,
_("Could not unlink '%s': %s\n"),
database,
- strerror(errno));
+ strerror(errno));
fd = NULL;
goto FRESH_START;
} else {
log(context,
DOODLE_LOG_CRITICAL,
_("Database file '%s' has wrong magic code.\n"),
- database);
+ database);
IO_FREE(fd);
free(ret->database);
free(ret);
@@ -1661,7 +1661,7 @@
IO_FREE(fd);
return NULL;
}
- if (ret->fnc != 0) {
+ if (ret->fnc != 0) {
GROW(ret->filenames,
ret->fns,
ret->fnc);
@@ -1670,7 +1670,7 @@
pathTab,
ptc);
if (ret->filenames[i].filename == NULL) {
- while (i < ret->fnc-1)
+ while (i < ret->fnc-1)
free(ret->filenames[++i].filename);
GROW(ret->filenames,
ret->fns,
@@ -1690,7 +1690,7 @@
}
if (-1 == READUINT(fd,
&ret->filenames[i].mod_time)) {
- while (i < ret->fnc-1)
+ while (i < ret->fnc-1)
free(ret->filenames[++i].filename);
GROW(ret->filenames,
ret->fns,
@@ -1711,12 +1711,12 @@
free(pathTab);
}
if (-1 == READUINT(fd,
- &ret->cisPos)) {
+ &ret->cisPos)) {
GROW(ret->filenames,
ret->fns,
0);
free(ret->database);
- free(ret);
+ free(ret);
IO_FREE(fd);
}
ret->cisLen = ret->cisPos;
@@ -1734,7 +1734,7 @@
ret->fns,
0);
free(ret->database);
- free(ret);
+ free(ret);
IO_FREE(fd);
return NULL;
}
@@ -1742,16 +1742,16 @@
if (-1 == READALL(fd,
&off,
sizeof(unsigned int))) {
- for (i=ret->cisPos-1;i>=0;i--)
+ for (i=ret->cisPos-1;i>=0;i--)
free(ret->cis[++i]);
free(ret->cis);
GROW(ret->filenames,
ret->fns,
0);
free(ret->database);
- free(ret);
+ free(ret);
IO_FREE(fd);
- return NULL;
+ return NULL;
}
off = ntohl(off);
ret->fd = fd;
@@ -1769,11 +1769,11 @@
return NULL;
}
#ifdef O_LARGEFILE
- ifd = open(database,
+ ifd = open(database,
O_CREAT | flags | O_LARGEFILE,
S_IRUSR | S_IWUSR | S_IRGRP);
#else
- ifd = open(database,
+ ifd = open(database,
O_CREAT | flags,
S_IRUSR | S_IWUSR | S_IRGRP);
#endif
@@ -1795,7 +1795,7 @@
free(ret->database);
free(ret);
return NULL;
- }
+ }
ret->root = NULL;
ret->fnc = 0;
ret->fns = 0;
@@ -1821,7 +1821,7 @@
#endif
ret->modified = 1;
}
-
+
CHECK(ret);
return ret;
}
@@ -1839,12 +1839,12 @@
}
/**
- * Open an existing database READ-ONLY.
+ * Open an existing database READ-ONLY.
* @return NULL on error (i.e. DB does not exist)
*/
SuffixTree * DOODLE_tree_open_RDONLY(DOODLE_Logger log,
void * context,
- const char * database) {
+ const char * database) {
return DOODLE_tree_create_internal(log,
context,
database,
@@ -1855,7 +1855,7 @@
* Change the memory limit (how much memory the
* tree may use). Note that the limit only refers
* to the tree nodes, memory used for keywords and
- * filenames is excluded since the current code
+ * filenames is excluded since the current code
* does not support keeping those on disk.
*
* @param limit new memory limit in bytes
@@ -1863,8 +1863,8 @@
void DOODLE_tree_set_memory_limit(SuffixTree * tree,
size_t limit) {
tree->memory_limit = limit;
- if (tree->used_memory > tree->memory_limit)
- shrinkMemoryFootprint(tree, tree->root);
+ if (tree->used_memory > tree->memory_limit)
+ shrinkMemoryFootprint(tree, tree->root);
}
/**
@@ -1895,11 +1895,11 @@
strcat(tdatabase,
"~");
#ifdef O_LARGEFILE
- fdt = open(tdatabase,
+ fdt = open(tdatabase,
O_CREAT | O_TRUNC | O_RDWR | O_LARGEFILE,
S_IRUSR | S_IWUSR | S_IRGRP);
#else
- fdt = open(tdatabase,
+ fdt = open(tdatabase,
O_CREAT | O_TRUNC | O_RDWR,
S_IRUSR | S_IWUSR | S_IRGRP);
#endif
@@ -1911,7 +1911,7 @@
strerror(errno));
free(tdatabase);
goto CLEANUP;
- }
+ }
fd = IO_WRAP(tree->log,
tree->context,
fdt);
@@ -1929,17 +1929,17 @@
char * fn;
int slen;
int xslen;
-
+
fn = tree->filenames[i].filename;
slen = strlen(fn);
xslen = slen;
while ( (fn[slen] != '/') && (slen > 0) )
slen--;
- for (j=ptc-1;j>=0;j--)
+ for (j=ptc-1;j>=0;j--)
if ( (0 == strncmp(fn,
pathTab[j],
slen)) &&
- (slen == strlen(pathTab[j])) )
+ (slen == strlen(pathTab[j])) )
break;
if (j < 0) {
GROW(pathTab,
@@ -1951,14 +1951,14 @@
slen);
pathTab[ptc-1][slen] = '\0';
}
- }
+ }
/* write pathTab */
WRITEUINT(fd,
ptc);
for (i=ptc-1;i>=0;i--)
- writeZT(fd,
- pathTab[i]);
+ writeZT(fd,
+ pathTab[i]);
/* write files... */
WRITEUINT(fd,
tree->fnc);
@@ -1966,7 +1966,7 @@
writeFN(fd,
pathTab,
ptc,
- tree->filenames[i].filename);
+ tree->filenames[i].filename);
WRITEUINT(fd,
tree->filenames[i].mod_time);
}
@@ -1978,25 +1978,25 @@
WRITEUINT(fd,
tree->cisPos);
for (i=tree->cisPos-1;i>=0;i--)
- writeZT(fd,
+ writeZT(fd,
tree->cis[i]);
wpos = LSEEK(fd, 0, SEEK_CUR);
off = 0;
WRITEALL(fd,
&off,
- sizeof(unsigned long long));
+ sizeof(unsigned long long));
off = writeNode(fd,
tree,
tree->root);
LSEEK(fd, wpos, SEEK_SET);
off = htonl(off);
- WRITEALL(fd,
+ WRITEALL(fd,
&off,
sizeof(unsigned long long));
IO_FREE(tree->fd);
tree->fd = NULL;
- IO_FREE(fd);
+ IO_FREE(fd);
if (0 != unlink(tree->database))
tree->log(tree->context,
@@ -2011,15 +2011,15 @@
_("Could not rename temporary file '%s' to '%s: %s\n"),
tdatabase,
tree->database,
- strerror(errno));
+ strerror(errno));
free(tdatabase);
} /* end if tree or root modified */
-
+
CLEANUP:
if (tree->fd != NULL) {
IO_FREE(tree->fd);
- tree->fd = NULL;
+ tree->fd = NULL;
}
for (i=tree->cisPos-1;i>=0;i--)
free(tree->cis[i]);
@@ -2126,7 +2126,7 @@
return;
}
#endif
- grandchild = pos->child;
+ grandchild = pos->child;
insert = MALLOC(sizeof(STNode));
insert->mls_size = 1;
insert->useCounter = 0;
@@ -2185,7 +2185,7 @@
if (pos->c[i] != ss[0])
return NULL;
ss++;
- }
+ }
if (ss[0] == '\0')
break;
if (pos->child == NULL) {
@@ -2212,7 +2212,7 @@
(pos->mls_size > ss[0] - pos->c[0]) ) {
/* mls allows us a direct jump to the
correct entry! */
- pos = &pos[ss[0] - pos->c[0]];
+ pos = &pos[ss[0] - pos->c[0]];
#if ASSERTS
if (pos->c[0] != ss[0]) { /* check that mls works! */
tree->log(tree->context,
@@ -2231,7 +2231,7 @@
} else {
return NULL;
}
- }
+ }
pos = pos->link;
}
}
@@ -2281,14 +2281,14 @@
if ( (tree->fnc > 0) &&
(0 == strcmp(fileName,
tree->filenames[tree->fnc-1].filename))) {
- sharedName = tree->filenames[tree->fnc-1].filename;
+ sharedName = tree->filenames[tree->fnc-1].filename;
sharedNameIndex = tree->fnc-1;
} else {
sharedNameIndex = -1;
for (i=tree->fnc-2;i>=0;i--) {
if (0 == strcmp(fileName,
tree->filenames[i].filename)) {
- sharedName = tree->filenames[i].filename;
+ sharedName = tree->filenames[i].filename;
sharedNameIndex = i;
break;
}
@@ -2318,16 +2318,16 @@
if (0 != strcmp(cisp,
searchString)) {
cix = -1;
-#if (OPTIMIZE_SPACE && USE_CI_CACHE)
+#if (OPTIMIZE_SPACE && USE_CI_CACHE)
spos = tree_search_internal(tree,
searchString);
pos = spos;
- while ( (pos != NULL) &&
+ while ( (pos != NULL) &&
( (pos->cix == -1) ||
(pos->clength == 1) ) )
pos = pos->child;
if (pos != NULL) {
- cix = pos->cix; /* now != -1 AND clength > 1 */
+ cix = pos->cix; /* now != -1 AND clength > 1 */
cisp = strstr(tree->cis[cix], searchString);
#if ASSERTS
if (cisp == NULL) {
@@ -2347,7 +2347,7 @@
cix = -1;
}
#endif
- }
+ }
#endif
if (cix == -1) {
if (tree->cisLen == tree->cisPos) {
@@ -2385,18 +2385,18 @@
pos->cix = cix;
#endif
pos->clength = strlen(cisp0);
- tree->root = pos;
+ tree->root = pos;
cisp0 = ""; /* done */
markModified(pos);
}
MORE:
while (cisp0[0] != '\0') {
pos->useCounter++;
-
+
if (cisp0[0] < pos->c[0]) {
STNode * insert;
/* head (non-mls) insert here! */
- insert = MALLOC(sizeof(STNode));
+ insert = MALLOC(sizeof(STNode));
insert->mls_size = 1;
insert->useCounter = 0;
insert->link = pos;
@@ -2426,7 +2426,7 @@
i = 1;
while ( (i < pos->clength) &&
(i < strlen(cisp0)) &&
- (pos->c[i] == cisp0[i]) )
+ (pos->c[i] == cisp0[i]) )
i++;
if ( (i > 1) &&
@@ -2457,7 +2457,7 @@
if (pos->next_off != 0) {
if (-1 == loadChild(tree,
pos))
- return 1;
+ return 1;
} else {
tree->modified = 1;
pos->child = MALLOC(sizeof(STNode));
@@ -2473,8 +2473,8 @@
markModified(pos);
break; /* strlen(cisp0) > 0! */
}
- }
- pos = pos->child;
+ }
+ pos = pos->child;
} else {
if (pos->link == NULL) {
if (pos->link_off != 0) {
@@ -2511,7 +2511,7 @@
(pos->mls_size > cisp0[0] - pos->c[0]) ) {
/* mls allows us a direct jump to the
correct entry! */
- pos = &pos[cisp0[0] - pos->c[0]];
+ pos = &pos[cisp0[0] - pos->c[0]];
#if ASSERTS
if (pos->c[0] != cisp0[0]) { /* check that mls works! */
tree->log(tree->context,
@@ -2522,14 +2522,14 @@
}
#endif
continue;
- }
+ }
}
if (pos->link->c[0] > cisp0[0]) {
if (pos->mls_size == cisp0[0] - pos->c[0]) {
STNode * mlsroot;
STNode * mlsnew;
- int mls;
-
+ int mls;
+
/* use mls! */
if (pos->clength != 1) {
/* need to split tree first to make mls possible */
@@ -2543,7 +2543,7 @@
(mlsroot->parent->link == mlsroot) &&
(mlsroot->parent->mls_size > 1) )
mlsroot = mlsroot->parent;
-
+
if (pos->link->c[0] == cisp0[0] + 1) {
/* JOIN two mls segments! */
if (pos->link->clength != 1) {
@@ -2553,15 +2553,15 @@
1);
}
mlsnew = MALLOC(sizeof(STNode) * (mlsroot->mls_size +
pos->link->mls_size + 1));
-
+
memcpy(mlsnew,
- mlsroot,
+ mlsroot,
sizeof(STNode) * (mlsroot->mls_size));
mlsnew[mlsroot->mls_size].clength = 1;
- memcpy(&mlsnew[mlsroot->mls_size+1],
+ memcpy(&mlsnew[mlsroot->mls_size+1],
pos->link,
sizeof(STNode) * (pos->link->mls_size));
-
+
/* adjust data in copy */
mlsnew[0].mls_size = mlsroot->mls_size + pos->link->mls_size + 1;
for (mls=1;mls<mlsnew->mls_size;mls++) {
@@ -2569,19 +2569,19 @@
mlsnew[mls].parent = &mlsnew[mls-1];
mlsnew[mls-1].link = &mlsnew[mls];
}
- for (mls=0;mls<mlsnew->mls_size;mls++)
+ for (mls=0;mls<mlsnew->mls_size;mls++)
if (mlsnew[mls].child != NULL)
- mlsnew[mls].child->parent = &mlsnew[mls];
-
+ mlsnew[mls].child->parent = &mlsnew[mls];
+
/* update link to next entry */
mlsnew[mlsnew->mls_size-1].link =
pos->link[pos->link->mls_size-1].link;
mlsnew[mlsnew->mls_size-1].link_off =
pos->link[pos->link->mls_size-1].link_off;
if (pos->link[pos->link->mls_size-1].link != NULL)
pos->link[pos->link->mls_size-1].link->parent =
&mlsnew[mlsnew->mls_size-1];
-
+
/* update data in new entry */
mlsnew[mlsroot->mls_size].c =
&CIS[mlsnew[mlsroot->mls_size-1].c[0]+1];
-
+
/* update link from parent */
if (mlsroot->parent != NULL) {
mlsnew[0].parent = mlsroot->parent;
@@ -2613,38 +2613,38 @@
#endif
tree->root = mlsnew;
}
-
+
/* update pos to point to new location */
free(pos->link);
pos = &mlsnew[mlsroot->mls_size];
} else {
/* EXTEND existing mls segment! */
mlsnew = MALLOC(sizeof(STNode) * (mlsroot->mls_size + 1));
- memcpy(mlsnew,
- mlsroot,
+ memcpy(mlsnew,
+ mlsroot,
sizeof(STNode) * (mlsroot->mls_size));
- mlsnew[mlsroot->mls_size].clength = 1;
+ mlsnew[mlsroot->mls_size].clength = 1;
/* adjust data in copy */
- mlsnew[0].mls_size = mlsroot->mls_size+1;
+ mlsnew[0].mls_size = mlsroot->mls_size+1;
for (mls=1;mls<mlsnew->mls_size;mls++) {
mlsnew[mls].mls_size = mlsnew->mls_size - mls;
mlsnew[mls].parent = &mlsnew[mls-1];
mlsnew[mls-1].link = &mlsnew[mls];
}
- for (mls=0;mls<mlsnew->mls_size;mls++)
+ for (mls=0;mls<mlsnew->mls_size;mls++)
if (mlsnew[mls].child != NULL)
- mlsnew[mls].child->parent = &mlsnew[mls];
-
+ mlsnew[mls].child->parent = &mlsnew[mls];
+
/* update link to next entry */
mlsnew[mlsnew->mls_size-1].link = pos->link;
mlsnew[mlsnew->mls_size-1].link_off = pos->link_off;
if (pos->link != NULL)
pos->link->parent = &mlsnew[mlsnew->mls_size-1];
-
+
/* update data in new entry */
mlsnew[mlsroot->mls_size].c =
&CIS[mlsnew[mlsroot->mls_size-1].c[0]+1];
-
+
/* update link from parent */
if (mlsroot->parent != NULL) {
mlsnew[0].parent = mlsroot->parent;
@@ -2679,14 +2679,14 @@
/* update pos to point to new location */
pos = &mlsnew[mlsroot->mls_size];
}
- free(mlsroot);
+ free(mlsroot);
tree->used_memory += sizeof(STNode);
- tree->modified = 1;
+ tree->modified = 1;
CHECK(tree);
- for (mls=0;mls<mlsnew->mls_size;mls++)
+ for (mls=0;mls<mlsnew->mls_size;mls++)
markModified(&mlsnew[mls]);
-#if ASSERTS
+#if ASSERTS
if (*pos->c != cisp0[0]) {
tree->log(tree->context,
DOODLE_LOG_CRITICAL,
@@ -2699,13 +2699,13 @@
} else {
STNode * insert;
/* normal (non-mls) insert here! */
- insert = MALLOC(sizeof(STNode));
+ insert = MALLOC(sizeof(STNode));
insert->mls_size = 1;
insert->useCounter = 0;
insert->link = pos->link;
insert->link_off = pos->link_off;
pos->link = insert;
- pos->link_off = 0;
+ pos->link_off = 0;
insert->parent = pos;
insert->link->parent = insert;
tree->modified = 1;
@@ -2714,12 +2714,12 @@
/* for now (for check), fixed later */
pos->c = &CIS[(unsigned char)cisp[0]];
pos->clength = 1;
- CHECK(tree);
+ CHECK(tree);
markModified(pos);
break; /* strlen(cisp0) > 0! */
}
} else {
- pos = pos->link;
+ pos = pos->link;
}
}
} /* end 'MORE: while-loop */
@@ -2742,17 +2742,17 @@
cisp0 = &cisp0[255];
goto MORE;
} else {
- pos->c = cisp;
+ pos->c = cisp;
#if USE_CI_CACHE
pos->cix = cix;
#endif
- pos->clength = strlen(cisp0);
+ pos->clength = strlen(cisp0);
}
- }
+ }
}
for (i=pos->matchCount-1;i>=0;i--)
- if (pos->matches[i] == sharedNameIndex)
- goto CLEANUP_SUCCESS;
+ if (pos->matches[i] == sharedNameIndex)
+ goto CLEANUP_SUCCESS;
GROW(pos->matches,
pos->matchCount,
pos->matchCount+1);
@@ -2760,10 +2760,10 @@
markModified(pos);
CLEANUP_SUCCESS:
- if (tree->used_memory > tree->memory_limit)
- shrinkMemoryFootprint(tree, tree->root);
+ if (tree->used_memory > tree->memory_limit)
+ shrinkMemoryFootprint(tree, tree->root);
- return 0;
+ return 0;
}
static int truncate_internal(SuffixTree * tree,
@@ -2783,8 +2783,8 @@
for (k=0;k<max;k++) {
j = -1;
for (i=node->matchCount-1;i>=0;i--) {
- if (node->matches[i] == fileNameIndex[k])
- j = i;
+ if (node->matches[i] == fileNameIndex[k])
+ j = i;
}
if (j != -1) {
node->matches[j] = node->matches[node->matchCount-1];
@@ -2811,7 +2811,7 @@
node->child,
fileNameIndex,
max))
- return -1;
+ return -1;
if ( (node->link == NULL) &&
(node->link_off != 0) )
if (-1 == loadLink(tree,
@@ -2820,9 +2820,9 @@
CHECK(tree);
next = node->link;
if ( (node->matchCount == 0) &&
- (node->child == NULL) &&
+ (node->child == NULL) &&
(node->mls_size == 1) && /* make sure this is not an MLS! */
- ( (node->parent == NULL) ||
+ ( (node->parent == NULL) ||
(node->parent->mls_size == 1) ||
(node->parent->link != node) ) ) {
tree->used_memory -= sizeof(STNode);
@@ -2840,7 +2840,7 @@
if (parent == NULL)
tree->root = next;
markModified(parent);
- free(node);
+ free(node);
markModified(next);
} else {
parent = node;
@@ -2864,7 +2864,7 @@
int max;
int i;
int pos;
-
+
CHECK(tree);
max = 0;
while (fileNames[max] != NULL) {
@@ -2900,7 +2900,7 @@
for (i=0;i<max;i++) {
free(tree->filenames[delOff[i]].filename);
tree->filenames[delOff[i]] = tree->filenames[--rep];
- }
+ }
free(delOff);
/* DOODLE_tree_dump(stdout, tree); */
CHECK(tree);
@@ -2935,7 +2935,7 @@
int i;
unsigned int killCount;
const char ** killNames;
-
+
log(logContext,
DOODLE_LOG_VERBOSE,
_("Scanning filesystem in order to remove obsolete entries from existing
database.\n"));
@@ -2996,7 +2996,7 @@
int i;
unsigned int killCount;
const char ** killNames;
-
+
log(logContext,
DOODLE_LOG_VERBOSE,
_("Scanning filesystem in order to remove obsolete entries from existing
database.\n"));
@@ -3028,10 +3028,10 @@
_("File '%s' is not a regular file. Removing file from index.\n"),
fn);
keep = 0;
- } else if (DOODLE_getFileAt(tree,i)->mod_time !=
+ } else if (DOODLE_getFileAt(tree,i)->mod_time !=
(unsigned int) sbuf.st_mtime) {
keep = 0; /* modified! */
- }
+ }
if (keep == 0) {
GROW(killNames,
killCount,
@@ -3081,7 +3081,7 @@
return -1;
}
ret += tree_iterate_internal(1,
- tree,
+ tree,
node->child,
callback,
arg);
@@ -3112,10 +3112,10 @@
pos = tree_search_internal(tree,
substring);
- return tree_iterate_internal(0,
+ return tree_iterate_internal(0,
tree,
pos,
- callback,
+ callback,
arg);
}
@@ -3129,7 +3129,7 @@
* @param resultSize pass address of integer of value 0, will be set
* @return -1 on error, 0 for no results, >0 for number of results
*/
-static int tree_search_approx_internal(STNode * pos,
+static int tree_search_approx_internal(STNode * pos,
const unsigned int approx,
const int ignore_case,
SuffixTree * tree,
@@ -3151,14 +3151,14 @@
}
if (pos == NULL)
return 0; /* huh? */
- if (pos->clength > 1)
+ if (pos->clength > 1)
tree_normalize(tree,
pos); /* normalize! */
-
+
while (pos != NULL) {
if ( (pos->c[0] == ss[0]) ||
( (ignore_case == 1) &&
- (tolower(pos->c[0]) == tolower(ss[0])) ) ) {
+ (tolower(pos->c[0]) == tolower(ss[0])) ) ) {
tree_normalize(tree, pos);
if (ss[1] == '\0') {
iret = tree_iterate_internal(0,
@@ -3195,7 +3195,7 @@
callback,
arg);
return ret;
- }
+ }
tree_normalize(tree, pos);
if ( (pos->child == NULL) &&
@@ -3238,7 +3238,7 @@
ret += iret;
}
if ( (pos->link == NULL) &&
- (pos->link_off != 0) )
+ (pos->link_off != 0) )
if (-1 == loadLink(tree,
pos))
return -1;
@@ -3288,7 +3288,7 @@
' ',
(int)node->clength,
node->c);
- for (i=node->matchCount-1;i>=0;i--)
+ for (i=node->matchCount-1;i>=0;i--)
fprintf(stream,
"%*c %s\n",
ident,
@@ -3348,7 +3348,7 @@
#define JNICALL
#endif
-#include "org_ovmj_doodle_Doodle.h"
+#include "org_ovmj_doodle_Doodle.h"
/*
* Class: org_ovmj_doodle_Doodle
* Method: getVersionInternal
@@ -3386,7 +3386,7 @@
va_start(ap, message);
n = vsnprintf(buf, n, message, ap);
va_end(ap);
-
+
logger = (*ctx->env)->GetObjectClass(ctx->env,
ctx->logger);
log = (*ctx->env)->GetMethodID(ctx->env,
@@ -3416,7 +3416,7 @@
database = (*env)->GetStringUTFChars(env,
filename,
- &isCopy);
+ &isCopy);
ret = MALLOC(sizeof(JNICTX));
ret->env = env;
ret->logger = logger;
@@ -3459,7 +3459,7 @@
fn = (*env)->GetStringUTFChars(env,
filename,
- &isCopy);
+ &isCopy);
DOODLE_tree_truncate(ret->dst,
fn);
(*env)->ReleaseStringUTFChars(env,
@@ -3482,10 +3482,10 @@
fn = (*env)->GetStringUTFChars(env,
filename,
- &isCopy);
+ &isCopy);
ky = (*env)->GetStringUTFChars(env,
key,
- &isCopy);
+ &isCopy);
i = DOODLE_tree_expand(ret->dst,
ky,
fn);
@@ -3513,14 +3513,14 @@
fn = (*env)->GetStringUTFChars(env,
filename,
- &isCopy);
+ &isCopy);
for (i=DOODLE_getFileCount(ret->dst)-1;i>=0;i--) {
f = DOODLE_getFileAt(ret->dst, i);
if (0 == strcmp(fn, f->filename)) {
(*env)->ReleaseStringUTFChars(env,
filename,
fn);
- return f->mod_time;
+ return f->mod_time;
}
}
(*env)->ReleaseStringUTFChars(env,
@@ -3563,7 +3563,7 @@
ky = (*env)->GetStringUTFChars(env,
key,
- &isCopy);
+ &isCopy);
vector = (*env)->GetObjectClass(env,
vect);
cls.env = env;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r465 - doodle/src/doodle,
grothoff <=