| 1011 | } |
| 1012 | |
| 1013 | void PiuCode_find(xsMachine *the) |
| 1014 | { |
| 1015 | PiuCode* self = PIU(Code, xsThis); |
| 1016 | uint32_t argc = xsToUnsigned(xsArgc); |
| 1017 | xsStringValue pattern = NULL; |
| 1018 | xsBooleanValue caseless = 0; |
| 1019 | PiuTextBuffer* results = (*self)->results; |
| 1020 | PiuCodeResult result; |
| 1021 | if (argc > 1) |
| 1022 | caseless = xsToBoolean(xsArg(1)); |
| 1023 | if (argc > 0) |
| 1024 | pattern = xsToString(xsArg(0)); |
| 1025 | if ((*self)->code || (*self)->data) { |
| 1026 | fxDeleteRegExp(NULL, (*self)->code, (*self)->data); |
| 1027 | (*self)->code = NULL; |
| 1028 | (*self)->data = NULL; |
| 1029 | } |
| 1030 | if (pattern && pattern[0]) { |
| 1031 | xsStringValue modifier = (caseless) ? "imu" : "mu"; |
| 1032 | fxCompileRegExp(NULL, pattern, modifier, &(*self)->code, &(*self)->data, NULL, 0); |
| 1033 | } |
| 1034 | PiuCodeSearch(self, (*self)->size); |
| 1035 | result = (PiuCodeResult)((char*)(*results) + sizeof(PiuTextBufferRecord)); |
| 1036 | if (result->count >= 0) { |
| 1037 | xsResult = xsTrue; |
| 1038 | while (result->count >= 0) { |
| 1039 | if ((*self)->from <= result->from) { |
| 1040 | PiuCodeSelect(self, result->from, result->to - result->from); |
| 1041 | return; |
| 1042 | } |
| 1043 | result = (PiuCodeResult)(((char*)result) + (*self)->resultsSize); |
| 1044 | } |
| 1045 | result = (PiuCodeResult)((char*)(*results) + sizeof(PiuTextBufferRecord)); |
| 1046 | PiuCodeSelect(self, result->from, result->to - result->from); |
| 1047 | } |
| 1048 | else { |
| 1049 | xsResult = xsFalse; |
| 1050 | PiuCodeSelect(self, (*self)->from, 0); |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | void PiuCode_findAgain(xsMachine *the) |
| 1055 | { |
nothing calls this directly
no test coverage detected