MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / normalize_index

Function normalize_index

src/gpre/exp.cpp:1019–1057  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1017//
1018
1019static gpre_nod* normalize_index( dim* dimension, gpre_nod* user_index, USHORT array_base)
1020{
1021 TEXT string[33];
1022 bool negate = false;
1023
1024 switch (array_base)
1025 {
1026 case ZERO_BASED:
1027 if (dimension->dim_lower < 0)
1028 negate = true;
1029 sprintf(string, "%d", abs(dimension->dim_lower));
1030 break;
1031
1032 case ONE_BASED:
1033 if (dimension->dim_lower - 1 < 0)
1034 negate = true;
1035 sprintf(string, "%d", abs(dimension->dim_lower - 1));
1036 break;
1037
1038 default:
1039 return user_index;
1040 }
1041
1042 ref* reference = (ref*) MSC_alloc(REF_LEN);
1043 char* tmp = (TEXT *) MSC_alloc(static_cast<int>(strlen(string)));
1044 reference->ref_value = tmp;
1045 strcpy(tmp, string);
1046 gpre_nod* adjustment_node = MSC_unary(nod_literal, (gpre_nod*) reference);
1047
1048 gpre_nod* negate_node;
1049 if (negate)
1050 negate_node = MSC_unary(nod_negate, adjustment_node);
1051 else
1052 negate_node = adjustment_node;
1053
1054 gpre_nod* index_node = MSC_binary(nod_plus, negate_node, user_index);
1055
1056 return index_node;
1057}
1058
1059
1060//____________________________________________________________

Callers 1

par_arrayFunction · 0.85

Calls 4

absFunction · 0.85
MSC_allocFunction · 0.85
MSC_unaryFunction · 0.85
MSC_binaryFunction · 0.85

Tested by

no test coverage detected