projects
/
blerg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
e476507
)
tags must be preceeded by whitespace or start at the beginning of the record
author
Chip Black
<bytex64@bytex64.net>
Sun, 16 Jan 2011 12:08:22 +0000
(06:08 -0600)
committer
Chip Black
<bytex64@bytex64.net>
Sun, 16 Jan 2011 12:08:22 +0000
(06:08 -0600)
config.h
patch
|
blob
|
history
database/tags.c
patch
|
blob
|
history
diff --git
a/config.h
b/config.h
index
9a16246
..
b363206
100644
(file)
--- a/
config.h
+++ b/
config.h
@@
-10,4
+10,7
@@
#define RECORDS_PER_SEGMENT 65536
#define MAX_RECORD_SIZE 65535 /* No greater than 65535 */
#define RECORDS_PER_SEGMENT 65536
#define MAX_RECORD_SIZE 65535 /* No greater than 65535 */
+#define MAX_TAG_LENGTH 64
+#define MAX_TAGS_PER_RECORD 1024
+
#endif //_CONFIG_H
#endif //_CONFIG_H
diff --git
a/database/tags.c
b/database/tags.c
index
8386705
..
a28df02
100644
(file)
--- a/
database/tags.c
+++ b/
database/tags.c
@@
-14,20
+14,19
@@
#include "util.h"
#include "config.h"
#include "util.h"
#include "config.h"
-#define MAX_TAG_LENGTH 64
-#define MAX_TAGS 1024
-
#define TAG_CHAR(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_')
#define TAG_CHAR(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_')
+#define WHITESPACE(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r')
int tag_scan(const char *author, const char *data, int len, uint64_t record) {
int tag_scan(const char *author, const char *data, int len, uint64_t record) {
- char *taglist[MAX_TAGS];
+ char *taglist[MAX_TAGS_PER_RECORD];
+ char last_char = ' ';
int n_tags = 0;
int i, j;
for (i = 0; i < len; i++) {
tag_scan_start:
int n_tags = 0;
int i, j;
for (i = 0; i < len; i++) {
tag_scan_start:
- if (
data[i] == '#' || data[i] == '@'
) {
- if (n_tags == MAX_TAGS) {
+ if (
WHITESPACE(last_char) && (data[i] == '#' || data[i] == '@')
) {
+ if (n_tags == MAX_TAGS
_PER_RECORD
) {
fprintf(stderr, "Too many tags in message\n");
break;
}
fprintf(stderr, "Too many tags in message\n");
break;
}
@@
-43,14
+42,17
@@
tag_scan_start:
if (!strncmp(tag, taglist[j], MAX_TAG_LENGTH)) {
// We already have this tag. Start over.
free(tag);
if (!strncmp(tag, taglist[j], MAX_TAG_LENGTH)) {
// We already have this tag. Start over.
free(tag);
+ last_char = data[i-1];
goto tag_scan_start;
}
}
taglist[n_tags] = tag;
n_tags++;
goto tag_scan_start;
}
}
taglist[n_tags] = tag;
n_tags++;
+ last_char = data[i-1];
// We goto here so i doesn't get incremented
goto tag_scan_start;
}
// We goto here so i doesn't get incremented
goto tag_scan_start;
}
+ last_char = data[i];
}
for (i = 0; i < n_tags; i++) {
}
for (i = 0; i < n_tags; i++) {