diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-06 11:14:11 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-06 11:14:11 +0000 |
commit | f5beb3eaf163fc0bf2a4f86bd413d3ee6939cfea (patch) | |
tree | b59a38ad9e2296b3d2c8cc3302f21cf6d3ecc458 /src/regex | |
parent | 6db64c5eae089e1d81cafbb051f65412790d16bc (diff) | |
download | gnunet-f5beb3eaf163fc0bf2a4f86bd413d3ee6939cfea.tar.gz gnunet-f5beb3eaf163fc0bf2a4f86bd413d3ee6939cfea.zip |
-fix misc issues
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 32 | ||||
-rw-r--r-- | src/regex/regex_internal.c | 6 |
2 files changed, 26 insertions, 12 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 2114e2cb1..c5ecf3b4d 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -1231,41 +1231,55 @@ load_search_strings (const char *filename, | |||
1231 | "Could not find search strings file %s\n", filename); | 1231 | "Could not find search strings file %s\n", filename); |
1232 | return GNUNET_SYSERR; | 1232 | return GNUNET_SYSERR; |
1233 | } | 1233 | } |
1234 | if (GNUNET_OK != GNUNET_DISK_file_size (filename, &filesize, GNUNET_YES, GNUNET_YES)) | 1234 | if (GNUNET_OK != |
1235 | GNUNET_DISK_file_size (filename, | ||
1236 | &filesize, | ||
1237 | GNUNET_YES, | ||
1238 | GNUNET_YES)) | ||
1235 | filesize = 0; | 1239 | filesize = 0; |
1236 | if (0 == filesize) | 1240 | if (0 == filesize) |
1237 | { | 1241 | { |
1238 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Search strings file %s is empty.\n", filename); | 1242 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1243 | "Search strings file %s is empty.\n", | ||
1244 | filename); | ||
1239 | return GNUNET_SYSERR; | 1245 | return GNUNET_SYSERR; |
1240 | } | 1246 | } |
1241 | data = GNUNET_malloc (filesize); | 1247 | data = GNUNET_malloc (filesize + 1); |
1242 | if (filesize != GNUNET_DISK_fn_read (filename, data, filesize)) | 1248 | if (filesize != GNUNET_DISK_fn_read (filename, |
1249 | data, | ||
1250 | filesize)) | ||
1243 | { | 1251 | { |
1244 | GNUNET_free (data); | 1252 | GNUNET_free (data); |
1245 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not read search strings file %s.\n", | 1253 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1254 | "Could not read search strings file %s.\n", | ||
1246 | filename); | 1255 | filename); |
1247 | return GNUNET_SYSERR; | 1256 | return GNUNET_SYSERR; |
1248 | } | 1257 | } |
1249 | buf = data; | 1258 | buf = data; |
1250 | offset = 0; | 1259 | offset = 0; |
1251 | str_cnt = 0; | 1260 | str_cnt = 0; |
1252 | while (offset < (filesize - 1) && str_cnt < limit) | 1261 | while ( (offset < (filesize - 1)) && (str_cnt < limit) ) |
1253 | { | 1262 | { |
1254 | offset++; | 1263 | offset++; |
1255 | if (((data[offset] == '\n')) && (buf != &data[offset])) | 1264 | if ( ((data[offset] == '\n')) && |
1265 | (buf != &data[offset]) ) | ||
1256 | { | 1266 | { |
1257 | data[offset] = '\0'; | 1267 | data[offset] = '\0'; |
1258 | str_cnt++; | 1268 | str_cnt++; |
1259 | buf = &data[offset + 1]; | 1269 | buf = &data[offset + 1]; |
1260 | } | 1270 | } |
1261 | else if ((data[offset] == '\n') || (data[offset] == '\0')) | 1271 | else if ( (data[offset] == '\n') || |
1272 | (data[offset] == '\0') ) | ||
1262 | buf = &data[offset + 1]; | 1273 | buf = &data[offset + 1]; |
1263 | } | 1274 | } |
1264 | *strings = GNUNET_malloc (sizeof (char *) * str_cnt); | 1275 | *strings = GNUNET_malloc (sizeof (char *) * str_cnt); |
1265 | offset = 0; | 1276 | offset = 0; |
1266 | for (i = 0; i < str_cnt; i++) | 1277 | for (i = 0; i < str_cnt; i++) |
1267 | { | 1278 | { |
1268 | GNUNET_asprintf (&(*strings)[i], "%s%s", regex_prefix, &data[offset]); | 1279 | GNUNET_asprintf (&(*strings)[i], |
1280 | "%s%s", | ||
1281 | regex_prefix, | ||
1282 | &data[offset]); | ||
1269 | offset += strlen (&data[offset]) + 1; | 1283 | offset += strlen (&data[offset]) + 1; |
1270 | } | 1284 | } |
1271 | GNUNET_free (data); | 1285 | GNUNET_free (data); |
diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c index 616b7f141..cb78545b9 100644 --- a/src/regex/regex_internal.c +++ b/src/regex/regex_internal.c | |||
@@ -2037,9 +2037,9 @@ dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx, | |||
2037 | /* same edge, but targets definitively different, so we're different | 2037 | /* same edge, but targets definitively different, so we're different |
2038 | as well */ | 2038 | as well */ |
2039 | if (t1->to_state->marked > t2->to_state->marked) | 2039 | if (t1->to_state->marked > t2->to_state->marked) |
2040 | idx1 = t1->to_state->marked * state_cnt + t2->to_state->marked; | 2040 | idx1 = (unsigned long long) t1->to_state->marked * state_cnt + t2->to_state->marked; |
2041 | else | 2041 | else |
2042 | idx1 = t2->to_state->marked * state_cnt + t1->to_state->marked; | 2042 | idx1 = (unsigned long long) t2->to_state->marked * state_cnt + t1->to_state->marked; |
2043 | if (0 != (table[idx1 / 32] & (1 << (idx1 % 32)))) | 2043 | if (0 != (table[idx1 / 32] & (1 << (idx1 % 32)))) |
2044 | { | 2044 | { |
2045 | table[idx / 32] |= (1 << (idx % 32)); | 2045 | table[idx / 32] |= (1 << (idx % 32)); |
@@ -2066,7 +2066,7 @@ dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx, | |||
2066 | for (s2 = a->states_head; NULL != s2 && s1 != s2; s2 = s2_next) | 2066 | for (s2 = a->states_head; NULL != s2 && s1 != s2; s2 = s2_next) |
2067 | { | 2067 | { |
2068 | s2_next = s2->next; | 2068 | s2_next = s2->next; |
2069 | idx = s1->marked * state_cnt + s2->marked; | 2069 | idx = (unsigned long long) s1->marked * state_cnt + s2->marked; |
2070 | if (0 == (table[idx / 32] & (1 << (idx % 32)))) | 2070 | if (0 == (table[idx / 32] & (1 << (idx % 32)))) |
2071 | automaton_merge_states (ctx, a, s1, s2); | 2071 | automaton_merge_states (ctx, a, s1, s2); |
2072 | } | 2072 | } |