(*** This bug was imported into bugs.kde.org ***) Package: korganizer Version: KDE 3.0.0 Severity: normal Installed from: Compiled From Sources Compiler: gcc 2.95.3 OS: Solaris OS/Compiler notes: Solaris 8 Hi I'm not able to get korganizer to use my timezone (PST/PDT). * In the Configure Korganizer I get only a [No selection] for the time zone:-( * I tried to change the korganizerrc file but so far it did not help:-( * That's especialy bad because I tried to use my *.ics file from KDE2.2.2 and now all my appointments are in the late evening;-) * kcontrol shows the right time and time zone! Thanks -- Marco (Submitted via bugs.kde.org)
Hi This patch does a little bit more than the fix of the Solaris timezone problem;-) It also sets the current timezone correctly Thanks -- Marco --------------------------------------------------------------------------- --- kdepim-3.0/korganizer/koprefsdialog.cpp~Mon Mar 18 04:43:58 2002 +++ kdepim-3.0/korganizer/koprefsdialog.cppWed Apr 17 17:50:56 2002 @@ -556 +5513 @@ #include <kurlrequester.h> #include <klineedit.h> +#if defined(USE_SOLARIS) +#include <sys/param.h> + +#define ZONEINFODIR"/usr/share/lib/zoneinfo" +#define INITFILE"/etc/default/init" +#endif + #include "koprefs.h" #include "koprefsdialog.h" @@ -19119 +19856 @@ FILE *f; char tempstring[101] = "Unknown"; - char szCurrentlySet[101] = "Unknown"; + QString sCurrentlySet(i18n("Unknown")); + int nCurrentlySet = 0; QStrList list; // read the currently set time zone +#if defined(USE_SOLARIS)// MARCO + char buf[MAXPATHLEN]; + + snprintf(buf MAXPATHLEN + "/bin/fgrep 'TZ=' %s | /bin/head -n 1 | /bin/cut -b 4-" + INITFILE); + + if (f = popen(buf "r")) + { +if (fgets(buf MAXPATHLEN - 1 f) != NULL) + { + buf[strlen(buf) - 1] = '\0'; + sCurrentlySet = QString(buf); + } +pclose(f); + } +#else if((f = fopen("/etc/timezone" "r")) != NULL) { // get the currently set timezone - fgets(szCurrentlySet 100 f); + fgets(tempstring 100 f); + tempstring(strlen(tempstring) - 1] = '\0'; + sCurrentlySet = QString(tempstring); fclose(f); } +#endif // !USE_SOLARIS mTimeZoneCombo->insertItem(i18n("[No selection]")); // Read all system time zones +#if defined(USE_SOLARIS)// MARCO + snprintf(buf MAXPATHLEN + "/bin/find %s \\( -name src -prune \\) -o -type f -print | /bin/cut -b %d-" + ZONEINFODIR strlen(ZONEINFODIR) + 2); + + if (f = popen(buf "r")) + { +while(fgets(buf MAXPATHLEN - 1 f) != NULL) + { + buf[strlen(buf) - 1] = '\0'; + list.inSort(buf); + } +pclose(f); + } + +#else f = popen("grep -e ^[^#] /usr/share/zoneinfo/zone.tab | cut -f 3""r"); if (!f) return; while(fgets(tempstring 100 f) != NULL) { @@ -2119 +25521 @@ list.inSort(tempstring); } pclose(f); +#endif // !USE_SOLARIS mTimeZoneCombo->insertStrList(&list); + // find the currently set time zone and select it + for (int i = 0; i < mTimeZoneCombo->count(); i++) + { + if (mTimeZoneCombo->text(i) == sCurrentlySet) + { + nCurrentlySet = i; + break; + } + } + + mTimeZoneCombo->setCurrentItem(nCurrentlySet); topLayout->addWidget(new QLabel(i18n("Default Appointment Time:") topFrame)10); --
The attached patch can't be completely correct: + fgets(tempstring 100 f); + tempstring(strlen(tempstring) - 1] = '\0'; + sCurrentlySet = QString(tempstring); is a) syntactically wrong: it should obviously be [strlen(...)-1] with two square brackets. b) semantically bogus: strlen works by walking along the string and looking for a '\0'. So either there already is one and the whole line is void or there isn't one and you're accessing memory you'd better leave alone. Looking at the fgets man page the former is the case and the line can simply be removed. This is not meant to be a statement about the overall correctness of the patch beyond this obvious issue. Michael
Created attachment 250 [details] make timezone selection & correct alarm time work on Solaris This patch ist basically Marco Walther's and should be applicable to the cvs version. It would be nice to have this in 3.1 if it doesn't break anything on non-Solaris systems... Torsten
I applied the patch (after making it compile), but I would like to get a comment about Michaels observations (see the bugzilla entry).