@@ -86,16 +86,24 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
86
86
{
87
87
grib_expression_functor* e = (grib_expression_functor*)g;
88
88
89
- if (strcmp (e->name , " lookup" ) == 0 ) {
89
+ if (STR_EQUAL (e->name , " lookup" )) {
90
90
return GRIB_SUCCESS;
91
91
}
92
92
93
- if (strcmp (e->name , " new" ) == 0 ) {
93
+ if (STR_EQUAL (e->name , " new" )) {
94
94
*lres = h->loader != NULL ;
95
95
return GRIB_SUCCESS;
96
96
}
97
97
98
- if (strcmp (e->name , " missing" ) == 0 ) {
98
+ if (STR_EQUAL (e->name , " abs" )) {
99
+ grib_expression* exp = grib_arguments_get_expression (h, e->args , 0 );
100
+ long lval = 0 ;
101
+ int ret = grib_expression_evaluate_long (h, exp, &lval);
102
+ *lres = abs (lval);
103
+ return ret;
104
+ }
105
+
106
+ if (STR_EQUAL (e->name , " missing" )) {
99
107
const char * p = grib_arguments_get_name (h, e->args , 0 );
100
108
if (p) {
101
109
long val = 0 ;
@@ -122,7 +130,7 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
122
130
return GRIB_SUCCESS;
123
131
}
124
132
125
- if (strcmp (e->name , " defined" ) == 0 ) {
133
+ if (STR_EQUAL (e->name , " defined" )) {
126
134
const char * p = grib_arguments_get_name (h, e->args , 0 );
127
135
128
136
if (p) {
@@ -134,7 +142,7 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
134
142
return GRIB_SUCCESS;
135
143
}
136
144
137
- if (strcmp (e->name , " environment_variable" ) == 0 ) {
145
+ if (STR_EQUAL (e->name , " environment_variable" )) {
138
146
// ECC-1520: This implementation has some limitations:
139
147
// 1. Cannot distinguish between environment variable NOT SET
140
148
// and SET but equal to 0
@@ -154,12 +162,12 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres)
154
162
return GRIB_SUCCESS;
155
163
}
156
164
157
- if (strcmp (e->name , " changed" ) == 0 ) {
165
+ if (STR_EQUAL (e->name , " changed" )) {
158
166
*lres = 1 ;
159
167
return GRIB_SUCCESS;
160
168
}
161
169
162
- if (strcmp (e->name , " gribex_mode_on" ) == 0 ) {
170
+ if (STR_EQUAL (e->name , " gribex_mode_on" )) {
163
171
*lres = h->context ->gribex_mode_on ? 1 : 0 ;
164
172
return GRIB_SUCCESS;
165
173
}
0 commit comments