This file is indexed.

/usr/share/calc/dms.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
/*
 * dms - calculate in degrees, minutes, and seconds (based on deg)
 *
 * Copyright (C) 1999,2010  David I. Bell and 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: dms.cal,v 30.2 2010/09/02 06:14:16 chongo Exp $
 * @(#) $Source: /usr/local/src/bin/calc/cal/RCS/dms.cal,v $
 *
 * Under source code control:	1990/02/15 01:50:33
 * File existed as early as:	before 1990
 *
 * Share and enjoy!  :-)	http://www.isthe.com/chongo/tech/comp/calc/
 */


obj dms {deg, min, sec};

define dms(deg, min, sec)
{
    local obj dms ans;		/* return value */

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

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

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


define dms_add(a, b)
{
    local obj dms ans;		/* return value */

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

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

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


define dms_neg(a)
{
    local obj dms ans;		/* return value */

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

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


define dms_sub(a, b)
{
    local obj dms ans;		/* return value */

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

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

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


define dms_mul(a, b)
{
    local obj dms ans;		/* return value */

    /* dms object multiplication */
    if (istype(a, ans) && istype(b, ans)) {
	ans.deg = dms_abs(a) * dms_abs(b);
	ans.min = 0;
	ans.sec = 0;

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

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


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

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

    /* print in dms form */
    print a.deg : 'd' : a.min : 'm' : a.sec : 's' :;
}


define dms_abs(a)
{
    local obj dms ans;		/* temp object for dms type testing */
    local deg;			/* return scalar value */

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

    /* compute degrees */
    deg = a.deg + a.min / 60 + a.sec / 3600;

    /* return degrees */
    return deg;
}


define dms_norm(a)
{
    local obj dms ans;		/* temp object for dms type testing */
    local deg;			/* degrees */

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

    /* square degrees (norm is the square of absolute value */
    deg = dms_abs(a);

    /* return degrees */
    return deg*deg;
}


define dms_test(a)
{
    local obj dms ans;		/* temp value */

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

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


define dms_int(a)
{
    local obj dms ans;		/* return value */

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

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

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

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


define dms_frac(a)
{
    local obj dms ans;		/* return value */

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

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

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

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


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

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

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


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

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

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


define dms_inc(a)
{
    local obj dms ans;		/* return value */

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

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

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


define dms_dec(a)
{
    local obj dms ans;		/* return value */

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

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

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


define fixdms(a)
{
    local obj dms ans;		/* temp value */

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

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

    /* force degrees 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 degrees */
    a.deg += a.min // 60;
    a.min %= 60;

    /* round degrees :-) */
    a.deg %= 360;

    /* return normalized result */
    return a;
}

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