This file is indexed.

/usr/share/calc/hms.cal is in apcalc-common 2.12.5.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
/*
 * hms - calculate in hours, minutes, and seconds
 *
 * Copyright (C) 2010  Landon Curt Noll
 *
 * Calc is open software; you can redistribute it and/or modify it under
 * the terms of the version 2.1 of the GNU Lesser General Public License
 * as published by the Free Software Foundation.
 *
 * Calc is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU Lesser General
 * Public License for more details.
 *
 * A copy of version 2.1 of the GNU Lesser General Public License is
 * distributed with calc under the filename COPYING-LGPL.  You should have
 * received a copy with calc; if not, write to Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * @(#) $Revision: 30.2 $
 * @(#) $Id: hms.cal,v 30.2 2010/09/02 06:14:16 chongo Exp $
 * @(#) $Source: /usr/local/src/bin/calc/cal/RCS/hms.cal,v $
 *
 * Under source code control:	2010/09/01 17:14:55
 * File existed as early as:	2010
 *
 * Share and enjoy!  :-)	http://www.isthe.com/chongo/tech/comp/calc/
 */


obj hms {hour, min, sec};

define hms(hour, min, sec)
{
    local obj hms ans;		/* return value */

    /* default missing args to 0 */
    if (isnull(sec)) {
	sec = 0;
    }
    if (isnull(min)) {
	min = 0;
    }

    /* load object */
    ans.hour = hour;
    ans.min = min;
    ans.sec = sec;

    /* return properly formed object */
    ans = fixhms(ans);
    return ans;
}


define hms_add(a, b)
{
    local obj hms ans;		/* return value */

    /* initalize value to 1st arg */
    if (istype(a, ans)) {
	/* 1st arg is hms object, load it */
	ans.hour = a.hour;
	ans.min = a.min;
	ans.sec = a.sec;
    } else {
	/* 1st arg is not hms, assume scalar hours */
	ans.hour = a;
	ans.min = 0;
	ans.sec = 0;
    }

    /* add value of 2nd arg */
    if (istype(b, ans)) {
	/* 2nd arg is hms object, add it */
	ans.hour += b.hour;
	ans.min += b.min;
	ans.sec += b.sec;
    } else {
	/* 2nd arg is not hms, add scalar hours */
	ans.hour += b;
    }

    /* return normalized result */
    ans = fixhms(ans);
    return ans;
}


define hms_neg(a)
{
    local obj hms ans;		/* return value */

    /* negate argument */
    if (istype(a, ans)) {
	/* 1st arg is hms object, load it */
	ans.hour = -a.hour;
	ans.min = -a.min;
	ans.sec = -a.sec;
    } else {
	/* 2nd arg is not hms, negate scalar hours */
	ans.hour = -a;
	ans.min = 0;
	ans.sec = 0;
    }

    /* return normalized result */
    ans = fixhms(ans);
    return ans;
}


define hms_sub(a, b)
{
    local obj hms ans;		/* return value */

    /* initalize value to 1st arg */
    if (istype(a, ans)) {
	/* 1st arg is hms object, load it */
	ans.hour = a.hour;
	ans.min = a.min;
	ans.sec = a.sec;
    } else {
	/* 1st arg is not hms, assume scalar hours */
	ans.hour = a;
	ans.min = 0;
	ans.sec = 0;
    }

    /* subtract value of 2nd arg */
    if (istype(b, ans)) {
	/* 2nd arg is hms object, subtract it */
	ans.hour -= b.hour;
	ans.min -= b.min;
	ans.sec -= b.sec;
    } else {
	/* 2nd arg is not hms, subtract scalar hours */
	ans.hour -= b;
    }

    /* return normalized result */
    ans = fixhms(ans);
    return ans;
}


define hms_mul(a, b)
{
    local obj hms ans;		/* return value */

    /* hms object multiplication */
    if (istype(a, ans) && istype(b, ans)) {
	ans.hour = hms_abs(a) * hms_abs(b);
	ans.min = 0;
	ans.sec = 0;

    /* scalar multiplication */
    } else if (istype(a, ans)) {
	ans.hour = a.hour * b;
	ans.min = a.min * b;
	ans.sec = a.sec * b;
    } else {
	ans.hour = b.hour * a;
	ans.min = b.min * a;
	ans.sec = b.sec * a;
    }

    /* return normalized result */
    ans = fixhms(ans);
    return ans;
}


