durable_rules 0.34.17 → 0.34.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f088b9135a5d4ad9a64d29156986df9307d40fc
4
- data.tar.gz: 3fa59ec7a1b268240235aadcfe1ea91563afd156
3
+ metadata.gz: ede28c26f0087d55595d6e8262fa6937cb26625f
4
+ data.tar.gz: bd5ac33cbe9887938d2ebe9fbb60121d870538b3
5
5
  SHA512:
6
- metadata.gz: b3c5a66e5cdcc3c813985d221e6933cd63692eccfee45cbd1fab0bda5283d203bd1b26a62d4ebdda671cab3e138a7e79c14bfc72aa2392bacb5d173b829a0548
7
- data.tar.gz: 49f9def662c46765994e89d35df408e20fc2eafe2d6650803403dc9b57e48652fe18e4533e9b77700987f28ac9d9f90df64d4d70c0fdd3741b40e466680a73cb
6
+ metadata.gz: fa7d9872f33c0de2c4aadb736bec251f760293708d09c7dd9562fa88e3c06cdaa7db031a603caacf930ed453d1955f1513fc40fbf71fb629abb739d59c11994d
7
+ data.tar.gz: 5a73610275300a5e6e35fdad63ba31cb1dd83edb746aad890bbd1a86093b943c44c0d0458ff8ce1dd1edd26a7f003481afddb10b4ae3cfb16e2bcc6495de4b75
data/src/rules/events.c CHANGED
@@ -272,7 +272,6 @@ static unsigned int handleAction(ruleset *tree,
272
272
  node *node,
273
273
  unsigned char actionType,
274
274
  char **evalKeys,
275
- unsigned short *evalPriorities,
276
275
  unsigned int *evalCount,
277
276
  char **addKeys,
278
277
  unsigned int *addCount,
@@ -303,15 +302,7 @@ static unsigned int handleAction(ruleset *tree,
303
302
  }
304
303
 
305
304
  strcpy(evalKey, prefix);
306
- unsigned int index = *evalCount;
307
- while (index > 0 && node->value.c.priority < evalPriorities[index - 1]) {
308
- evalKeys[index] = evalKeys[index - 1];
309
- evalPriorities[index] = evalPriorities[index - 1];
310
- --index;
311
- }
312
-
313
- evalKeys[index] = evalKey;
314
- evalPriorities[index] = node->value.c.priority;
305
+ evalKeys[*evalCount] = evalKey;
315
306
  ++*evalCount;
316
307
  break;
317
308
 
@@ -354,7 +345,6 @@ static unsigned int handleBeta(ruleset *tree,
354
345
  node *betaNode,
355
346
  unsigned short actionType,
356
347
  char **evalKeys,
357
- unsigned short *evalPriorities,
358
348
  unsigned int *evalCount,
359
349
  char **addKeys,
360
350
  unsigned int *addCount,
@@ -420,7 +410,6 @@ static unsigned int handleBeta(ruleset *tree,
420
410
  actionNode,
421
411
  actionType,
422
412
  evalKeys,
423
- evalPriorities,
424
413
  evalCount,
425
414
  addKeys,
426
415
  addCount,
@@ -923,7 +912,6 @@ static unsigned int handleAlpha(ruleset *tree,
923
912
  alpha *alphaNode,
924
913
  unsigned char actionType,
925
914
  char **evalKeys,
926
- unsigned short *evalPriorities,
927
915
  unsigned int *evalCount,
928
916
  char **addKeys,
929
917
  unsigned int *addCount,
@@ -1010,7 +998,6 @@ static unsigned int handleAlpha(ruleset *tree,
1010
998
  &tree->nodePool[betaList[entry]],
1011
999
  actionType,
1012
1000
  evalKeys,
1013
- evalPriorities,
1014
1001
  evalCount,
1015
1002
  addKeys,
1016
1003
  addCount,
@@ -1126,7 +1113,6 @@ static unsigned int handleMessageCore(ruleset *tree,
1126
1113
  char *addKeys[MAX_ADD_COUNT];
1127
1114
  unsigned int addCount = 0;
1128
1115
  char *evalKeys[MAX_EVAL_COUNT];
1129
- unsigned short evalPriorities[MAX_EVAL_COUNT];
1130
1116
  unsigned int evalCount = 0;
1131
1117
  result = handleAlpha(tree,
1132
1118
  sid,
@@ -1137,7 +1123,6 @@ static unsigned int handleMessageCore(ruleset *tree,
1137
1123
  &tree->nodePool[NODE_M_OFFSET].value.a,
1138
1124
  actionType,
1139
1125
  evalKeys,
1140
- evalPriorities,
1141
1126
  &evalCount,
1142
1127
  addKeys,
1143
1128
  &addCount,
@@ -1201,7 +1186,6 @@ static unsigned int handleMessageCore(ruleset *tree,
1201
1186
  evalKeys,
1202
1187
  evalCount,
1203
1188
  &evalCommand);
1204
-
1205
1189
  for (unsigned int i = 0; i < evalCount; ++i) {
1206
1190
  free(evalKeys[i]);
1207
1191
  }
data/src/rules/net.c CHANGED
@@ -1216,6 +1216,23 @@ static unsigned int loadPeekActionCommand(ruleset *tree, binding *rulesBinding)
1216
1216
  return RULES_OK;
1217
1217
  }
1218
1218
 
1219
+ static void sortActions(ruleset *tree, node **sortedActions, unsigned int *actionCount) {
1220
+ *actionCount = 0;
1221
+ for (unsigned int i = 0; i < tree->nodeOffset; ++i) {
1222
+ node *currentNode = &tree->nodePool[i];
1223
+ if (currentNode->type == NODE_ACTION) {
1224
+ unsigned int index = *actionCount;
1225
+ while (index > 0 && currentNode->value.c.priority < sortedActions[index - 1]->value.c.priority) {
1226
+ sortedActions[index] = sortedActions[index - 1];
1227
+ --index;
1228
+ }
1229
+
1230
+ sortedActions[index] = currentNode;
1231
+ ++*actionCount;
1232
+ }
1233
+ }
1234
+ }
1235
+
1219
1236
  static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding) {
1220
1237
  char *name = &tree->stringPool[tree->nameOffset];
1221
1238
  int nameLength = strlen(name);
@@ -1223,13 +1240,16 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1223
1240
  redisReply *reply;
1224
1241
  char *lua = NULL;
1225
1242
  char *oldLua;
1226
-
1243
+ unsigned int actionCount = 0;
1244
+
1227
1245
  #ifdef _WIN32
1228
- char *actionKey = (char *)_alloca(sizeof(char)*(nameLength + 3));
1246
+ char *actionKey = (char *)_alloca(sizeof(char) * (nameLength + 3));
1229
1247
  sprintf_s(actionKey, nameLength + 3, "%s!a", name);
1248
+ node **sortedActions = (node **)_alloca(sizeof(node *) * tree->nodeOffset);
1230
1249
  #else
1231
1250
  char actionKey[nameLength + 3];
1232
1251
  snprintf(actionKey, nameLength + 3, "%s!a", name);
1252
+ node *sortedActions[tree->nodeOffset];
1233
1253
  #endif
1234
1254
 
1235
1255
  lua = (char*)calloc(1, sizeof(char));
@@ -1237,30 +1257,29 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1237
1257
  return ERR_OUT_OF_MEMORY;
1238
1258
  }
1239
1259
 
1240
- for (unsigned int i = 0; i < tree->nodeOffset; ++i) {
1241
- node *currentNode = &tree->nodePool[i];
1242
-
1243
- if (currentNode->type == NODE_ACTION) {
1244
- char *packFrameLua = NULL;
1245
- char *unpackFrameLua = NULL;
1246
- char *oldPackFrameLua = NULL;
1247
- char *oldUnpackFrameLua = NULL;
1248
- char *actionName = &tree->stringPool[currentNode->nameOffset];
1249
- char *actionLastName = strchr(actionName, '!');
1260
+ sortActions(tree, sortedActions, &actionCount);
1261
+ for (unsigned int i = 0; i < actionCount; ++i) {
1262
+ node *currentNode = sortedActions[i];
1263
+ char *packFrameLua = NULL;
1264
+ char *unpackFrameLua = NULL;
1265
+ char *oldPackFrameLua = NULL;
1266
+ char *oldUnpackFrameLua = NULL;
1267
+ char *actionName = &tree->stringPool[currentNode->nameOffset];
1268
+ char *actionLastName = strchr(actionName, '!');
1250
1269
  #ifdef _WIN32
1251
- char *actionAlias = (char *)_alloca(sizeof(char)*(actionLastName - actionName + 1));
1270
+ char *actionAlias = (char *)_alloca(sizeof(char)*(actionLastName - actionName + 1));
1252
1271
  #else
1253
- char actionAlias[actionLastName - actionName + 1];
1272
+ char actionAlias[actionLastName - actionName + 1];
1254
1273
  #endif
1255
-
1256
- strncpy(actionAlias, actionName, actionLastName - actionName);
1257
- actionAlias[actionLastName - actionName] = '\0';
1258
-
1259
- for (unsigned int ii = 0; ii < currentNode->value.c.joinsLength; ++ii) {
1260
- unsigned int currentJoinOffset = tree->nextPool[currentNode->value.c.joinsOffset + ii];
1261
- join *currentJoin = &tree->joinPool[currentJoinOffset];
1262
- oldLua = lua;
1263
- if (asprintf(&lua,
1274
+
1275
+ strncpy(actionAlias, actionName, actionLastName - actionName);
1276
+ actionAlias[actionLastName - actionName] = '\0';
1277
+
1278
+ for (unsigned int ii = 0; ii < currentNode->value.c.joinsLength; ++ii) {
1279
+ unsigned int currentJoinOffset = tree->nextPool[currentNode->value.c.joinsOffset + ii];
1280
+ join *currentJoin = &tree->joinPool[currentJoinOffset];
1281
+ oldLua = lua;
1282
+ if (asprintf(&lua,
1264
1283
  "%stoggle = false\n"
1265
1284
  "context_directory = {}\n"
1266
1285
  "context = {}\n"
@@ -1282,51 +1301,51 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1282
1301
  "context[\"directory\"] = directory\n"
1283
1302
  "context[\"results_key\"] = \"%s!%d!r!\" .. sid\n"
1284
1303
  "context[\"expressions_count\"] = %d\n",
1285
- lua,
1286
- actionName,
1287
- ii,
1288
- currentJoin->expressionsLength) == -1) {
1289
- return ERR_OUT_OF_MEMORY;
1290
- }
1291
- free(oldLua);
1292
-
1293
- for (unsigned int iii = 0; iii < currentJoin->expressionsLength; ++iii) {
1294
- unsigned int expressionOffset = tree->nextPool[currentJoin->expressionsOffset + iii];
1295
- expression *expr = &tree->expressionPool[expressionOffset];
1296
- char *currentKey = &tree->stringPool[expr->nameOffset];
1297
- char *currentAlias = &tree->stringPool[expr->aliasOffset];
1298
- char *nextKeyTest;
1299
-
1300
- if (iii == (currentJoin->expressionsLength - 1)) {
1301
- nextKeyTest = (char*)calloc(1, sizeof(char));
1302
- if (!nextKeyTest) {
1303
- return ERR_OUT_OF_MEMORY;
1304
- }
1305
- } else {
1306
- unsigned int nextExpressionOffset = tree->nextPool[currentJoin->expressionsOffset + iii + 1];
1307
- expression *nextExpr = &tree->expressionPool[nextExpressionOffset];
1308
- if (asprintf(&nextKeyTest,
1304
+ lua,
1305
+ actionName,
1306
+ ii,
1307
+ currentJoin->expressionsLength) == -1) {
1308
+ return ERR_OUT_OF_MEMORY;
1309
+ }
1310
+ free(oldLua);
1311
+
1312
+ for (unsigned int iii = 0; iii < currentJoin->expressionsLength; ++iii) {
1313
+ unsigned int expressionOffset = tree->nextPool[currentJoin->expressionsOffset + iii];
1314
+ expression *expr = &tree->expressionPool[expressionOffset];
1315
+ char *currentKey = &tree->stringPool[expr->nameOffset];
1316
+ char *currentAlias = &tree->stringPool[expr->aliasOffset];
1317
+ char *nextKeyTest;
1318
+
1319
+ if (iii == (currentJoin->expressionsLength - 1)) {
1320
+ nextKeyTest = (char*)calloc(1, sizeof(char));
1321
+ if (!nextKeyTest) {
1322
+ return ERR_OUT_OF_MEMORY;
1323
+ }
1324
+ } else {
1325
+ unsigned int nextExpressionOffset = tree->nextPool[currentJoin->expressionsOffset + iii + 1];
1326
+ expression *nextExpr = &tree->expressionPool[nextExpressionOffset];
1327
+ if (asprintf(&nextKeyTest,
1309
1328
  "or input_keys[\"%s\"]",
1310
- &tree->stringPool[nextExpr->nameOffset]) == -1) {
1311
- return ERR_OUT_OF_MEMORY;
1312
- }
1329
+ &tree->stringPool[nextExpr->nameOffset]) == -1) {
1330
+ return ERR_OUT_OF_MEMORY;
1313
1331
  }
1314
-
1315
- if (iii == 0) {
1316
- if (expr->not) {
1317
- if (asprintf(&packFrameLua,
1332
+ }
1333
+
1334
+ if (iii == 0) {
1335
+ if (expr->not) {
1336
+ if (asprintf(&packFrameLua,
1318
1337
  " result[1] = \"$n\"\n") == -1) {
1319
- return ERR_OUT_OF_MEMORY;
1320
- }
1338
+ return ERR_OUT_OF_MEMORY;
1339
+ }
1321
1340
 
1322
- if (asprintf(&unpackFrameLua,
1341
+ if (asprintf(&unpackFrameLua,
1323
1342
  " result[\"%s\"] = \"$n\"\n",
1324
- currentAlias) == -1) {
1325
- return ERR_OUT_OF_MEMORY;
1326
- }
1343
+ currentAlias) == -1) {
1344
+ return ERR_OUT_OF_MEMORY;
1345
+ }
1327
1346
 
1328
- oldLua = lua;
1329
- if (asprintf(&lua,
1347
+ oldLua = lua;
1348
+ if (asprintf(&lua,
1330
1349
  "%sif input_keys[\"%s\"] %s then\n"
1331
1350
  " toggle = true\n"
1332
1351
  " context_directory[\"%s\"] = context\n"
@@ -1356,43 +1375,43 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1356
1375
  " return \"\"\n"
1357
1376
  " end\n"
1358
1377
  "end\n",
1359
- lua,
1360
- currentKey,
1361
- nextKeyTest,
1362
- currentKey,
1363
- currentKey,
1364
- currentKey,
1365
- currentAlias,
1366
- packFrameLua,
1367
- unpackFrameLua) == -1) {
1368
- return ERR_OUT_OF_MEMORY;
1369
- }
1370
- free(oldLua);
1371
- // not (expr->not)
1372
- } else {
1373
- if (asprintf(&packFrameLua,
1378
+ lua,
1379
+ currentKey,
1380
+ nextKeyTest,
1381
+ currentKey,
1382
+ currentKey,
1383
+ currentKey,
1384
+ currentAlias,
1385
+ packFrameLua,
1386
+ unpackFrameLua) == -1) {
1387
+ return ERR_OUT_OF_MEMORY;
1388
+ }
1389
+ free(oldLua);
1390
+ // not (expr->not)
1391
+ } else {
1392
+ if (asprintf(&packFrameLua,
1374
1393
  " message = frame[\"%s\"]\n"
1375
1394
  " if full_encode and not message[\"$f\"] then\n"
1376
1395
  " result[1] = message\n"
1377
1396
  " else\n"
1378
1397
  " result[1] = message[\"id\"]\n"
1379
1398
  " end\n",
1380
- currentAlias) == -1) {
1381
- return ERR_OUT_OF_MEMORY;
1382
- }
1399
+ currentAlias) == -1) {
1400
+ return ERR_OUT_OF_MEMORY;
1401
+ }
1383
1402
 
1384
- if (asprintf(&unpackFrameLua,
1403
+ if (asprintf(&unpackFrameLua,
1385
1404
  " message = fetch_message(frame[1])\n"
1386
1405
  " if not message then\n"
1387
1406
  " return nil\n"
1388
1407
  " end\n"
1389
1408
  " result[\"%s\"] = message\n",
1390
- currentAlias) == -1) {
1391
- return ERR_OUT_OF_MEMORY;
1392
- }
1409
+ currentAlias) == -1) {
1410
+ return ERR_OUT_OF_MEMORY;
1411
+ }
1393
1412
 
1394
- oldLua = lua;
1395
- if (asprintf(&lua,
1413
+ oldLua = lua;
1414
+ if (asprintf(&lua,
1396
1415
  "%sif input_keys[\"%s\"] %s then\n"
1397
1416
  " toggle = true\n"
1398
1417
  " context_directory[\"%s\"] = context\n"
@@ -1424,51 +1443,51 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1424
1443
  " return \"\"\n"
1425
1444
  " end\n"
1426
1445
  "end\n",
1427
- lua,
1428
- currentKey,
1429
- nextKeyTest,
1430
- currentKey,
1431
- currentKey,
1432
- currentKey,
1433
- currentAlias,
1434
- packFrameLua,
1435
- unpackFrameLua) == -1) {
1436
- return ERR_OUT_OF_MEMORY;
1437
- }
1438
- free(oldLua);
1439
- }
1440
- // not (iii == 0)
1441
- } else {
1442
- char *test = NULL;
1443
- char *primaryKeyLua = NULL;
1444
- char *primaryFrameKeyLua = NULL;
1445
-
1446
- unsigned int result = createTest(tree, expr, &test, &primaryKeyLua, &primaryFrameKeyLua);
1447
- if (result != RULES_OK) {
1448
- return result;
1446
+ lua,
1447
+ currentKey,
1448
+ nextKeyTest,
1449
+ currentKey,
1450
+ currentKey,
1451
+ currentKey,
1452
+ currentAlias,
1453
+ packFrameLua,
1454
+ unpackFrameLua) == -1) {
1455
+ return ERR_OUT_OF_MEMORY;
1449
1456
  }
1457
+ free(oldLua);
1458
+ }
1459
+ // not (iii == 0)
1460
+ } else {
1461
+ char *test = NULL;
1462
+ char *primaryKeyLua = NULL;
1463
+ char *primaryFrameKeyLua = NULL;
1464
+
1465
+ unsigned int result = createTest(tree, expr, &test, &primaryKeyLua, &primaryFrameKeyLua);
1466
+ if (result != RULES_OK) {
1467
+ return result;
1468
+ }
1450
1469
 
1451
- if (expr->not) {
1452
- oldPackFrameLua = packFrameLua;
1453
- if (asprintf(&packFrameLua,
1470
+ if (expr->not) {
1471
+ oldPackFrameLua = packFrameLua;
1472
+ if (asprintf(&packFrameLua,
1454
1473
  "%s result[%d] = \"$n\"\n",
1455
- packFrameLua,
1456
- iii + 1) == -1) {
1457
- return ERR_OUT_OF_MEMORY;
1458
- }
1459
- free(oldPackFrameLua);
1474
+ packFrameLua,
1475
+ iii + 1) == -1) {
1476
+ return ERR_OUT_OF_MEMORY;
1477
+ }
1478
+ free(oldPackFrameLua);
1460
1479
 
1461
- oldUnpackFrameLua = unpackFrameLua;
1462
- if (asprintf(&unpackFrameLua,
1480
+ oldUnpackFrameLua = unpackFrameLua;
1481
+ if (asprintf(&unpackFrameLua,
1463
1482
  "%s result[\"%s\"] = \"$n\"\n",
1464
- unpackFrameLua,
1465
- currentAlias) == -1) {
1466
- return ERR_OUT_OF_MEMORY;
1467
- }
1468
- free(oldUnpackFrameLua);
1483
+ unpackFrameLua,
1484
+ currentAlias) == -1) {
1485
+ return ERR_OUT_OF_MEMORY;
1486
+ }
1487
+ free(oldUnpackFrameLua);
1469
1488
 
1470
- oldLua = lua;
1471
- if (asprintf(&lua,
1489
+ oldLua = lua;
1490
+ if (asprintf(&lua,
1472
1491
  "%sif toggle %s then\n"
1473
1492
  " toggle = true\n"
1474
1493
  " context_directory[\"%s\"] = context\n"
@@ -1502,63 +1521,63 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1502
1521
  " return result\n"
1503
1522
  " end\n"
1504
1523
  "end\n",
1505
- lua,
1506
- nextKeyTest,
1507
- currentKey,
1508
- iii + 1,
1509
- currentKey,
1510
- iii + 1,
1511
- currentKey,
1512
- iii + 1,
1513
- iii + 1,
1514
- test,
1515
- currentAlias,
1516
- iii + 1,
1517
- packFrameLua,
1518
- iii + 1,
1519
- unpackFrameLua,
1520
- iii + 1,
1521
- primaryKeyLua,
1522
- iii + 1,
1523
- primaryFrameKeyLua) == -1) {
1524
- return ERR_OUT_OF_MEMORY;
1525
- }
1526
- free(oldLua);
1524
+ lua,
1525
+ nextKeyTest,
1526
+ currentKey,
1527
+ iii + 1,
1528
+ currentKey,
1529
+ iii + 1,
1530
+ currentKey,
1531
+ iii + 1,
1532
+ iii + 1,
1533
+ test,
1534
+ currentAlias,
1535
+ iii + 1,
1536
+ packFrameLua,
1537
+ iii + 1,
1538
+ unpackFrameLua,
1539
+ iii + 1,
1540
+ primaryKeyLua,
1541
+ iii + 1,
1542
+ primaryFrameKeyLua) == -1) {
1543
+ return ERR_OUT_OF_MEMORY;
1544
+ }
1545
+ free(oldLua);
1527
1546
 
1528
- // not (expr->not)
1529
- } else {
1530
- oldPackFrameLua = packFrameLua;
1531
- if (asprintf(&packFrameLua,
1547
+ // not (expr->not)
1548
+ } else {
1549
+ oldPackFrameLua = packFrameLua;
1550
+ if (asprintf(&packFrameLua,
1532
1551
  "%s message = frame[\"%s\"]\n"
1533
1552
  " if full_encode and not message[\"$f\"] then\n"
1534
1553
  " result[%d] = message\n"
1535
1554
  " else\n"
1536
1555
  " result[%d] = message[\"id\"]\n"
1537
1556
  " end\n",
1538
- packFrameLua,
1539
- currentAlias,
1540
- iii + 1,
1541
- iii + 1) == -1) {
1542
- return ERR_OUT_OF_MEMORY;
1543
- }
1544
- free(oldPackFrameLua);
1557
+ packFrameLua,
1558
+ currentAlias,
1559
+ iii + 1,
1560
+ iii + 1) == -1) {
1561
+ return ERR_OUT_OF_MEMORY;
1562
+ }
1563
+ free(oldPackFrameLua);
1545
1564
 
1546
- oldUnpackFrameLua = unpackFrameLua;
1547
- if (asprintf(&unpackFrameLua,
1565
+ oldUnpackFrameLua = unpackFrameLua;
1566
+ if (asprintf(&unpackFrameLua,
1548
1567
  "%s message = fetch_message(frame[%d])\n"
1549
1568
  " if not message then\n"
1550
1569
  " return nil\n"
1551
1570
  " end\n"
1552
1571
  " result[\"%s\"] = message\n",
1553
- unpackFrameLua,
1554
- iii + 1,
1555
- currentAlias) == -1) {
1556
- return ERR_OUT_OF_MEMORY;
1557
- }
1558
- free(oldUnpackFrameLua);
1572
+ unpackFrameLua,
1573
+ iii + 1,
1574
+ currentAlias) == -1) {
1575
+ return ERR_OUT_OF_MEMORY;
1576
+ }
1577
+ free(oldUnpackFrameLua);
1559
1578
 
1560
- oldLua = lua;
1561
- if (asprintf(&lua,
1579
+ oldLua = lua;
1580
+ if (asprintf(&lua,
1562
1581
  "%sif toggle %s then\n"
1563
1582
  " toggle = true\n"
1564
1583
  " context_directory[\"%s\"] = context\n"
@@ -1591,40 +1610,40 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1591
1610
  " return result\n"
1592
1611
  " end\n"
1593
1612
  "end\n",
1594
- lua,
1595
- nextKeyTest,
1596
- currentKey,
1597
- iii + 1,
1598
- currentKey,
1599
- currentKey,
1600
- iii + 1,
1601
- iii + 1,
1602
- test,
1603
- currentAlias,
1604
- iii + 1,
1605
- packFrameLua,
1606
- iii + 1,
1607
- unpackFrameLua,
1608
- iii + 1,
1609
- primaryKeyLua,
1610
- iii + 1,
1611
- primaryFrameKeyLua) == -1) {
1612
- return ERR_OUT_OF_MEMORY;
1613
- }
1614
- free(oldLua);
1615
- // done not (expr->not)
1613
+ lua,
1614
+ nextKeyTest,
1615
+ currentKey,
1616
+ iii + 1,
1617
+ currentKey,
1618
+ currentKey,
1619
+ iii + 1,
1620
+ iii + 1,
1621
+ test,
1622
+ currentAlias,
1623
+ iii + 1,
1624
+ packFrameLua,
1625
+ iii + 1,
1626
+ unpackFrameLua,
1627
+ iii + 1,
1628
+ primaryKeyLua,
1629
+ iii + 1,
1630
+ primaryFrameKeyLua) == -1) {
1631
+ return ERR_OUT_OF_MEMORY;
1616
1632
  }
1617
- free(nextKeyTest);
1618
- free(test);
1619
- free(primaryKeyLua);
1620
- free(primaryFrameKeyLua);
1621
- // done not (iii == 0)
1633
+ free(oldLua);
1634
+ // done not (expr->not)
1622
1635
  }
1636
+ free(nextKeyTest);
1637
+ free(test);
1638
+ free(primaryKeyLua);
1639
+ free(primaryFrameKeyLua);
1640
+ // done not (iii == 0)
1623
1641
  }
1642
+ }
1624
1643
 
1625
- if (currentNode->value.c.span > 0) {
1626
- oldLua = lua;
1627
- if (asprintf(&lua,
1644
+ if (currentNode->value.c.span > 0) {
1645
+ oldLua = lua;
1646
+ if (asprintf(&lua,
1628
1647
  "%sif toggle then\n"
1629
1648
  " context[\"process_key\"] = process_key_with_span\n"
1630
1649
  " context[\"process_key_count\"] = %d\n"
@@ -1632,15 +1651,15 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1632
1651
  " return\n"
1633
1652
  " end\n"
1634
1653
  "end\n",
1635
- lua,
1636
- currentNode->value.c.span) == -1) {
1637
- return ERR_OUT_OF_MEMORY;
1638
- }
1639
- free(oldLua);
1654
+ lua,
1655
+ currentNode->value.c.span) == -1) {
1656
+ return ERR_OUT_OF_MEMORY;
1657
+ }
1658
+ free(oldLua);
1640
1659
 
1641
- } else if (currentNode->value.c.cap > 0) {
1642
- oldLua = lua;
1643
- if (asprintf(&lua,
1660
+ } else if (currentNode->value.c.cap > 0) {
1661
+ oldLua = lua;
1662
+ if (asprintf(&lua,
1644
1663
  "%sif toggle then\n"
1645
1664
  " context[\"process_key\"] = process_key_with_cap\n"
1646
1665
  " context[\"process_key_count\"] = %d\n"
@@ -1648,15 +1667,15 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1648
1667
  " return\n"
1649
1668
  " end\n"
1650
1669
  "end\n",
1651
- lua,
1652
- currentNode->value.c.cap) == -1) {
1653
- return ERR_OUT_OF_MEMORY;
1654
- }
1655
- free(oldLua);
1670
+ lua,
1671
+ currentNode->value.c.cap) == -1) {
1672
+ return ERR_OUT_OF_MEMORY;
1673
+ }
1674
+ free(oldLua);
1656
1675
 
1657
- } else {
1658
- oldLua = lua;
1659
- if (asprintf(&lua,
1676
+ } else {
1677
+ oldLua = lua;
1678
+ if (asprintf(&lua,
1660
1679
  "%sif toggle then\n"
1661
1680
  " context[\"process_key\"] = process_key_with_window\n"
1662
1681
  " context[\"process_key_count\"] = %d\n"
@@ -1664,17 +1683,16 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
1664
1683
  " return\n"
1665
1684
  " end\n"
1666
1685
  "end\n",
1667
- lua,
1668
- currentNode->value.c.count) == -1) {
1669
- return ERR_OUT_OF_MEMORY;
1670
- }
1671
- free(oldLua);
1686
+ lua,
1687
+ currentNode->value.c.count) == -1) {
1688
+ return ERR_OUT_OF_MEMORY;
1672
1689
  }
1690
+ free(oldLua);
1673
1691
  }
1674
-
1675
- free(unpackFrameLua);
1676
- free(packFrameLua);
1677
1692
  }
1693
+
1694
+ free(unpackFrameLua);
1695
+ free(packFrameLua);
1678
1696
  }
1679
1697
 
1680
1698
  oldLua = lua;
@@ -2073,22 +2091,22 @@ static unsigned int loadEvalMessageCommand(ruleset *tree, binding *rulesBinding)
2073
2091
  " key = ARGV[index]\n"
2074
2092
  " context = context_directory[key]\n"
2075
2093
  " if context then\n"
2076
- " keys = context[\"keys\"]\n"
2077
- " reviewers = context[\"reviewers\"]\n"
2078
- " frame_packers = context[\"frame_packers\"]\n"
2079
- " frame_unpackers = context[\"frame_unpackers\"]\n"
2080
- " primary_message_keys = context[\"primary_message_keys\"]\n"
2081
- " primary_frame_keys = context[\"primary_frame_keys\"]\n"
2082
- " directory = context[\"directory\"]\n"
2083
- " results_key = context[\"results_key\"]\n"
2084
- " inverse_directory = context[\"inverse_directory\"]\n"
2085
- " expressions_count = context[\"expressions_count\"]\n"
2086
- " local process_key = context[\"process_key\"]\n"
2087
- " local process_key_count = context[\"process_key_count\"]\n"
2088
- " queue_action = process_key(message, process_key_count) or queue_action\n"
2089
- " if assert_fact == 0 and events_message_cache[tostring(message[\"id\"])] == false then\n"
2090
- " break\n"
2091
- " end\n"
2094
+ " keys = context[\"keys\"]\n"
2095
+ " reviewers = context[\"reviewers\"]\n"
2096
+ " frame_packers = context[\"frame_packers\"]\n"
2097
+ " frame_unpackers = context[\"frame_unpackers\"]\n"
2098
+ " primary_message_keys = context[\"primary_message_keys\"]\n"
2099
+ " primary_frame_keys = context[\"primary_frame_keys\"]\n"
2100
+ " directory = context[\"directory\"]\n"
2101
+ " results_key = context[\"results_key\"]\n"
2102
+ " inverse_directory = context[\"inverse_directory\"]\n"
2103
+ " expressions_count = context[\"expressions_count\"]\n"
2104
+ " local process_key = context[\"process_key\"]\n"
2105
+ " local process_key_count = context[\"process_key_count\"]\n"
2106
+ " queue_action = process_key(message, process_key_count) or queue_action\n"
2107
+ " if assert_fact == 0 and events_message_cache[tostring(message[\"id\"])] == false then\n"
2108
+ " break\n"
2109
+ " end\n"
2092
2110
  " end\n"
2093
2111
  " end\n"
2094
2112
  " if queue_action then\n"
data/src/rules/regex.c CHANGED
@@ -189,7 +189,6 @@ unsigned int utf8ToUnicode(char **first, char *last, unsigned int *result) {
189
189
  if (*first + byteNumber >= last) {
190
190
  return ERR_PARSE_REGEX;
191
191
  }
192
-
193
192
  *result = 0;
194
193
  switch (byteNumber) {
195
194
  case 3:
@@ -460,6 +459,10 @@ static unsigned int readNextToken(char **first,
460
459
  char *last,
461
460
  token *nextToken) {
462
461
  unsigned int result = REGEX_PARSE_OK;
462
+ nextToken->low = 0;
463
+ nextToken->high = 0;
464
+ nextToken->symbolsLength = 0;
465
+ nextToken->inverseSymbolsLength = 0;
463
466
  if (*first >= last) {
464
467
  return REGEX_PARSE_END;
465
468
  }
data/src/rules/rete.c CHANGED
@@ -1084,23 +1084,6 @@ static unsigned int findAlpha(ruleset *tree,
1084
1084
  return linkAlpha(tree, parentOffset, *resultOffset);
1085
1085
  }
1086
1086
 
1087
- static void getSymbolSetting(unsigned int settingHash, char *rule, unsigned int *symbolHash) {
1088
- char *first;
1089
- char *last;
1090
- unsigned int hash;
1091
- unsigned char type;
1092
- unsigned int result = readNextName(rule, &first, &last, &hash);
1093
- while (result == PARSE_OK) {
1094
- if (hash == settingHash) {
1095
- readNextString(last, &first, &last, symbolHash);
1096
- break;
1097
- } else {
1098
- readNextValue(last, &first, &last, &type);
1099
- result = readNextName(last, &first, &last, &hash);
1100
- }
1101
- }
1102
- }
1103
-
1104
1087
  static void getSetting(unsigned int settingHash, char *rule, unsigned short *value) {
1105
1088
  char *first;
1106
1089
  char *last;
@@ -1696,12 +1679,10 @@ static unsigned int createTree(ruleset *tree, char *rules) {
1696
1679
  ruleAction->value.c.count = 0;
1697
1680
  ruleAction->value.c.span = 0;
1698
1681
  ruleAction->value.c.cap = 0;
1699
- ruleAction->value.c.partitionBy = 0;
1700
1682
  getSetting(HASH_PRI, first, &ruleAction->value.c.priority);
1701
1683
  getSetting(HASH_COUNT, first, &ruleAction->value.c.count);
1702
1684
  getSetting(HASH_SPAN, first, &ruleAction->value.c.span);
1703
1685
  getSetting(HASH_CAP, first, &ruleAction->value.c.cap);
1704
- getSymbolSetting(HASH_BY, first, &ruleAction->value.c.partitionBy);
1705
1686
  if (!ruleAction->value.c.count && !ruleAction->value.c.span && !ruleAction->value.c.cap) {
1706
1687
  ruleAction->value.c.count = 1;
1707
1688
  }
data/src/rules/rete.h CHANGED
@@ -95,7 +95,6 @@ typedef struct action {
95
95
  unsigned short span;
96
96
  unsigned short count;
97
97
  unsigned short cap;
98
- unsigned int partitionBy;
99
98
  unsigned short priority;
100
99
  unsigned int joinsOffset;
101
100
  unsigned short joinsLength;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: durable_rules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.17
4
+ version: 0.34.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesus Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-23 00:00:00.000000000 Z
11
+ date: 2017-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake