MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / find_match

Function find_match

libsigrokdecode4DSL/instance.c:938–1004  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

936}
937
938static gboolean
939find_match(struct srd_decoder_inst *di)
940{
941 uint64_t j;
942 GSList *l, *cond;
943 gboolean skip_allow;
944 gboolean all_skip_allow = TRUE;
945
946 /* Caller ensures di != NULL. */
947
948 /* Check whether the condition list is NULL/empty. */
949 if (!di->condition_list) {
950 srd_dbg("NULL/empty condition list, automatic match.");
951 return TRUE;
952 }
953
954 /* Check whether we have any non-NULL conditions. */
955 if (!have_non_null_conds(di)) {
956 srd_dbg("Only NULL conditions in list, automatic match.");
957 return TRUE;
958 }
959
960 /* di->match_array is 0 here. Create a new GArray. */
961 di->match_array = 0;
962
963 /* Sample 0: Set di->old_pins_array for SRD_INITIAL_PIN_SAME_AS_SAMPLE0 pins. */
964 if (di->first_pos) {
965 di->first_pos = FALSE;
966 update_old_pins_array_initial_pins(di);
967 }
968
969 if (di->abs_cur_matched)
970 di->abs_cur_samplenum++;
971
972 while (di->abs_cur_samplenum < di->abs_end_samplenum) {
973
974 /* Check whether the current sample matches at least one of the conditions (logical OR). */
975 /* IMPORTANT: We need to check all conditions, even if there was a match already! */
976 for (l = di->condition_list, j = 0; l; l = l->next, j++) {
977 cond = l->data;
978 if (!cond)
979 continue;
980
981 /* All terms in 'cond' must match (logical AND). */
982 if (all_terms_match(di, cond, &skip_allow)) {
983 all_skip_allow = FALSE;
984 di->match_array |= (1 << j);
985 } else {
986 all_skip_allow &= skip_allow;
987 }
988 }
989
990 update_old_pins_array(di);
991
992 /* If at least one condition matched we're done. */
993 di->abs_cur_matched = (di->match_array != 0);
994 if (di->abs_cur_matched)
995 return TRUE;

Callers 1

Calls 4

have_non_null_condsFunction · 0.85
all_terms_matchFunction · 0.85
update_old_pins_arrayFunction · 0.85

Tested by

no test coverage detected