define hms_print(a)
{
    local obj hms ans;		/* temp object for hms type testing */

    /* firewall - arg must be a hms object */
    if (! istype(a, ans)) {
	quit "hms_print called with non hms object";
    }

    /* print in hms form */
    print a.hour : ':' : a.min : ':' : a.sec :;
}


define hms_abs(a)
{
    local obj hms ans;		/* temp object for hms type testing */
    local hour;			/* return scalar value */

    /* firewall - just absolute value non hms objects */
    if (! istype(a, ans)) {
    	return abs(a);
    }

    /* compute hours */
    hour = a.hour + a.min / 60 + a.sec / 3600;

    /* return hours */
    return hour;
}


define hms_norm(a)
{
    local obj hms ans;		/* temp object for hms type testing */
    local hour;			/* hours */

    /* firewall - arg must be a hms object */
    if (! istype(a, ans)) {
	quit "hms_norm called with non hms object";
    }

    /* square hours (norm is the square of absolute value */
    hour = hms_abs(a);

    /* return hours */
    return hour*hour;
}


define hms_test(a)
{
    local obj hms ans;		/* temp value */

    /* firewall - arg must be a hms object */
    if (! istype(a, ans)) {
	quit "hms_test called with non hms object";
    }

    /* return false of non-zero */
    ans = fixhms(a);
    if (ans.hour == 0 && ans.min == 0 && ans.sec == 0) {
	/* false */
	return 0;
    }
    /* true */
    return 1;
}


define hms_int(a)
{
    local obj hms ans;		/* return value */

    /* firewall - arg must be a hms object */
    if (! istype(a, ans)) {
	quit "hms_int called with non hms object";
    }

    /* normalize the argument */
    ans = fixhms(a);

    /* truncate to the nearest second */
    ans.sec = int(ans.sec);

    /* return value to the nearest second */
    return ans;
}


define hms_frac(a)
{
    local obj hms ans;		/* return value */

    /* firewall - arg must be a hms object */
    if (! istype(a, ans)) {
	quit "hms_frac called with non hms object";
    }

    /* normalize the argument */
    ans = fixhms(a);

    /* remove all but fractional seconds */
    ans.hour = 0;
    ans.min = 0;
    ans.sec = frac(ans.sec);

    /* return value to the second fraction */
    return ans;
}


define hms_rel(a,b)
{
    local abs_a, abs_b;		/* scalars of the arguments */

    /* compute scalars of the arguments */
    abs_a = hms_abs(a);
    abs_b = hms_abs(b);

    /* return the comparison */
    return cmp(abs_a, abs_b);
}


define hms_cmp(a,b)
{
    local abs_a, abs_b;		/* scalars of the arguments */

    /* compute scalars of the arguments */
    abs_a = hms_abs(a);
    abs_b = hms_abs(b);

    /* return the equality comparison */
    return (abs_a == abs_b);
}


define hms_inc(a)
{
    local obj hms ans;		/* return value */

    /* increment a hms object */
    if (istype(a, ans)) {
	ans = a;
	++ans.sec;

	/* return normalized result */
	ans = fixhms(ans);
	return ans;
    }

    /* increment a scalar */
    return a+1;
}


define hms_dec(a)
{
    local obj hms ans;		/* return value */

    /* decrement a hms object */
    if (istype(a, ans)) {
	ans = a;
	--ans.sec;

	/* return normalized result */
	ans = fixhms(ans);
	return ans;
    }

    /* decrement a scalar */
    return a-1;
}


define fixhms(a)
{
    local obj hms ans;		/* temp value */

    /* firewall */
    if (! istype(a, ans)) {
	quit "attempt to fix a non hms object";
    }

    /* force minutes to be intergral */
    a.min += frac(a.hour) * 60;
    a.hour = int(a.hour);

    /* force hours to be intergral */
    a.sec += frac(a.min) * 60;
    a.min = int(a.min);

    /* carry excess seconds into minutes */
    a.min += a.sec // 60;
    a.sec %= 60;

    /* carry excess minutes into hours */
    a.hour += a.min // 60;
    a.min %= 60;

    /* round hours by day */
    a.hour %= 24;

    /* return normalized result */
    return a;
}

if (config("resource_debug") & 3) {
    print "obj hms {hour, min, sec} defined";
}