From 2dfc0571356da7636cfd590fb386d34702b1ad7b Mon Sep 17 00:00:00 2001 From: mfranz Date: Mon, 2 Jul 2007 15:42:19 +0000 Subject: [PATCH] replace exit() by throw sg_exception(). Of course, we have to be aware that interdependencies between sg libs are generally unwelcome, but sg_exception is a rather basic part, and it's already used by xml, props, scene, sound and, of course, structure. Since props and xml are core libs, we can assume that sg_exceptions are available. (OK'ed by Curt) --- simgear/timing/lowleveltime.cxx | 14 ++++++++------ simgear/timing/timezone.cxx | 8 ++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/simgear/timing/lowleveltime.cxx b/simgear/timing/lowleveltime.cxx index 9aa4e459..a5505269 100644 --- a/simgear/timing/lowleveltime.cxx +++ b/simgear/timing/lowleveltime.cxx @@ -40,6 +40,9 @@ #include #include #include + +#include + #include "lowleveltime.h" @@ -331,19 +334,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! diff --git a/simgear/timing/timezone.cxx b/simgear/timing/timezone.cxx index f052032a..0b2e74c6 100644 --- a/simgear/timing/timezone.cxx +++ b/simgear/timing/timezone.cxx @@ -29,6 +29,9 @@ #include #include #include + +#include + #include "timezone.h" SGTimeZone::SGTimeZone(float la, float lo, char* cc, char* desc) : @@ -126,8 +129,9 @@ SGTimeZoneContainer::SGTimeZoneContainer(const char *filename) char buffer[256]; FILE* infile = fopen(filename, "rb"); if (!(infile)) { - fprintf(stderr, "Unable to open file %s\n", filename); - exit(1); + string e = "Unable to open time zone file '"; + throw sg_exception(e + filename + '\''); + } else { errno = 0; -- 2.39.5