X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Ftiming%2Flowleveltime.cxx;h=9d20655d6361ab94904086533a42b0aecff3b465;hb=6a7c2000027cd22eea603e936ddbad1a5bfc8b04;hp=2ae1570087b6433434d6c26d560fc8715a75952b;hpb=1b07b25ad2eb26be45f7df744efa332a230d2baf;p=simgear.git diff --git a/simgear/timing/lowleveltime.cxx b/simgear/timing/lowleveltime.cxx index 2ae15700..9d20655d 100644 --- a/simgear/timing/lowleveltime.cxx +++ b/simgear/timing/lowleveltime.cxx @@ -2,19 +2,19 @@ * Written by various people (I"ll look up the exact credits later) * Modified by Durk Talsma, July 1999 for use in FlightGear * - * 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 2 of the - * License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of + * This library 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 - * General Public License for more details. + * Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * **************************************************************************/ @@ -40,6 +40,9 @@ #include #include #include + +#include + #include "lowleveltime.h" @@ -285,10 +288,10 @@ static void fgtzset_internal (int always, const char *tz) time(&now); static int is_initialized = 0; //register const char *tz; - register size_t l; - char *tzbuf; - unsigned short int hh, mm, ss; - unsigned short int whichrule; + // register size_t l; + // char *tzbuf; + // unsigned short int hh, mm, ss; + // unsigned short int whichrule; if (is_initialized && !always) return; @@ -303,16 +306,11 @@ static void fgtzset_internal (int always, const char *tz) /* User specified the empty string; use UTC explicitly. */ tz = "Universal"; -#ifdef MACOS - /* as you well know, mac paths contain leading colon, this code - messes things up.... */ -#else /* A leading colon means "implementation defined syntax". We ignore the colon and always use the same algorithm: try a data file, and if none exists parse the 1003.1 syntax. */ if (tz && *tz == ':') ++tz; -#endif /* Check whether the value changes since the last run. */ if (old_fgtz != NULL && tz != NULL && strcmp (tz, old_fgtz) == 0) @@ -331,19 +329,18 @@ static void fgtzset_internal (int always, const char *tz) fgtzfile_read (tz); if (use_fgtzfile) return; - // The default behaviour of the originale tzset_internal (int always, char* tz) - // function is to set up a default timezone, in any casetz file_read() fails - // Currently this leads to problems, because it modidifies the system timezone + // The default behaviour of the original tzset_internal (int always, char* tz) + // function is to set up a default timezone, in any case file_read() fails + // Currently this leads to problems, because it modifies the system timezone // and not the local aircraft timezone, contained in FlightGear. I could adapt // this in future versions of this code, but doubt whether this is what we really - // want. So right now, exit when timezone information reading failed. + // want. So right now, throw an exception when timezone information reading failed. // Guess I'll change that to something like 12 * (FG_LON / 180.0) // // For now, I'll leave it like this. else { - printf ("Timezone reading failed\n"); - exit(1); + throw sg_exception("Timezone reading failed"); } // this emacs "comment out" function is cool! @@ -789,7 +786,7 @@ static struct ttinfo * fgfind_transition (time_t timer) /**************************************************************************/ void fgtzfile_read (const char *file) { - static const char default_tzdir[] = TZDIR; + // static const char default_tzdir[] = TZDIR; size_t num_isstd, num_isgmt; register FILE *f; struct tzhead tzhead; @@ -861,8 +858,12 @@ void fgtzfile_read (const char *file) // } f = fopen (file, "rb"); - if (f == NULL) - return; + + if (f == NULL) { + perror( "fgtzfile_read(): " ); + errno = 0; + return; + } if (fread ((void *) &tzhead, sizeof (tzhead), 1, f) != 1) goto lose; @@ -993,7 +994,7 @@ void fgtzfile_read (const char *file) /****************************************************************************/ static void fgcompute_tzname_max (size_t chars) { - extern size_t tzname_cur_max; /* Defined in tzset.c. */ + // extern size_t tzname_cur_max; /* Defined in tzset.c. */ const char *p;