patch-luna_c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. $OpenBSD: patch-luna_c,v 1.2 2007/12/18 09:43:36 ajacoutot Exp $
  2. --- luna.c.orig Tue Dec 18 09:36:17 2007
  3. +++ luna.c Tue Dec 18 09:36:17 2007
  4. @@ -25,27 +25,41 @@
  5. #include "luna.h"
  6. -void
  7. +int
  8. main(argc, argv)
  9. int argc;
  10. char **argv;
  11. {
  12. - int aotmoon, i;
  13. - struct tm *localtmp, *algotmp;
  14. - char *chp;
  15. + int aotmoon, tzhere, i;
  16. + struct tm *localtmp, algotm;
  17. + char *chp, *envp, *tzname;
  18. - getoptions(argc, argv, &localtmp, &algotmp);
  19. + getoptions(argc, argv, &localtmp);
  20. + envp = getenv("TZ");
  21. + if ((envp = getenv("TZ")) == NULL ||
  22. + (chp = strchr(envp, '-')) == NULL && (chp = strchr(envp, '+')) == NULL
  23. + ) {
  24. + tzhere = TZ_DFL;
  25. + } else {
  26. + tzhere = atoi(chp);
  27. + }
  28. + tzconv(&algotm, localtmp, tzhere - TZ_ALGO);
  29. +
  30. for (i = 0; i < bdate; i++) {
  31. if (extluna) {
  32. aotmoon = getext(localtmp -> tm_year, localtmp -> tm_mon,
  33. localtmp -> tm_mday);
  34. } else {
  35. - aotmoon = getmoon(algotmp -> tm_year, algotmp -> tm_yday);
  36. + aotmoon = getmoon(algotm.tm_year, algotm.tm_yday);
  37. }
  38. +
  39. + if ((tzname = getenv("TZ")) == NULL) {
  40. + tzname = TZNAME_DFL;
  41. + }
  42. - chp = Asctime(localtmp);
  43. + chp = asctime(localtmp);
  44. chp[LASCTIME - 2] = 0;
  45. - printf("%s", chp);
  46. + printf("%s %3.3s", chp, tzname);
  47. if (numonly) {
  48. printf(" ");
  49. @@ -62,7 +76,7 @@ main(argc, argv)
  50. today = FALSE;
  51. tomorrow(localtmp);
  52. - tomorrow(algotmp);
  53. + tomorrow(&algotm);
  54. }
  55. exit(0);
  56. @@ -177,18 +191,16 @@ usage()
  57. void
  58. -getoptions(argc, argv, localtmpp, algotmpp)
  59. +getoptions(argc, argv, localtmpp)
  60. int argc;
  61. char **argv;
  62. struct tm **localtmpp;
  63. - struct tm **algotmpp;
  64. {
  65. - int argnum[3], argnumcnt,
  66. - tzhere;
  67. - char *chp, *envp;
  68. + int argnum[3], argnumcnt;
  69. + char *chp;
  70. +
  71. register int j, i;
  72. BOOLEAN namedmon, followname;
  73. - static struct tm algotm;
  74. struct tm *localtmp;
  75. argnumcnt = 0;
  76. @@ -203,7 +215,7 @@ getoptions(argc, argv, localtmpp, algotmpp)
  77. strlwr(argv[i]);
  78. #else
  79. for (j = 0; j < strlen(argv[i]); j++) {
  80. - *(argv[i] + j) = Tolower(*(argv[i] + j));
  81. + *(argv[i] + j) = tolower(*(argv[i] + j));
  82. }
  83. #endif /* MSDOS or not */
  84. @@ -376,19 +388,7 @@ getoptions(argc, argv, localtmpp, algotmpp)
  85. = ymd2yday(localtmp -> tm_year, localtmp -> tm_mon,
  86. localtmp -> tm_mday);
  87. - envp = getenv("TZ");
  88. - if ((envp = getenv("TZ")) == NULL ||
  89. - (chp = strchr(envp, '-')) == NULL && (chp = strchr(envp, '+')) == NULL
  90. - ) {
  91. - tzhere = TZ_DFL;
  92. - } else {
  93. - tzhere = atoi(chp);
  94. - }
  95. - tzconv(&algotm, localtmp, tzhere - TZ_ALGO);
  96. -printf("%d %d:%d\n", algotm.tm_mday, algotm.tm_hour, algotm.tm_min);
  97. -
  98. *localtmpp = localtmp;
  99. - *algotmpp = &algotm;
  100. return;
  101. }