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 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864
|
/*
* rc-use.c: Central function, manages the resource file handling
* and displays the results.
*
*
* Copyright (c) 1994, 95, 96, 1997, 2000, 2011 Thomas Esken
* Copyright (c) 2010, 2011 Free Software Foundation, Inc.
*
* This software doesn't claim completeness, correctness or usability.
* On principle I will not be liable for ANY damages or losses (implicit
* or explicit), which result from using or handling my software.
* If you use this software, you agree without any exception to this
* agreement, which binds you LEGALLY !!
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the `GNU General Public License' as published by
* the `Free Software Foundation'; either version 3, or (at your option)
* any later version.
*
* You should have received a copy of the `GNU General Public License'
* along with this program; if not, write to the:
*
*/
/*
* Include definition header file to see whether USE_RC is defined there.
* Compile this module only if USE_RC is defined, otherwise skip it.
*/
#include "tailor.h"
#if USE_RC
/*
* Include header files.
*/
# if HAVE_ASSERT_H
# include <assert.h>
# endif
# if HAVE_CTYPE_H
# include <ctype.h>
# endif
# if HAVE_LIMITS_H
# include <limits.h>
# endif
# include "common.h"
# include "rc-defs.h"
# include "globals.h"
# include "file-io.h"
# include "hd-defs.h"
# include "hd-use.h"
# include "rc-astro.h"
# include "rc-check.h"
# include "rc-insert.h"
# include "rc-utils.h"
# include "tty.h"
# include "utils.h"
# include "rc-use.h"
/*
* static functions prototypes.
*/
__BEGIN_DECLARATIONS
/*
************************************************** Defined in `rc-use.c'.
*/
static void try_to_include_file __P_ ((int ed, int wd));
static void
display_table __P_ ((const int tmp_ad,
const int tmp_am,
const int tmp_ay, int day, int ed, int wd));
static int fn_asc_sort __P_ ((const char **a, const char **b));
static int fn_des_sort __P_ ((const char **a, const char **b));
__END_DECLARATIONS
/*
* GLOBAL variables definitions.
*/
/* Date variables a[=MMDD]...z[] (YYYY@{a|b|...|z}[[-]N]). */
Dvar_struct rc_dvar[RC_DVAR_MAX];
/* Text variables $a[=TEXT]...$z[]. */
Tvar_struct rc_tvar[RC_TVAR_MAX];
/* Local co-ordinates used by both the %distance and %sun* special texts. */
Coor_struct lcoor1;
/* Points to the local co-ordinates 1. */
Coor_struct *coor1 = &lcoor1;
/* Local co-ordinates used by the %distance special text. */
Coor_struct lcoor2;
/* Points to the local co-ordinates 2. */
Coor_struct *coor2 = &lcoor2;
/* Pointers to different parts of a (resource file) line. */
Line_struct *lineptrs = (Line_struct *) NULL;
/* Pointers to different parts of a (resource file) line. */
Line_struct *lptrs = (Line_struct *) NULL;
/* Pointers to different parts of a (resource file) line. */
Line_struct *lptrs2 = (Line_struct *) NULL;
/* Pointers to different parts of a (resource file) line. */
Line_struct *lptrs3 = (Line_struct *) NULL;
/* Temporary file used when a command is assigned to a TVAR. */
FILE *rc_tvar_tfp = (FILE *) NULL;
/* Temporary file used for managing `--here=ARG' options. */
FILE *rc_here_fp = (FILE *) NULL;
/* Time displacement value in days used by %sun* and %moon*
(also used as cycle-starting time value for %sun* and %moon* special texts). */
double time_offset = 0.0;
/* Atmospheric pressure in millibar (`--atmosphere=PRESSURE,TEMPERATURE'). */
double atm_pressure = DEFAULT_PRESSURE;
/* Atmospheric temperature in degrees Celsius (`--atmosphere=PRESSURE,TEMPERATURE'). */
double atm_temperature = DEFAULT_TEMPERATURE;
/* Adjust rise/set-based reference altitude resp. shadow length factor (`--adjust-value=NUMBER'). */
double adjust_value = DEGS_PER_24_HOURS;
/* Actual size of `rc_elems_table[]'. */
Uint rc_elems_max = RC_ELEMS_MAX;
/* Amount of period of fixed dates. */
int rc_period = 0;
/* Amount of resource file entries. */
int rc_elems = 0;
/* Starting index of dummy resource file entries in table. */
int rc_zero_pos = 0;
/* `-cd'. */
int rc_have_today_in_list = 0;
/* Length of a single axis of a biorhythm text graphics bar. */
int rc_bio_axis_len = BIO_AXIS_DEF;
/* Number of lines of a Moon phase text graphics image. */
int rc_moonimage_lines = MOONIMAGE_DEF;
/* Filler length of week number text. */
int len_fil_wt = 0;
/* Actual size of text buffer of "text"-part of a line. */
int len_the_text = 0;
/* Cycle-ending time value in minutes for %sun* and %moon* special texts. */
int loop_end = SPECIAL_VALUE;
/* Cycle-timestep value in minutes for %sun* and %moon* special texts. */
int loop_step = DEFAULT_CYCLE_STEP;
/* Actual GMT minute. */
int gmt_min = 0;
/* Actual GMT hour. */
int gmt_hour = 0;
/* Buffer of actual GMT day. */
int buf_gd = 0;
/* Buffer of actual GMT month. */
int buf_gm = 0;
/* Buffer of actual GMT year. */
int buf_gy = 0;
/* Day difference of GMT and local date. */
int gmt_loc_diff = 0;
/* Indicates whether event also appears in next year. */
int incr_year = 0;
/* Indicates whether event also appears in previous year. */
int decr_year = 0;
/* Day of event found in line. */
int d = 0;
/* Month of event found in line. */
int m = 0;
/* Year of event found in line. */
int y = 0;
/* Buffered day of event. */
int d_buf = 0;
/* Buffered month of event. */
int m_buf = 0;
/* The `N'th weekday of month' displacement value. */
int hn = 0;
/* The weekday number of `N'th weekday of month'. */
int hwd = 0;
/* Name of tempfile used when a command is assigned to a TVAR. */
char *rc_tvar_tfn = (char *) NULL;
/* Name of tempfile used for managing `--here=ARG' options. */
char *rc_here_fn = (char *) NULL;
/* Text buffer of "text"-part of a line. */
char *the_text = (char *) NULL;
/* General purpose text buffer 5. */
char *s5 = (char *) NULL;
/* General purpose text buffer 6. */
char *s6 = (char *) NULL;
/* General purpose text buffer 7. */
char *s7 = (char *) NULL;
/* Text buffer of a line read from a resource file. */
char *line_buffer = (char *) NULL;
/* Stores the valid fixed date texts. */
char **rc_elems_table = (char **) NULL;
/* Text of modified actual date %DATE. */
char *rc_adate = (char *) NULL;
/* Name of alternative resource file(s) `-f|F<NAME[+...]>'. */
char *rc_filename = (char *) NULL;
/* Argument used for filtering fixed date days. */
char *rc_filter_day = (char *) NULL;
/* Argument used for filtering fixed date periods. */
char *rc_filter_period = (char *) NULL;
/* REGEX used for filtering fixed date texts. */
char *rc_filter_text = (char *) NULL;
/* Fixed date list grouping separator `-cg[TEXT]'. */
char *rc_grp_sep = (char *) NULL;
/* Fixed date list heading text `--heading-text=TEXT'. */
char *rc_heading_text = (char *) NULL;
/* The biorhythm's "Emo" text. */
char *rc_bio_emo_lit = (char *) NULL;
/* The biorhythm's "Int" text. */
char *rc_bio_int_lit = (char *) NULL;
/* The biorhythm's "Phy" text. */
char *rc_bio_phy_lit = (char *) NULL;
/* The mode specifying character. */
char hc = '\0';
/* `-jc'. */
Bool rc_special_flag = FALSE;
/* `-jcb'. */
Bool rc_both_dates_flag = FALSE;
/* `-c'. */
Bool rc_use_flag = FALSE;
/* `-C[]' or `-C[][T|W|M|Y]' or `-c[][T|W|M|Y]' or `-F<>'. */
Bool rc_all_dates_flag = FALSE;
/* `-c-'. */
Bool rc_sort_des_flag = FALSE;
/* `-ca'. */
Bool rc_enable_fn_flag = FALSE;
/* `-cA'. */
Bool rc_alternative_format_flag = FALSE;
/* `--execute-command'. */
Bool rc_execute_command = FALSE;
/* `-ce'. */
Bool rc_enable_hda_flag = FALSE;
/* `-cE'. */
Bool rc_enable_hdl_flag = FALSE;
/* `-ck'. */
Bool rc_week_number_flag = FALSE;
/* `-cl'. */
Bool rc_period_list = FALSE;
/* `-co'. */
Bool rc_omit_date_flag = FALSE;
/* `-cU'. */
Bool rc_suppr_date_part_flag = FALSE;
/* `-cQ'. */
Bool rc_suppr_list_sep_flag = FALSE;
/* `-cJ'. */
Bool rc_suppr_text_part_flag = FALSE;
/* `-cx'. */
Bool rc_title_flag = TRUE;
/* `-cz'. */
Bool rc_count_flag = FALSE;
/* `-cZ'. */
Bool rc_zero_dates_flag = FALSE;
/* `-cN[d|w|+|-]|MMDD|MMWW[W]N'. */
Bool rc_period_flag = FALSE;
/* `-c]t'. */
Bool rc_tomorrow_flag = FALSE;
/* `-c]w'. */
Bool rc_week_flag = FALSE;
/* `-c]m'. */
Bool rc_month_flag = FALSE;
/* `-c]y'. */
Bool rc_year_flag = FALSE;
/* `-cNw'. */
Bool rc_week_year_flag = FALSE;
/* `-c<N|w|m|y>+'. */
Bool rc_forwards_flag = FALSE;
/* Buffers the state of `rc_forwards_flag'. */
Bool rc_fwdf_buffer = FALSE;
/* `-c<N|w|m|y>-'. */
Bool rc_backwards_flag = FALSE;
/* Buffers the state of `rc_backwards_flag'. */
Bool rc_bwdf_buffer = FALSE;
/* `--leap-day=february'. */
Bool rc_feb_29_to_feb_28 = FALSE;
/* `--leap-day=march'. */
Bool rc_feb_29_to_mar_01 = FALSE;
/* `--precise' to display precise, non-rounded, times and data. */
Bool rc_precise = FALSE;
/* `--export-date-variables'. */
Bool rc_export_ldvar_flag = FALSE;
/* `--export-text-variables'. */
Bool rc_export_ltvar_flag = FALSE;
/* `--ignore-case' to ignore case distinctions in PATTERN. */
Bool rc_ignore_case_flag = FALSE;
/* `--limit' to calculate rise/set times limited to the current day only. */
Bool rc_limit = FALSE;
/* `--revert-match' to select non-matching PATTERN lines. */
Bool rc_revert_match_flag = FALSE;
/* Is a command (explicit date) given in the command line? */
Bool is_date_given = FALSE;
/* Does the command enables a year implicitly? */
Bool date_enables_year = FALSE;
/* Stores whether a %shell escape special text is run. */
Bool shell_escape_done = FALSE;
/* `-cNw' and complete week is in month. */
Bool is_1month_mode = FALSE;
/* `-cNw' and only part of week is in month. */
Bool is_2month_mode = FALSE;
/* Reference to a date variable found in line. */
Bool is_2dvar = FALSE;
/* Reference to Easter Sundays date found in line. */
Bool is_2easter = FALSE;
/* `-cNw' and actual date modified. */
Bool adate_set = FALSE;
/* Remove highlighting sequences before searching PATTERN? */
Bool remove_hls_in_regex = FALSE;
/*
* The REGEX stuff; global variables that represent the "remembered" search PATTERN.
*/
# if HAVE_GNU_RE_COMPILE_PATTERN
struct re_pattern_buffer regpattern;
char *gnu_fastmap_table = (char *) NULL;
unsigned char *gnu_translate_table = (unsigned char *) NULL;
# endif
# if HAVE_POSIX_REGCOMP
regex_t regpattern;
# endif
# if HAVE_RE_COMP
int re_pattern = 0;
# endif
/*
* static variables definitions.
*/
/* Table of resource/include file buffers. */
static File_struct **rc_files_table = (File_struct **) NULL;
/* Actual size of `rc_files_table[]'. */
static Uint rc_files_max = RC_FILES_MAX;
/* Amount of resource file buffers. */
static int rc_files = 0;
/* Number of characters in `line_buffer'. */
static int line_length = 0;
/* An include statement is found in file. */
static Bool is_include = FALSE;
/* A date variable statement is found in file. */
static Bool is_dvar = FALSE;
/* A text variable statement is found in file. */
static Bool is_tvar = FALSE;
/* File contains an invalid include file name? */
static Bool bad_sys_include = FALSE;
/*
* Function implementations.
*/
void
rc_use ()
/*
Processes a standard/special resource file and displays the valid fixed
dates found resp., the valid fixed dates of eternal holiday list.
*/
{
register int wd = weekday_of_date (act_day, act_month, act_year);
register int ed;
register int i;
register int j;
register int tmp_month = month;
register int tmp_fiscal_month = fiscal_month;
register int tmp_start_day = start_day;
register int tmp_ad = act_day;
register int tmp_am = act_month;
register int tmp_ay = act_year;
register int tindex = 0;
auto char *ptr_char;
# if HAVE_ASSERT_H
static Bool is_table_range_checked = FALSE;
# endif
static Bool tables_initialized = FALSE;
/*
Initialize some important module global variables.
*/
len_fil_wt = rc_elems = rc_files = 0;
len_the_text = (int) maxlen_max;
# if HAVE_ASSERT_H
/*
Check if the value for the maximum number of table entries
fits to the positive range of a signed int (INT_MAX/SHRT_MAX)!
*/
if (!is_table_range_checked)
{
assert (rc_elems_max > 0);
assert (rc_elems_max <= testval);
assert (rc_files_max > 0);
assert (rc_files_max <= testval);
assert (len_the_text > 0);
assert (len_the_text <= testval);
is_table_range_checked = TRUE;
}
# endif
if (!tables_initialized)
{
/*
Initialize the biorhythms phase texts consisting of 3 characters each.
*/
/*
*** Translators, please translate this as a fixed 3-character text.
*** This text should be a proper abbreviation of "Emotional".
*/
rc_bio_emo_lit = _("Emo");
/*
*** Translators, please translate this as a fixed 3-character text.
*** This text should be a proper abbreviation of "Intellectual".
*/
rc_bio_int_lit = _("Int");
/*
*** Translators, please translate this as a fixed 3-character text.
*** This text should be a proper abbreviation of "Physical".
*/
rc_bio_phy_lit = _("Phy");
/*
Initial memory allocation for an element of the `Line_struct' record
which is needed if we have to parse and evaluate a line.
*/
lptrs = (Line_struct *) my_malloc (sizeof (Line_struct),
ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 2L,
"lptrs", 0);
/*
Initial memory allocation for an element of the `Line_struct' record
which is needed if we have to evaluate %?... special texts.
*/
lptrs2 = (Line_struct *) my_malloc (sizeof (Line_struct),
ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 2L,
"lptrs2", 0);
/*
Initial memory allocation for `rc_files_table[]'.
*/
rc_files_table =
(File_struct **) my_malloc (RC_FILES_MAX * sizeof (File_struct *),
ERR_NO_MEMORY_AVAILABLE, __FILE__,
((long) __LINE__) - 2L,
"rc_files_table[RC_FILES_MAX]",
RC_FILES_MAX);
/*
Initial memory allocation for `rc_elems_table[]'.
*/
rc_elems_table = (char **) my_malloc (RC_ELEMS_MAX * sizeof (char *),
ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 2L,
"rc_elems_table[RC_ELEMS_MAX]",
RC_ELEMS_MAX);
/*
Initial memory allocation for `the_text'.
*/
the_text = (char *) my_malloc (len_the_text, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 1L,
"the_text", 0);
/*
The REGEX stuff in case `--filter-text=PATTERN' is given.
*/
if (rc_filter_text != (char *) NULL)
{
/*
Compile `rc_filter_text' PATTERN.
*/
# if !HAVE_GNU_RE_COMPILE_PATTERN
if (rc_ignore_case_flag)
{
/*
Set PATTERN to lower-case letters
if we have to ignore case distinctions.
*/
ptr_char = rc_filter_text;
for (; *ptr_char; ptr_char++)
*ptr_char = (char) tolower (*ptr_char);
}
# else /* HAVE_GNU_RE_COMPILE_PATTERN */
/*
Compute the GNU Regex table size.
*/
# ifndef CHAR_BIT
auto Uchar bit;
for (i = 0, bit = 2; bit; bit <<= 1, i++)
; /* Void, nothing to do here! */
# else /* CHAR_BIT */
i = CHAR_BIT - 1;
# endif /* CHAR_BIT */
j = ((1 << i) - 1) + (1 << i);
/*
Initial memory allocation of GNU Regex fastmap table.
*/
gnu_fastmap_table =
(char *) my_malloc (j + 1, ERR_NO_MEMORY_AVAILABLE, __FILE__,
((long) __LINE__) - 1L, "gnu_fastmap_table",
0);
/*
Initial memory allocation and initialization of GNU Regex translate table.
*/
gnu_translate_table =
(unsigned char *) my_malloc (j + 1, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 1L,
"gnu_translate_table", 0);
if (rc_ignore_case_flag)
/*
Set PATTERN to lower-case letters
if we have to ignore case distinctions.
*/
for (i = 0; i <= j; i++)
gnu_translate_table[i] = (unsigned char) tolower (i);
else
for (i = 0; i <= j; i++)
gnu_translate_table[i] = (unsigned char) i;
(void)
re_set_syntax ((RE_SYNTAX_POSIX_EXTENDED |
RE_BACKSLASH_ESCAPE_IN_LISTS) &
~(RE_DOT_NOT_NULL));
regpattern.fastmap = gnu_fastmap_table;
regpattern.translate = gnu_translate_table;
if (re_compile_pattern
(rc_filter_text, (int) strlen (rc_filter_text),
®pattern) != (char *) NULL)
my_error (ERR_INVALID_REGEX_PATTERN, "", 0L, rc_filter_text, 0);
# endif /* HAVE_GNU_RE_COMPILE_PATTERN */
# if HAVE_POSIX_REGCOMP
if (regcomp (®pattern, rc_filter_text, REGCOMP_FLAG))
my_error (ERR_INVALID_REGEX_PATTERN, "", 0L, rc_filter_text, 0);
# endif
# if HAVE_RE_COMP
if (re_comp (rc_filter_text) != (char *) NULL)
my_error (ERR_INVALID_REGEX_PATTERN, "", 0L, rc_filter_text, 0);
re_pattern = 1;
# endif
/*
Is it necessary to remove highlighting sequences
in each text before searching the PATTERN?
*/
remove_hls_in_regex = highlight_flag;
}
tables_initialized = TRUE;
}
/*
Depending on fixed date mode,
compute last valid day `ed' a fixed date may occur.
*/
ed = day = day_of_year (act_day, act_month, act_year);
if (is_date_given)
{
/*
NOT in simple month/year mode (an explicit date is given in the command line):
Compute the starting/ending loop values of the requested period.
*/
ed = DAY_LAST + is_leap_year + 1;
if (!month)
day = DAY_MIN;
else
{
day = day_of_year (DAY_MIN, month, year);
if (month < MONTH_MAX)
ed = day_of_year (DAY_MIN, month + 1, year);
}
/*
Then clean all flags which are related to the fixed date period.
*/
rc_clean_flags ();
if (date_enables_year)
rc_year_flag = TRUE;
}
else
{
auto int dd;
auto int mm;
auto int yy = act_year;
auto int greg_missing_days = (greg->last_day - greg->first_day + 1);
auto Bool greg_correction = FALSE;
auto Bool swap_flag = FALSE;
if (rc_tomorrow_flag)
{
/*
`-ct' option found.
*/
rc_period_list = FALSE;
ed += 2;
if ((act_year == greg->year)
&& (act_month == greg->month)
&& (act_day == greg->first_day - 1))
ed += greg_missing_days;
}
else if (rc_week_flag)
{
/*
`-cw[+|-]' option found.
*/
rc_period_list = FALSE;
if (!rc_forwards_flag && !rc_backwards_flag)
day += (-DAY_MAX + SDAY (DAY_MAX - wd + 1, start_day));
else if (rc_forwards_flag)
day += !rc_have_today_in_list;
else
day += rc_have_today_in_list;
if (rc_backwards_flag
|| (!rc_forwards_flag
&& !rc_backwards_flag && (start_day > wd)))
{
swap_flag = TRUE;
ed -= DAY_MAX;
}
ed += SDAY (DAY_MAX - wd + 1, start_day);
if (act_year == greg->year)
greg_correction = TRUE;
}
else if (rc_month_flag)
{
/*
`-cm[+|-]' option found.
*/
rc_period_list = FALSE;
if (!rc_forwards_flag && !rc_backwards_flag)
day = day_of_year (DAY_MIN, act_month, act_year);
else if (rc_forwards_flag)
day += !rc_have_today_in_list;
else
day += rc_have_today_in_list;
if (rc_backwards_flag)
ed = day_of_year (DAY_MIN, act_month, act_year);
else
{
if (act_month < MONTH_MAX)
ed = day_of_year (DAY_MIN, act_month + 1, act_year);
else
ed = DAY_LAST + is_leap_year + 1;
}
}
else if (rc_year_flag)
{
/*
`-cy[+|-]' option found.
*/
rc_period_list = FALSE;
if (!rc_forwards_flag && !rc_backwards_flag)
day = DAY_MIN;
else if (rc_forwards_flag)
day += !rc_have_today_in_list;
else
day += rc_have_today_in_list;
if (rc_backwards_flag)
ed = DAY_MIN;
else
ed = DAY_LAST + is_leap_year + 1;
}
else if (rc_period_flag)
{
if (rc_week_year_flag)
{
/*
`-cNw' option found
*/
if (iso_week_number)
/*
Those ISO-8601:1988 weeks starts on Monday.
*/
wd = start_day = DAY_MIN;
/*
Compute the day number of year the week starts at.
*/
j = day =
weekno2doy (rc_period, act_year, iso_week_number, start_day);
if (day != -WEEK_MAX)
{
if (rc_period_list)
{
/*
`-cNw' option found.
*/
if (day > ed)
{
if (day <= DAY_LAST + is_leap_year)
{
rc_forwards_flag = TRUE;
day = ed + 1 - rc_have_today_in_list;
ed = j + DAY_MAX;
/*
Correction in case week occurs during Gregorian Reformation period.
*/
if (act_year == greg->year)
{
(void) doy2date (j, is_leap_year, &dd, &mm);
for (i = j; i < ed; i++)
if (!next_date (&dd, &mm, &yy))
{
ed += greg_missing_days;
break;
}
}
if (ed > DAY_LAST + is_leap_year + 1)
ed = DAY_LAST + is_leap_year + 1;
}
else
/*
No fixed date messages to display.
*/
day = ed;
}
else
{
if (ed > DAY_MIN)
{
rc_backwards_flag = TRUE;
day = ed + rc_have_today_in_list;
ed = j;
if (ed < DAY_MIN)
ed = DAY_MIN;
}
else
/*
No fixed date messages to display.
*/
day = ed;
}
}
else
{
/*
`-cNw' option found:
Set actual date to Mondays date of week
and omit highlighting that date; boolean
`adate_set' is set to distinct this
SPECIAL mode from other modes...
*/
rc_week_flag = TRUE;
ed = day + DAY_MAX;
/*
Correction in case week occurs during Gregorian Reformation period.
*/
if (act_year == greg->year)
{
(void) doy2date (day, is_leap_year, &dd, &mm);
for (i = day; i < ed; i++)
if (!next_date (&dd, &mm, &yy))
{
ed += greg_missing_days;
break;
}
}
if (day < DAY_MIN)
{
act_year--;
j +=
(DAY_LAST + (days_of_february (act_year) == 29));
}
else
j = day;
(void) doy2date (j, is_leap_year, &act_day, &act_month);
month = act_month;
fiscal_month = MONTH_MIN;
adate_set = TRUE;
}
}
else
/*
Wanted week doesn't exist:
Don't display any fixed date messages.
*/
day = ed;
}
else
/*
`-cNd', `-cMMDD', `-cMMWW[W]N', `-c*d|wN[WW[W]' and
`-c@e|t|DVAR[[-]N] options are implicitly managed in
this subsection, too.
*/
if (rc_forwards_flag && (day < DAY_LAST + is_leap_year))
{
if (rc_period_list)
{
/*
`-clN+' option found (list of dates).
*/
day += !rc_have_today_in_list;
/*
Correction in case date occurs during Gregorian Reformation period.
*/
if (rc_fwdf_buffer
&& (act_year == greg->year)
&& (ed <
day_of_year (greg->first_day, greg->month,
greg->year))
&& (ed + rc_period >=
day_of_year (greg->first_day, greg->month,
greg->year)))
ed += greg_missing_days;
ed += (rc_period + 1);
if (ed > DAY_LAST + is_leap_year + 1)
ed = DAY_LAST + is_leap_year + 1;
}
else
{
/*
`-cN+ option found (single date).
*/
rc_forwards_flag = FALSE;
/*
Correction in case date occurs during Gregorian Reformation period.
*/
if (rc_fwdf_buffer
&& (act_year == greg->year)
&& (day <
day_of_year (greg->first_day, greg->month,
greg->year))
&& (day + rc_period >=
day_of_year (greg->first_day, greg->month,
greg->year)))
day += greg_missing_days;
day += rc_period;
ed = day;
if (day < DAY_LAST + is_leap_year + 1)
{
rc_period_flag = FALSE;
(void) doy2date (day, is_leap_year, &act_day,
&act_month);
month = act_month;
ed++;
}
}
}
else if (rc_backwards_flag && (day > DAY_MIN))
{
if (rc_period_list)
{
/*
`-clN-' option found (list of dates).
*/
day += rc_have_today_in_list;
/*
Correction in case date occurs during Gregorian Reformation period.
*/
if (rc_bwdf_buffer
&& (act_year == greg->year)
&& (ed >
day_of_year (greg->last_day, greg->month,
greg->year))
&& (ed - rc_period <=
day_of_year (greg->last_day, greg->month,
greg->year)))
ed -= greg_missing_days;
ed -= rc_period;
if (ed < DAY_MIN)
ed = DAY_MIN;
}
else
{
/*
`-cN-' option found (single date).
*/
rc_backwards_flag = FALSE;
/*
Correction in case date occurs during Gregorian Reformation period.
*/
if (rc_bwdf_buffer
&& (act_year == greg->year)
&& (day >
day_of_year (greg->last_day, greg->month,
greg->year))
&& (day - rc_period <=
day_of_year (greg->last_day, greg->month,
greg->year)))
day -= greg_missing_days;
day -= rc_period;
ed = day;
if (day > 0)
{
rc_period_flag = FALSE;
(void) doy2date (day, is_leap_year, &act_day,
&act_month);
month = act_month;
ed++;
}
}
}
}
else
{
/*
Only a simple option `-c' (without any modifiers) found.
*/
rc_period_list = FALSE;
ed++;
}
/*
Swap the starting date `day' and final date `ed' of the period.
*/
if (swap_flag || rc_backwards_flag)
{
int tmp = ed;
ed = day;
day = tmp;
}
/*
Correction in case date occurs during Gregorian Reformation period.
*/
if (greg_correction)
{
(void) doy2date (day, is_leap_year, &dd, &mm);
if (!prev_date (&dd, &mm, &yy))
day -= greg_missing_days;
else
{
if (!rc_forwards_flag && !rc_backwards_flag)
{
(void) doy2date (day, is_leap_year, &dd, &mm);
if (weekday_of_date (dd, mm, yy) != start_day)
day -= greg_missing_days;
else
for (i = day; i < ed; i++)
if (!next_date (&dd, &mm, &yy))
{
ed += greg_missing_days;
break;
}
}
else
{
auto Bool ed_set = FALSE;
for (i = day; i < ed; i++)
if (!next_date (&dd, &mm, &yy))
{
ed += greg_missing_days;
ed_set = TRUE;
break;
}
if (rc_backwards_flag && ed_set)
{
(void) doy2date (day, is_leap_year, &dd, &mm);
if (weekday_of_date (dd, mm, yy) != start_day)
{
day -= greg_missing_days;
ed -= greg_missing_days;
}
}
}
}
}
}
if (day != ed)
{
auto double save_time_offset = time_offset;
register int save_hour_offset = time_hour_offset;
register int save_min_offset = time_min_offset;
register int save_loop_end = loop_end;
auto char *tmp_rc_here_fn;
auto Bool cycle_increment = TRUE;
auto Bool is_here_file;
auto Bool ok;
/*
Now include the eternal holidays, which are valid fixed dates,
into `rc_elems_table[]'.
*/
if (rc_enable_hda_flag || rc_enable_hdl_flag)
{
while ((hd_table[tindex] != (char *) NULL)
&& (tindex < HD_ELEMS_MAX))
{
strcpy (line_buffer, hd_table[tindex]);
i = LEN_HD_NAME + len_year_max + 4 + 2;
if (rc_enable_hda_flag
|| (rc_enable_hdl_flag
&& (line_buffer[i] != *DIS_HLS_PREF)
&& (line_buffer[i] != *DIS_HLS_PREF2)))
{
i -= 2;
while (i && isspace (line_buffer[i]))
line_buffer[i--] = '\0';
if (i > len_year_max + 4)
rc_check (line_buffer, _("`Eternal holiday list'"),
(long) tindex, i, &rc_elems, day, ed, wd);
}
if (!holiday_flag)
{
free (hd_table[tindex]);
hd_table[tindex] = (char *) NULL;
}
tindex++;
}
/*
If the fixed date mode is related to a week or to tomorrow
and the period has left the current year, include those
eternal holidays in year +/- 1 into `rc_elems_table',
which are valid fixed dates.
*/
if ((rc_tomorrow_flag
|| rc_week_flag)
&& !is_date_given
&& !is_1month_mode
&& !is_2month_mode
&& ((!rc_forwards_flag
&& !rc_backwards_flag
&& (((year + 1 <= YEAR_MAX)
&& (ed > DAY_LAST + is_leap_year + 1))
|| ((year - 1 >= YEAR_MIN)
&& (day < DAY_MIN))))
|| (rc_forwards_flag
&& ((year + 1 <= YEAR_MAX)
&& (ed > DAY_LAST + is_leap_year + 1)))
|| (rc_backwards_flag
&& ((year - 1 >= YEAR_MIN) && (day < DAY_MIN)))))
{
register int jtmp_ad = act_day;
register int tay = act_year;
register int tam = act_month;
register int tad = act_day;
if (holiday_flag)
for (i = 0; i < tindex; i++)
{
free (hd_table[i]);
hd_table[i] = (char *) NULL;
}
tindex = 0;
if (day < DAY_MIN)
{
year--;
month = MONTH_MAX;
}
else
{
year++;
month = MONTH_MIN;
}
is_leap_year = (days_of_february (year) == 29);
if (cal_special_flag)
act_day = day_of_year (jtmp_ad, act_month, act_year);
if (adate_set)
fiscal_month = tmp_fiscal_month;
if (((year == EASTER_MIN - 1)
&& (fiscal_month > MONTH_MIN))
|| ((year >= EASTER_MIN) && (year <= EASTER_MAX)))
print_all_holidays (TRUE, TRUE);
if (adate_set)
fiscal_month = MONTH_MIN;
if (day < DAY_MIN)
{
year++;
month = MONTH_MIN;
}
else
{
year--;
month = MONTH_MAX;
}
while ((hd_table[tindex] != (char *) NULL)
&& (tindex < HD_ELEMS_MAX))
{
strcpy (line_buffer, hd_table[tindex]);
i = LEN_HD_NAME + len_year_max + 4 + 2;
if (rc_enable_hda_flag
|| (rc_enable_hdl_flag
&& (line_buffer[i] == *DIS_HLS_PREF)
&& (line_buffer[i] == *DIS_HLS_PREF2)))
{
i -= 2;
while (i && isspace (line_buffer[i]))
line_buffer[i--] = '\0';
if (i > len_year_max + 4)
rc_check (line_buffer, _("`Eternal holiday list'"),
(long) tindex, i, &rc_elems, day, ed, wd);
}
free (hd_table[tindex]);
hd_table[tindex] = (char *) NULL;
tindex++;
}
is_leap_year = (days_of_february (year) == 29);
if (adate_set)
{
fiscal_month = tmp_fiscal_month;
act_year = tmp_ay;
act_month = tmp_am;
jtmp_ad = act_day = tmp_ad;
}
if (cal_special_flag)
act_day = day_of_year (jtmp_ad, act_month, act_year);
if (holiday_flag
&& (((year == EASTER_MIN - 1)
&& (fiscal_month > MONTH_MIN))
|| ((year >= EASTER_MIN) && (year <= EASTER_MAX))))
print_all_holidays (TRUE, TRUE);
if (cal_special_flag)
act_day = jtmp_ad;
if (adate_set)
{
fiscal_month = MONTH_MIN;
act_year = tay;
month = act_month = tam;
act_day = tad;
}
else
month = tmp_month;
}
}
/*
Try to open the resource file(s).
*/
if (rc_filename == (char *) NULL)
{
/*
Use the standard resource file.
*/
i = (int) strlen (PACKAGE_NAME) + strlen (RC_SUFFIX);
# ifdef GCAL_SHELL
i++;
# endif
if ((Uint) i >= maxlen_max)
resize_all_strings (i + 1, FALSE, __FILE__, (long) __LINE__);
# ifdef GCAL_SHELL
strcpy (s3, ".");
# else /* !GCAL_SHELL */
*s3 = '\0';
# endif /* !GCAL_SHELL */
strcat (s3, PACKAGE_NAME);
strcat (s3, RC_SUFFIX);
}
else
{
/*
Use the list of resource file names.
*/
i = (int) strlen (rc_filename);
if ((Uint) i >= maxlen_max)
resize_all_strings (i + 1, FALSE, __FILE__, (long) __LINE__);
strcpy (s3, rc_filename);
}
/*
Allocate the file buffers for the main resource file itself
(the main resource file is always buffered at position 0 in `rc_files_table[]').
*/
rc_files_table[rc_files] =
(File_struct *) my_malloc (sizeof (File_struct),
ERR_NO_MEMORY_AVAILABLE, __FILE__,
((long) __LINE__) - 2L,
"rc_files_table[rc_files]", rc_files);
rc_files_table[rc_files]->fp = (FILE *) NULL;
rc_files_table[rc_files]->pool = (char *) my_malloc (BUF_LEN + 1,
ERR_NO_MEMORY_AVAILABLE,
__FILE__,
((long) __LINE__) -
2L,
"rc_files_table[rc_files]->pool",
rc_files);
if (loop_end != SPECIAL_VALUE)
{
/*
Set the cycle-starting time value for %sun* and %moon*.
*/
tindex = HHMM2MM (time_hour_offset, time_min_offset);
/*
Reduce the given cycle-starting time value in minutes to a single day.
*/
if (tindex < 0)
tindex = 0;
else if (tindex >= MINS_PER_DAY)
tindex = MINS_PER_DAY - 1;
if (tindex > loop_end)
cycle_increment = FALSE;
time_hour_offset = MM2HH (tindex);
time_min_offset = tindex % MINS_PER_HOUR;
time_offset = MM2DAY (tindex);
}
else
tindex = 0;
do
{
tmp_rc_here_fn = rc_here_fn;
ok = is_here_file = FALSE;
while (!ok)
{
/*
Single file or list of resource file names given in the command line.
*/
while (rc_files_table[rc_files]->fp == (FILE *) NULL)
{
i = 0;
ptr_char = s3;
LOOP
{
if (*ptr_char == QUOTE_CHAR)
{
if (*(ptr_char + 1) == *CONNECT_SEP
|| *(ptr_char + 1) == QUOTE_CHAR)
ptr_char++;
s7[i++] = *ptr_char++;
}
else if (*ptr_char != *CONNECT_SEP)
s7[i++] = *ptr_char++;
if (!*ptr_char || *ptr_char == *CONNECT_SEP)
break;
}
s7[i] = '\0';
/*
Now check if the file exists.
*/
rc_files_table[rc_files]->filename
= (char *) my_malloc (i + 1, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 1L,
"rc_files_table[rc_files]->filename",
rc_files);
strcpy (rc_files_table[rc_files]->filename, s7);
rc_files_table[rc_files]->fp =
file_open (&rc_files_table[rc_files]->filename, rc_files,
(is_here_file) ? HEre : REsource,
&bad_sys_include);
if (!*ptr_char)
{
/*
Finished, THE file respectively ALL files are managed
so check whether any `--here=ARG' options must be processed
at last coming from the temporary file already created.
*/
if (tmp_rc_here_fn != (char *) NULL)
{
/*
Use the temporary "here" filename for processing next.
*/
i = (int) strlen (tmp_rc_here_fn);
if ((Uint) i >= maxlen_max)
resize_all_strings (i + 1, FALSE, __FILE__,
(long) __LINE__);
strcpy (s3, tmp_rc_here_fn);
tmp_rc_here_fn = (char *) NULL;
is_here_file = !ok; /* Nomen est Omen??? :-) */
}
else
ok = TRUE;
break;
}
else
{
/*
Now skip a trailing '+' character of a file name list.
*/
ptr_char++;
/*
Copy the rest of the file name list and start
the file search again if the file was not found.
*/
strcpy (s7, ptr_char);
strcpy (s3, s7);
if (rc_files_table[rc_files]->fp == (FILE *) NULL)
free (rc_files_table[rc_files]->filename);
}
}
/*
Now read and check contents of a resource file `filename'
and include valid fixed dates into `rc_elems_table[]'.
*/
if (rc_files_table[rc_files]->fp != (FILE *) NULL)
{
rc_files_table[rc_files]->in_pool = 0;
rc_files_table[rc_files]->line_number = 0L;
/*
First of all, copy the contents of the global date variables to the
local variables (if one of these isn't defined) so we can perform
local operations (++, --, +=, -=) on global variables.
*/
for (i = 0; i < RC_DVAR_MAX; i++)
if (rc_dvar[i].dvar_global.dvar_month
&& !rc_dvar[i].dvar_local.dvar_month)
{
rc_dvar[i].dvar_local.dvar_month =
rc_dvar[i].dvar_global.dvar_month;
rc_dvar[i].dvar_local.dvar_day =
rc_dvar[i].dvar_global.dvar_day;
}
/*
Then copy the contents of the global text variables to the
local variables (if one of these isn't defined) so we can
perform local operations (++, --, +=, -=) on global variables.
*/
for (i = 0; i < RC_TVAR_MAX; i++)
if ((rc_tvar[i].tvar_global.tvar_text != (char *) NULL)
&& (rc_tvar[i].tvar_local.tvar_text == (char *) NULL))
{
rc_tvar[i].tvar_local.tvar_text
=
(char *)
my_malloc (strlen (rc_tvar[i].tvar_global.tvar_text)
+ 1, ERR_NO_MEMORY_AVAILABLE, __FILE__,
((long) __LINE__) - 2L,
"rc_tvar[i].tvar_local.tvar_text", i);
strcpy (rc_tvar[i].tvar_local.tvar_text,
rc_tvar[i].tvar_global.tvar_text);
}
while ((rc_files_table[rc_files]->ptr_pool =
file_read_line (rc_files_table[rc_files]->fp,
&line_buffer,
&rc_files_table[rc_files]->in_pool,
rc_files_table[rc_files]->pool,
rc_files_table[rc_files]->ptr_pool,
rc_files_table[rc_files]->filename,
&rc_files_table[rc_files]->
line_number, &line_length, REsource,
&is_include, &is_dvar,
&is_tvar)) != (char *) NULL)
{
/*
Check whether an "#include" statement is found.
*/
if (is_include)
/*
We have to manage an include file.
*/
try_to_include_file (ed, wd);
else
/*
We are still in the main resource file.
*/
if (*line_buffer && !is_dvar && !is_tvar)
rc_check (line_buffer,
rc_files_table[rc_files]->filename,
rc_files_table[rc_files]->line_number,
line_length, &rc_elems, day, ed, wd);
}
if (rc_files_table[rc_files]->fp != stdin)
(void) fclose (rc_files_table[rc_files]->fp);
rc_files_table[rc_files]->fp = (FILE *) NULL;
free (rc_files_table[rc_files]->filename);
/*
Next file -> reset all local date variables to zero,
if `--export-date-variables' flag set, don't reset them!
*/
if (!rc_export_ldvar_flag)
for (i = 0; i < RC_DVAR_MAX; i++)
rc_dvar[i].dvar_local.dvar_month = (char) 0;
/*
Next file -> reset all local text variables to NULL,
if `--export-text-variables' flag set, don't reset them!
*/
if (!rc_export_ltvar_flag)
for (i = 0; i < RC_TVAR_MAX; i++)
if (rc_tvar[i].tvar_local.tvar_text != (char *) NULL)
{
free (rc_tvar[i].tvar_local.tvar_text);
rc_tvar[i].tvar_local.tvar_text = (char *) NULL;
}
}
else
/*
Yeah, we have not found any main resource file so it's absolutely
necessary to free the allocated memory area of the "file name",
because it's possible that we enter this function again,
e.g. if we produce month/year lists or ranges.
*/
free (rc_files_table[rc_files]->filename);
}
if (loop_end != SPECIAL_VALUE)
{
/*
Increase/decrease the cycle-time counter properly and set
a ``new'' time value for the %sun* and %moon* special texts.
*/
if (cycle_increment)
tindex += loop_step;
else
tindex -= loop_step;
time_hour_offset = MM2HH (tindex);
time_min_offset = tindex % MINS_PER_HOUR;
time_offset = MM2DAY (tindex);
}
}
while ((cycle_increment
&& (tindex <= loop_end))
|| (!cycle_increment && (tindex >= loop_end)));
time_hour_offset = save_hour_offset;
time_min_offset = save_min_offset;
time_offset = save_time_offset;
loop_end = save_loop_end;
free (rc_files_table[rc_files]->pool);
for (i = 0; i < RC_TVAR_MAX; i++)
if (rc_tvar[i].tvar_local.tvar_text != (char *) NULL)
{
free (rc_tvar[i].tvar_local.tvar_text);
rc_tvar[i].tvar_local.tvar_text = (char *) NULL;
}
free ((VOID_PTR) rc_files_table[rc_files]);
fiscal_month = tmp_fiscal_month;
/*
Now display the constructed contents of `rc_elems_table[]'.
*/
if (rc_elems || rc_all_dates_flag || rc_zero_dates_flag)
display_table (tmp_ad, tmp_am, tmp_ay, day, ed, wd);
}
start_day = tmp_start_day;
month = tmp_month;
act_day = tmp_ad;
act_month = tmp_am;
act_year = tmp_ay;
}
static void
try_to_include_file (ed, wd)
int ed;
int wd;
/*
Manages an include file.
*/
{
register int i;
register int j;
auto Bool is_usr_file = FALSE;
auto Bool is_sys_file = FALSE;
i = (int) strlen (line_buffer);
if ((Uint) i >= maxlen_max)
resize_all_strings (i + 1, FALSE, __FILE__, (long) __LINE__);
strcpy (s7, line_buffer);
i = (int) strlen (RC_INCL_STMENT);
if (strncasecmp (s7, RC_INCL_STMENT, i))
/*
Error, misspelled "#include" directive found.
*/
my_error (ERR_MALFORMED_INCLUDE, rc_files_table[rc_files]->filename,
rc_files_table[rc_files]->line_number, line_buffer, 0);
/*
Skip any leading whitespace characters of the line.
*/
while (isspace (s7[i]))
i++;
if (!s7[i] || s7[i] == '\n')
/*
Error, no include file "argument" encoded.
*/
my_error (ERR_MALFORMED_INCLUDE, rc_files_table[rc_files]->filename,
rc_files_table[rc_files]->line_number, line_buffer, 0);
if (s7[i] == *RC_INCL_USR_ID)
is_usr_file = TRUE;
else if (s7[i] == *RC_INCL_SYS_ID)
is_sys_file = TRUE;
else
/*
Error, illegal leading include file name delimiter found.
*/
my_error (ERR_MALFORMED_INCLUDE, rc_files_table[rc_files]->filename,
rc_files_table[rc_files]->line_number, line_buffer, 0);
i++;
j = 0;
/*
Get the include file name.
*/
while (s7[i] && (s7[i] != *RC_INCL_USR_OD) && (s7[i] != *RC_INCL_SYS_OD))
s7[j++] = s7[i++];
if ((is_usr_file
&& (s7[i] != *RC_INCL_USR_OD))
|| (is_sys_file && (s7[i] != *RC_INCL_SYS_OD)))
/*
Error, illegal trailing include file name delimiter found.
*/
my_error (ERR_MALFORMED_INCLUDE, rc_files_table[rc_files]->filename,
rc_files_table[rc_files]->line_number, line_buffer, 0);
if (!j)
/*
Error, no include file "name" encoded.
*/
my_error (ERR_MALFORMED_INCLUDE, rc_files_table[rc_files]->filename,
rc_files_table[rc_files]->line_number, line_buffer, 0);
/*
Now we have the name of include file and the mode of operation.
*/
s7[j] = '\0';
/*
Before we have to manage this next include file,
let's check for recursive/cyclic includes, which we MUST avoid!
*/
for (i = 0; i <= rc_files; i++)
{
/*
Check if any file buffered in `rc_files_table[]' is just included by this file.
*/
if (*s7 == *rc_files_table[i]->filename)
if (!strcmp (s7 + 1, rc_files_table[i]->filename + 1))
/*
Error, invalid recursive/cyclic include statement found.
*/
my_error (ERR_CYCLIC_INCLUDE, rc_files_table[rc_files]->filename,
rc_files_table[rc_files]->line_number, line_buffer, 0);
}
/*
First or next include file, so we increment the counter
of buffered files in `rc_files_table[]' by one first before we check
the table size, because `rc_files' wasn't just postincremented
*/
rc_files++;
/*
Now check if it's necessary to resize the `rc_files_table[]'.
*/
if ((Uint) rc_files >= rc_files_max)
{
/*
Resize the `rc_files_table[]' table.
*/
rc_files_max <<= 1;
if (rc_elems_max * sizeof (File_struct *) > testval)
rc_files_max--;
rc_files_table = (File_struct **) my_realloc ((VOID_PTR) rc_files_table,
rc_files_max *
sizeof (File_struct *),
ERR_NO_MEMORY_AVAILABLE,
__FILE__,
((long) __LINE__) - 3L,
"rc_files_table[rc_files_max]",
rc_files_max);
}
/*
Allocate the file buffers for an include file.
*/
rc_files_table[rc_files] = (File_struct *) my_malloc (sizeof (File_struct),
ERR_NO_MEMORY_AVAILABLE,
__FILE__,
((long) __LINE__) -
2L,
"rc_files_table[rc_files]",
rc_files);
rc_files_table[rc_files]->filename =
(char *) my_malloc (j + 1, ERR_NO_MEMORY_AVAILABLE, __FILE__,
((long) __LINE__) - 2L,
"rc_files_table[rc_files]->filename", rc_files);
strcpy (rc_files_table[rc_files]->filename, s7);
/*
Try to open it.
*/
rc_files_table[rc_files]->fp =
file_open (&rc_files_table[rc_files]->filename, rc_files,
(is_usr_file) ? USr_include : SYs_include, &bad_sys_include);
if (bad_sys_include)
/*
Error, invalid root directory based system include file name found
in the include statement, e.g.: #include </foo> or #include </foo/bar>.
*/
my_error (ERR_MALFORMED_INCLUDE, rc_files_table[rc_files - 1]->filename,
rc_files_table[rc_files - 1]->line_number, line_buffer, 0);
/*
If include file exists, read it.
*/
if (rc_files_table[rc_files]->fp != (FILE *) NULL)
{
rc_files_table[rc_files]->in_pool = 0;
rc_files_table[rc_files]->line_number = 0L;
rc_files_table[rc_files]->pool = (char *) my_malloc (BUF_LEN + 1,
ERR_NO_MEMORY_AVAILABLE,
__FILE__,
((long) __LINE__) -
2L,
"rc_files_table[rc_files]->pool",
rc_files);
/*
Buffer all local date variables of the include file.
*/
for (i = 0; i < RC_DVAR_MAX; i++)
{
rc_files_table[rc_files]->local_dvars[i].dvar_month =
rc_dvar[i].dvar_local.dvar_month;
rc_files_table[rc_files]->local_dvars[i].dvar_day =
rc_dvar[i].dvar_local.dvar_day;
}
/*
Buffer all local text variables of the include file.
*/
for (i = 0; i < RC_TVAR_MAX; i++)
{
if (rc_tvar[i].tvar_local.tvar_text != (char *) NULL)
{
rc_files_table[rc_files]->local_tvars[i].tvar_text
=
(char *) my_malloc (strlen (rc_tvar[i].tvar_local.tvar_text) +
1, ERR_NO_MEMORY_AVAILABLE, __FILE__,
((long) __LINE__) - 2L,
"rc_tvar[i].tvar_local.tvar_text", i);
strcpy (rc_files_table[rc_files]->local_tvars[i].tvar_text,
rc_tvar[i].tvar_local.tvar_text);
}
else
rc_files_table[rc_files]->local_tvars[i].tvar_text =
(char *) NULL;
}
while ((rc_files_table[rc_files]->ptr_pool =
file_read_line (rc_files_table[rc_files]->fp, &line_buffer,
&rc_files_table[rc_files]->in_pool,
rc_files_table[rc_files]->pool,
rc_files_table[rc_files]->ptr_pool,
rc_files_table[rc_files]->filename,
&rc_files_table[rc_files]->line_number,
&line_length, REsource, &is_include, &is_dvar,
&is_tvar)) != (char *) NULL)
/*
Check whether an "#include" statement is found.
*/
if (is_include)
/*
Ok, let's manage a next include file by calling this function recursively.
*/
try_to_include_file (ed, wd);
else
/*
We are still in the actual include file.
*/
if (*line_buffer && !is_dvar && !is_tvar)
rc_check (line_buffer, rc_files_table[rc_files]->filename,
rc_files_table[rc_files]->line_number, line_length,
&rc_elems, day, ed, wd);
(void) fclose (rc_files_table[rc_files]->fp);
free (rc_files_table[rc_files]->pool);
/*
Restore all local date variables of the include file.
*/
for (i = 0; i < RC_DVAR_MAX; i++)
{
rc_dvar[i].dvar_local.dvar_month =
rc_files_table[rc_files]->local_dvars[i].dvar_month;
rc_dvar[i].dvar_local.dvar_day =
rc_files_table[rc_files]->local_dvars[i].dvar_day;
}
/*
Restore all local text variables of the include file.
*/
for (i = 0; i < RC_TVAR_MAX; i++)
if (rc_files_table[rc_files]->local_tvars[i].tvar_text !=
(char *) NULL)
{
if (rc_tvar[i].tvar_local.tvar_text == (char *) NULL)
rc_tvar[i].tvar_local.tvar_text
=
(char *)
my_malloc (strlen
(rc_files_table[rc_files]->local_tvars[i].
tvar_text) + 1, ERR_NO_MEMORY_AVAILABLE, __FILE__,
((long) __LINE__) - 2L,
"rc_tvar[i].tvar_local.tvar_text", i);
else
rc_tvar[i].tvar_local.tvar_text
=
(char *)
my_realloc ((VOID_PTR) (rc_tvar[i].tvar_local.tvar_text),
strlen (rc_files_table[rc_files]->local_tvars[i].
tvar_text) + 1, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 3L,
"rc_tvar[i].tvar_local.tvar_text", i);
strcpy (rc_tvar[i].tvar_local.tvar_text,
rc_files_table[rc_files]->local_tvars[i].tvar_text);
free (rc_files_table[rc_files]->local_tvars[i].tvar_text);
rc_files_table[rc_files]->local_tvars[i].tvar_text =
(char *) NULL;
}
}
/*
Now deallocate the include file buffers.
*/
free (rc_files_table[rc_files]->filename);
free ((VOID_PTR) rc_files_table[rc_files]);
/*
And back to the previous include file resp., main resource file.
*/
rc_files--;
}
static void
display_table (tmp_ad, tmp_am, tmp_ay, day, ed, wd)
const int tmp_ad;
const int tmp_am;
const int tmp_ay;
int day;
int ed;
int wd;
/*
Displays all entries in `rc_elems_table[]' in sorted order.
*/
{
register int n;
register int i;
register int j = 0;
register int tindex = 0;
auto int ld = 0;
auto int lm = 0;
auto int ly = 0;
auto int dd = 0;
auto int mm = 0;
auto int yy = 0;
auto int i_dummy;
auto char c_dummy;
auto Bool b_dummy;
auto Bool ok;
rc_zero_pos = rc_elems;
/*
If `rc_all_dates_flag' or `rc_zero_dates_flag' is set, complete the
contents of `rc_elems_table[]', i.e., generate "empty" texts for
each day in the requested period.
*/
if (rc_all_dates_flag || rc_zero_dates_flag)
{
register int rc_e = rc_zero_pos;
/*
Lets sort ascending first only in case `rc_elems_table[]' isn't presorted!
*/
if ((rc_elems > 1) && !is_presorted (rc_elems_table, rc_elems))
qsort ((VOID_PTR) rc_elems_table, rc_elems, sizeof *rc_elems_table,
(Cmp_func) asc_sort);
if (rc_elems)
(void) rc_get_date (rc_elems_table[j], lineptrs, FALSE, &b_dummy, &ld,
&lm, &ly, &i_dummy, &i_dummy, &c_dummy, &i_dummy,
&i_dummy, _("Internal"), (long) j,
rc_elems_table[j], TRUE);
/*
Correction for the respected period if we are in fiscal year mode.
*/
if ((fiscal_month > MONTH_MIN) && !adate_set)
{
day = mvec[fiscal_month - 1] + 1;
if (fiscal_month > 2)
day += is_leap_year;
}
/*
Let's produce the dummy entries ("empty" fixed dates)...
*/
for (i = day; i < ed; i++)
{
yy = year;
ok = doy2date (i, is_leap_year, &dd, &mm);
if (!ok)
{
if (rc_tomorrow_flag || rc_week_flag)
{
if (i < DAY_MIN)
{
yy = year - 1;
if (yy < YEAR_MIN)
break;
n = (days_of_february (yy) == 29);
(void) doy2date (DAY_LAST + n + i, n, &dd, &mm);
}
else if (i > DAY_LAST + is_leap_year)
{
yy = year + 1;
if (yy > YEAR_MAX)
break;
n = (days_of_february (yy) == 29);
(void) doy2date (i - (DAY_LAST + is_leap_year), n, &dd,
&mm);
}
}
else
break;
}
if (j == rc_e
|| mm < lm
|| yy < ly || ((dd < ld) && (mm <= lm) && (yy <= ly)))
{
sprintf (line_buffer, "%0*d%02d%02d ", len_year_max, yy, mm,
dd);
rc_check (line_buffer, _("`Internal'"), (long) tindex,
strlen (line_buffer), &rc_elems, day, ed, wd);
}
else
while ((dd == ld) && (mm == lm) && (yy == ly))
if (j + 1 < rc_e)
{
j++;
(void) rc_get_date (rc_elems_table[j], lineptrs, FALSE,
&b_dummy, &ld, &lm, &ly, &i_dummy,
&i_dummy, &c_dummy, &i_dummy, &i_dummy,
_("Internal"), (long) j,
rc_elems_table[j], TRUE);
}
else
{
j++;
break;
}
}
/*
Respect fiscal year mode.
*/
if ((fiscal_month > MONTH_MIN) && (year < YEAR_MAX) && !adate_set)
{
/*
Correction for the respected period.
*/
day = DAY_MIN;
yy = year + 1;
is_leap_year = (days_of_february (yy) == 29);
if (fiscal_month < MONTH_MAX)
ed = day_of_year (DAY_MIN, fiscal_month + 1, yy) + 1;
else
ed = DAY_LAST + is_leap_year + 1;
/*
Let's produce the dummy entries ("empty" fixed dates)...
*/
for (i = day; i < ed; i++)
{
ok = doy2date (i, is_leap_year, &dd, &mm);
if (!ok)
break;
if (j == rc_e
|| mm < lm
|| yy < ly || ((dd < ld) && (mm <= lm) && (yy <= ly)))
{
sprintf (line_buffer, "%0*d%02d%02d ", len_year_max, yy, mm,
dd);
rc_check (line_buffer, _("`Internal'"), (long) tindex,
strlen (line_buffer), &rc_elems, day, ed, wd);
}
else
while ((dd == ld) && (mm == lm) && (yy == ly))
if (j + 1 < rc_e)
{
j++;
(void) rc_get_date (rc_elems_table[j], lineptrs, FALSE,
&b_dummy, &ld, &lm, &ly, &i_dummy,
&i_dummy, &c_dummy, &i_dummy,
&i_dummy, _("Internal"), (long) j,
rc_elems_table[j], TRUE);
}
else
{
j++;
break;
}
}
}
is_leap_year = (days_of_february (year) == 29);
}
if ((rc_zero_dates_flag
&& (rc_elems - rc_zero_pos)) || (!rc_zero_dates_flag && rc_elems))
{
register int tstart;
register int tend;
register int skipped;
register int len_rce = 0;
register int len_line;
register int len_fn_part;
register int len_text_part;
register int hls_len = 0;
auto char *ptr_char;
auto Bool same_date = FALSE;
auto Bool ok2;
/*
At last, sort the fixed dates only if they are either not presorted
or contain no resource file name reference, and not ONLY "empty"
fixed dates shall be displayed.
*/
if (!rc_zero_dates_flag && (rc_elems > 1))
{
if (rc_enable_fn_flag)
{
if (rc_sort_des_flag)
qsort ((VOID_PTR) rc_elems_table, rc_elems,
sizeof *rc_elems_table, (Cmp_func) fn_des_sort);
else
qsort ((VOID_PTR) rc_elems_table, rc_elems,
sizeof *rc_elems_table, (Cmp_func) fn_asc_sort);
}
else if (!is_presorted (rc_elems_table, rc_elems))
{
if (rc_sort_des_flag)
qsort ((VOID_PTR) rc_elems_table, rc_elems,
sizeof *rc_elems_table, (Cmp_func) des_sort);
else
qsort ((VOID_PTR) rc_elems_table, rc_elems,
sizeof *rc_elems_table, (Cmp_func) asc_sort);
}
else if (rc_sort_des_flag)
/*
`rc_elems_table[]' is presorted and must be shown in
descending sort order, rearrange its internal sort
order from ascending to descending sort order.
*/
reverse_order (rc_elems_table, rc_elems);
}
d = tmp_ad;
m = tmp_am;
/*
Copy `rc_grp_sep' [-c]g[] to text buffer variable `s3' for further use,
which will be first evaluated for text variable references and
some special texts. Thereafter, perform the '~'-TILDE or '^'-CARET
expansion on the one hand.
*/
if (rc_grp_sep != (char *) NULL)
{
register int x1 = year;
register int x2 = incr_year;
register int x3 = decr_year;
year = act_year;
incr_year = decr_year = 0;
insert_line_into_table (rc_grp_sep, _("`Internal'"),
(long) SPECIAL_VALUE, &rc_elems, 1, 1);
decr_year = x3;
incr_year = x2;
year = x1;
i = (int) strlen (rc_elems_table[--rc_elems]);
if ((Uint) i >= maxlen_max)
resize_all_strings (i + 1, FALSE, __FILE__, (long) __LINE__);
strcpy (s3, rc_elems_table[rc_elems] + len_year_max + 5);
free (rc_elems_table[rc_elems]);
ptr_char = s3;
if (*ptr_char)
{
/*
A text for grouping is defined.
*/
i = 0;
while (*ptr_char)
{
switch (*ptr_char)
{
case RC_NL_CHAR:
case RC_NL2_CHAR:
if (i)
{
/*
RC_NL[2]_CHAR is single `\~' or `\^' quoted
or double `\\~' or `\\^' quoted:
Replace QUOTE_CHAR by RC_NL[2]_CHAR resp.,
replace last QUOTE_CHAR by RC_NL_CHAR.
*/
if (s3[i - 1] == QUOTE_CHAR)
s3[i - 1] = *ptr_char;
else
/*
RC_NL[2]_CHAR is not quoted '~' or '^':
Insert a real `\n'-NEWLINE character.
*/
s3[i++] = '\n';
}
else
/*
RC_NL[2]_CHAR is not quoted '~' or '^':
Insert a real `\n'-NEWLINE character.
*/
s3[i++] = '\n';
break;
case QUOTE_CHAR:
ptr_char++;
if (*ptr_char)
{
if (*ptr_char == RC_NL_CHAR
|| *ptr_char == RC_NL2_CHAR)
s3[i++] = *ptr_char;
else
{
s3[i++] = QUOTE_CHAR;
s3[i++] = *ptr_char;
}
}
else
s3[i++] = QUOTE_CHAR;
break;
default:
s3[i++] = *ptr_char;
}
ptr_char++;
}
s3[i] = '\0';
}
}
(*s1) = (*s6) = '\0';
/*
Now display a leading NEWLINE character before the text/title.
*/
if (!rc_suppr_list_sep_flag)
print_text (stdout, s1);
/*
Now display the leading title/heading text of the fixed date list,
which will be first evaluated for text variable references and
some special texts. Thereafter, perform the '~'-TILDE or '^'-CARET
expansion on the one hand.
*/
if (rc_title_flag)
{
register int x1 = year;
register int x2 = incr_year;
register int x3 = decr_year;
year = act_year;
incr_year = decr_year = 0;
insert_line_into_table (rc_heading_text, _("`Internal'"),
(long) SPECIAL_VALUE, &rc_elems, 1, 1);
decr_year = x3;
incr_year = x2;
year = x1;
i = (int) strlen (rc_elems_table[--rc_elems]);
if ((Uint) i >= maxlen_max)
resize_all_strings (i + 1, FALSE, __FILE__, (long) __LINE__);
strcpy (s1, rc_elems_table[rc_elems] + len_year_max + 5);
free (rc_elems_table[rc_elems]);
ptr_char = s1;
i = 0;
while (*ptr_char)
{
switch (*ptr_char)
{
case RC_NL_CHAR:
case RC_NL2_CHAR:
if (i)
{
/*
RC_NL[2]_CHAR is single `\~' or `\^' quoted
or double `\\~' `\\^' quoted:
Replace QUOTE_CHAR by RC_NL[2]_CHAR resp.,
replace last QUOTE_CHAR by RC_NL[2]_CHAR.
*/
if (s1[i - 1] == QUOTE_CHAR)
s1[i - 1] = *ptr_char;
else
/*
RC_NL[2]_CHAR is not quoted '~' or '^':
Insert a real `\n'-NEWLINE character.
*/
s1[i++] = '\n';
}
else
/*
RC_NL[2]_CHAR is not quoted '~' or '^':
Insert a real `\n'-NEWLINE character.
*/
s1[i++] = '\n';
break;
case QUOTE_CHAR:
ptr_char++;
if (*ptr_char)
{
if (*ptr_char == RC_NL_CHAR || *ptr_char == RC_NL2_CHAR)
s1[i++] = *ptr_char;
else
{
s1[i++] = QUOTE_CHAR;
s1[i++] = *ptr_char;
}
}
else
s1[i++] = QUOTE_CHAR;
break;
default:
s1[i++] = *ptr_char;
}
ptr_char++;
}
s1[i] = '\0';
print_text (stdout, s1);
print_text (stdout, s1);
}
/*
Detect the number of digits of `rc_elems'.
*/
sprintf (s2, "%d",
(rc_zero_dates_flag) ? rc_elems - rc_zero_pos : rc_elems);
len_rce = (int) strlen (s2);
/*
Initialize the variables which control the loop.
*/
skipped = tstart = 0;
tend = rc_elems - 1;
if (rc_zero_dates_flag)
{
if (rc_sort_des_flag)
{
tstart = rc_elems - 1;
tend = rc_zero_pos;
skipped = rc_elems + 1;
}
else
skipped = tstart = rc_zero_pos;
}
/*
Now initialize the loop counter.
*/
tindex = tstart;
/*
And display all fixed dates of `rc_elems_table[]'.
*/
LOOP
{
lineptrs =
rc_get_date (rc_elems_table[tindex], lineptrs, FALSE, &b_dummy,
&day, &lm, &ly, &i_dummy, &i_dummy, &c_dummy, &i_dummy,
&i_dummy, _("Internal"), (long) tindex,
rc_elems_table[tindex], TRUE);
if ((tindex == tstart)
&& (rc_omit_date_flag
|| rc_alternative_format_flag || rc_grp_sep != (char *) NULL))
{
dd = day;
mm = lm;
yy = ly;
}
/*
Avoid displaying duplicate resource file entries by storing
the actual entry into `s6' and comparing it with the previous
entry in line.
*/
if (tindex == tstart
|| ((tindex != tstart) && strcmp (s6, rc_elems_table[tindex])))
{
strcpy (s6, rc_elems_table[tindex]);
/*
Now display fixed date list group separator resp.,
detect if date of text differs from previous text.
*/
if (rc_omit_date_flag
|| rc_alternative_format_flag || rc_grp_sep != (char *) NULL)
{
if ((day == dd) && (lm == mm) && (ly == yy))
{
/*
Same date:
Avoid displaying of group separator.
*/
if (tindex != tstart)
same_date = TRUE;
}
else
{
/*
Date differs.
*/
same_date = FALSE;
dd = day;
mm = lm;
yy = ly;
if (rc_grp_sep != (char *) NULL)
{
/*
Display constructed group separator text `-cg[TEXT]'.
*/
strcpy (s2, s3);
print_text (stdout, s2);
}
}
}
/*
Construct the leading (partitially highlighted) "date"-part of the fixed date.
*/
if (rc_week_number_flag)
{
j = week_number (day, lm, ly, iso_week_number, start_day);
/*
We convert the computed week number to a week number text
(this looks nicer in output).
*/
if (j < 0)
/*
Week starts in previous year and the first days
of the actual year are not in its first week.
*/
sprintf (s7, "|%02d/0|", -j);
else if (!j)
/*
Week starts in previous year and the first days
of the actual year are in its first week.
*/
sprintf (s7, "|%s|", "53/1");
else
/*
Week starts in actual year.
*/
sprintf (s7, "|%02d|", j);
if (!rc_alternative_format_flag)
{
if (strlen (s7) > 4)
{
if (rc_count_flag)
sprintf (s1, "%0*d) %s ", len_rce,
abs ((tindex - skipped) + 1), s7);
else
sprintf (s1, "%s ", s7);
}
else if (rc_count_flag)
sprintf (s1, "%0*d) %s%*s ", len_rce,
abs ((tindex - skipped) + 1), s7, len_fil_wt,
"");
else
sprintf (s1, "%s%*s ", s7, len_fil_wt, "");
}
}
else if (!rc_alternative_format_flag && rc_count_flag)
sprintf (s1, "%0*d) ", len_rce, abs ((tindex - skipped) + 1));
wd = day;
ld = day_of_year (day, lm, ly);
if (!rc_both_dates_flag)
{
if (!rc_special_flag)
ld = 0;
else
day = 0;
}
if (!rc_suppr_date_part_flag)
{
if ((ly == tmp_ay) && (lm == tmp_am) && (wd == tmp_ad))
hls_len =
decode_date_format (date_format->df_format, &s1, day, lm,
ly, ld, TRUE, FALSE,
!rc_alternative_format_flag);
else
{
if (hd_ldays[((lm - 1) * MONTH_LAST) + (wd - 1)])
hls_len =
decode_date_format (date_format->df_format, &s1, day,
lm, ly, ld, FALSE, TRUE,
!rc_alternative_format_flag);
else
hls_len =
decode_date_format (date_format->df_format, &s1, day,
lm, ly, ld, FALSE, FALSE,
!rc_alternative_format_flag);
}
if (rc_alternative_format_flag && rc_week_number_flag)
{
sprintf (s2, _(" ; Week %s"), s7);
}
else
*s2 = '\0';
}
else
{
if (rc_alternative_format_flag && rc_week_number_flag)
{
sprintf (s2, _("Week %s"), s7);
}
else
*s2 = '\0';
}
if (*s2 || !rc_suppr_date_part_flag)
{
strcat (s2, ":");
strcat (s1, s2);
}
j = (int) strlen (s1) - hls_len;
/*
Skip the separating whitespace character between
the "date"-part and the "text"-part.
*/
if (*lineptrs->text_part == ' ')
lineptrs->text_part++;
/*
Construct the "text"-part of the fixed date.
*/
len_text_part = (int) strlen (lineptrs->text_part);
if (rc_alternative_format_flag)
{
if (!same_date && *s1)
/*
Print the constructed date on a separate line
only if it appears the first time!
*/
print_text (stdout, s1);
if (rc_count_flag)
{
sprintf (s1, "%0*d)", len_rce,
abs ((tindex - skipped) + 1));
if (len_text_part)
strcat (s1, " ");
}
else
*s1 = '\0';
j = len_line = (int) strlen (s1);
}
else
len_line = j + hls_len + (int) !rc_suppr_date_part_flag;
/*
Now check if it's necessary to modify the "text"-part of the fixed date.
*/
ok = FALSE;
len_fn_part = 0;
/*
"Empty" texts have no trailing blank character!
*/
if (len_text_part)
{
if (!rc_alternative_format_flag && !rc_suppr_date_part_flag)
strcat (s1, " ");
/*
Get the textual length of the file name,
which has been inserted into the line.
*/
if (rc_enable_fn_flag)
{
auto Bool pseudo_quote_found = FALSE;
/*
Add the length of the "file name"+3 (+3 because the file
name itself is leaded by a blank character and is
enclosed in PSEUDO_QUOTE characters to the number of
leading blanks, which must be displayed if the line
wrapped by a given `~'-TILDE.
*/
ptr_char = lineptrs->text_part;
while (*ptr_char)
{
len_fn_part++;
if (*ptr_char == PSEUDO_QUOTE)
{
if (!pseudo_quote_found)
pseudo_quote_found = TRUE;
else
break;
}
ptr_char++;
}
if (!*ptr_char)
/*
Internal error, a maintainer has modified the internal
format of a line and forgots to respect this
modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__,
(long) __LINE__, "", 0);
c_dummy = *++ptr_char;
if (*ptr_char)
{
len_line++;
ptr_char++;
c_dummy = *ptr_char;
*ptr_char = '\0';
}
strcat (s1, lineptrs->text_part);
i = len_fn_part;
len_line += i;
if (c_dummy)
{
*ptr_char = c_dummy;
i++;
j += (int) !rc_alternative_format_flag;
}
len_text_part -= i;
lineptrs->text_part += i;
/*
Now exchange the first two PSEUDO_QUOTE characters
-- which embrace the "file name" -- by parentheses.
*/
ptr_char = strchr (s1, PSEUDO_QUOTE);
if (ptr_char == (char *) NULL)
/*
Internal error, a maintainer has modified the internal
format of a line and forgots to respect this
modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__,
(long) __LINE__, "", 0);
*ptr_char = '(';
ptr_char = strchr (s1, PSEUDO_QUOTE);
if (ptr_char == (char *) NULL)
/*
Internal error, a maintainer has modified the internal
format of a line and forgots to respect this
modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__,
(long) __LINE__, "", 0);
*ptr_char = ')';
/*
Check if the FIRST character of the REAL "text"-part was a quoted
whitespace character (this is indicated by a PSEUDO_QUOTE
character ('\001') followed by a "whitespace" character,
see `rc-check.c'). If this case is TRUE, skip the PSEUDO_QUOTE.
*/
if (*lineptrs->text_part)
if ((*lineptrs->text_part == PSEUDO_QUOTE)
&& isspace (lineptrs->text_part[1]))
{
lineptrs->text_part++;
len_text_part--;
}
}
else
{
/*
Check if the FIRST character of the "text"-part was a quoted
whitespace character (this is indicated by a PSEUDO_QUOTE
character ('\001') followed by a "whitespace" character,
see `rc-check.c'). If this case is TRUE, skip the PSEUDO_QUOTE.
*/
if ((*lineptrs->text_part == PSEUDO_QUOTE)
&& isspace (lineptrs->text_part[1]))
{
lineptrs->text_part++;
len_text_part--;
}
}
ok =
(Bool) (strchr (lineptrs->text_part, RC_NL_CHAR) ==
(char *) NULL);
ok2 =
(Bool) (strchr (lineptrs->text_part, RC_NL2_CHAR) ==
(char *) NULL);
if (ok && ok2)
{
if (*lineptrs->text_part)
{
if ((Uint) len_line + len_text_part >= maxlen_max)
resize_all_strings (len_line + len_text_part + 1,
FALSE, __FILE__,
(long) __LINE__);
strcat (s1, lineptrs->text_part);
}
}
else
{
/*
`~'-TILDE, `^'-CARET or quoted `\~'-TILDE resp., CARET found
in "text"-part of fixed date:
Quote TILDE/CARET resp., insert a real `\n'-NEWLINE character
*/
while (*lineptrs->text_part)
{
if ((Uint) len_line >= maxlen_max)
resize_all_strings (maxlen_max << 1, FALSE,
__FILE__, (long) __LINE__);
if (*lineptrs->text_part == RC_NL_CHAR)
{
/*
RC_NL_CHAR is single `\~' quoted
or double `\\~' quoted:
Replace QUOTE_CHAR by RC_NL_CHAR resp.,
replace last QUOTE_CHAR by RC_NL_CHAR.
*/
if (s1[len_line - 1] == QUOTE_CHAR)
s1[len_line - 1] = *lineptrs->text_part;
else
{
/*
RC_NL_CHAR is not quoted '~':
Insert a real `\n'_NEWLINE character.
*/
s1[len_line++] = '\n';
/*
Insert some leading blanks.
*/
if (rc_alternative_format_flag
&& !rc_enable_fn_flag)
n = j;
else
{
n = j + len_fn_part + 1;
if (!rc_alternative_format_flag)
n -= (int) rc_suppr_date_part_flag;
}
for (i = 0; i < n; i++)
{
if ((Uint) len_line >= maxlen_max)
resize_all_strings (maxlen_max << 1,
FALSE, __FILE__,
(long) __LINE__);
s1[len_line++] = ' ';
}
}
}
else if (*lineptrs->text_part == RC_NL2_CHAR)
{
/*
RC_NL2_CHAR is single `\^' quoted
or double `\\^' quoted:
Replace QUOTE_CHAR by RC_NL2_CHAR resp.,
replace last QUOTE_CHAR by RC_NL2_CHAR.
*/
if (s1[len_line - 1] == QUOTE_CHAR)
s1[len_line - 1] = *lineptrs->text_part;
else
/*
RC_NL2_CHAR is not quoted '^':
Insert a real `\n'_NEWLINE character only!
*/
s1[len_line++] = '\n';
}
else
s1[len_line++] = *lineptrs->text_part;
lineptrs->text_part++;
}
s1[len_line] = '\0';
}
}
if (rc_omit_date_flag && !rc_alternative_format_flag && same_date)
{
/*
Overwrite leading "date"-part of output with blanks.
*/
if (rc_count_flag)
i = len_rce + 3; /* +3 because of the ") " text */
else
i = 0;
n = j - (int) rc_suppr_date_part_flag;
for (; i < n; i++)
s1[i] = ' ';
ptr_char = s1 + j + hls_len;
for (i = j; *ptr_char; i++)
s1[i] = *ptr_char++;
s1[i] = '\0';
}
/*
Now we display the constructed fixed date text.
*/
if (!rc_alternative_format_flag || len_text_part || len_line)
print_text (stdout, s1);
}
else
skipped++;
/*
Now deallocate the just displayed/skipped fixed date in the table.
*/
free (rc_elems_table[tindex]);
/*
Check if all fixed date entries are displayed.
*/
if (tindex == tend)
break;
/*
If not, increase/decrease the loop counter.
*/
if (rc_zero_dates_flag && rc_sort_des_flag)
tindex--;
else
tindex++;
}
}
/*
Now deallocate all NON-"empty" fixed dates in the table
in case only "empty" fixed dates were displayed.
*/
if (rc_zero_dates_flag && (rc_elems - rc_zero_pos))
for (tindex = 0; tindex < rc_zero_pos; tindex++)
free (rc_elems_table[tindex]);
}
static int
fn_asc_sort (a, b)
const char **a;
const char **b;
/*
The (q)sort compare function for fixed dates which texts
have an included resource "file name"; ascending order.
*/
{
static Uint previous_len;
static int i;
static char *a_text;
static char *b_text;
static char *ptr_char;
static Bool is_initialized = FALSE;
/*
Don't sort on the included resource "file name",
sort on the REAL text of the fixed date O N L Y !!!
*/
if (!is_initialized)
{
a_text = (char *) my_malloc (maxlen_max, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 1L,
"a_text", 0);
b_text = (char *) my_malloc (maxlen_max, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 1L,
"b_text", 0);
previous_len = maxlen_max;
is_initialized = TRUE;
}
else if (previous_len < maxlen_max)
{
a_text = (char *) my_realloc ((VOID_PTR) a_text,
maxlen_max, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 2L,
"a_text", maxlen_max);
b_text = (char *) my_realloc ((VOID_PTR) b_text,
maxlen_max, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 2L,
"b_text", maxlen_max);
previous_len = maxlen_max;
}
i = len_year_max + 4;
/*
Copy the "date"-part AS IS.
*/
strncpy (a_text, *a, i);
a_text[i] = '\0';
/*
Skip the filename part.
*/
if (*(*a + i + 1) != PSEUDO_QUOTE)
/*
Internal error, a maintainer has modified the internal format
of a line and forgots to respect this modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__, (long) __LINE__, "", 0);
ptr_char = strchr (*a + i + 2, PSEUDO_QUOTE);
if (ptr_char == (char *) NULL)
/*
Internal error, a maintainer has modified the internal format
of a line and forgots to respect this modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__, (long) __LINE__, "", 0);
ptr_char++;
/*
And concatenate the "text"-part.
*/
if (*ptr_char)
strcat (a_text, ptr_char);
/*
Copy the "date"-part AS IS.
*/
strncpy (b_text, *b, i);
b_text[i] = '\0';
/*
Skip the filename part.
*/
if (*(*b + i + 1) != PSEUDO_QUOTE)
/*
Internal error, a maintainer has modified the internal format
of a line and forgots to respect this modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__, (long) __LINE__, "", 0);
ptr_char = strchr (*b + i + 2, PSEUDO_QUOTE);
if (ptr_char == (char *) NULL)
/*
Internal error, a maintainer has modified the internal format
of a line and forgots to respect this modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__, (long) __LINE__, "", 0);
ptr_char++;
/*
And concatenate the "text"-part.
*/
if (*ptr_char)
strcat (b_text, ptr_char);
return (strcmp (a_text, b_text));
}
static int
fn_des_sort (a, b)
const char **a;
const char **b;
/*
The (q)sort compare function for fixed dates which texts
have an included resource "file name"; descending order.
*/
{
static Uint previous_len;
static int i;
static char *a_text;
static char *b_text;
static char *ptr_char;
static Bool is_initialized = FALSE;
/*
Don't sort on the included resource "file name",
sort on the REAL text of the fixed date O N L Y !!!
*/
if (!is_initialized)
{
a_text = (char *) my_malloc (maxlen_max, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 1L,
"a_text", 0);
b_text = (char *) my_malloc (maxlen_max, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 1L,
"b_text", 0);
previous_len = maxlen_max;
is_initialized = TRUE;
}
else if (previous_len < maxlen_max)
{
a_text = (char *) my_realloc ((VOID_PTR) a_text,
maxlen_max, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 2L,
"a_text", maxlen_max);
b_text = (char *) my_realloc ((VOID_PTR) b_text,
maxlen_max, ERR_NO_MEMORY_AVAILABLE,
__FILE__, ((long) __LINE__) - 2L,
"b_text", maxlen_max);
previous_len = maxlen_max;
}
i = len_year_max + 4;
/*
Copy the "date"-part AS IS.
*/
strncpy (a_text, *a, i);
a_text[i] = '\0';
/*
Skip the filename part.
*/
if (*(*a + i + 1) != PSEUDO_QUOTE)
/*
Internal error, a maintainer has modified the internal format
of a line and forgots to respect this modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__, (long) __LINE__, "", 0);
ptr_char = strchr (*a + i + 2, PSEUDO_QUOTE);
if (ptr_char == (char *) NULL)
/*
Internal error, a maintainer has modified the internal format
of a line and forgots to respect this modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__, (long) __LINE__, "", 0);
ptr_char++;
/*
And concatenate the "text"-part.
*/
if (*ptr_char)
strcat (a_text, ptr_char);
/*
Copy the "date"-part AS IS.
*/
strncpy (b_text, *b, i);
b_text[i] = '\0';
/*
Skip the filename part.
*/
if (*(*b + i + 1) != PSEUDO_QUOTE)
/*
Internal error, a maintainer has modified the internal format
of a line and forgots to respect this modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__, (long) __LINE__, "", 0);
ptr_char = strchr (*b + i + 2, PSEUDO_QUOTE);
if (ptr_char == (char *) NULL)
/*
Internal error, a maintainer has modified the internal format
of a line and forgots to respect this modification here!
*/
my_error (ERR_MAINTAINER_FAILURE, __FILE__, (long) __LINE__, "", 0);
ptr_char++;
/*
And concatenate the "text"-part.
*/
if (*ptr_char)
strcat (b_text, ptr_char);
return (strcmp (b_text, a_text));
}
#endif /* USE_RC */
|