openbsd-ports/x11/kde/base3/patches/patch-kcontrol_clock_tzone_cpp
espie af7e1f85d0 basic import of kde 3.1.95, still missing a few parts.
TODO:
- compile the missing packages.
- redo konsole fixes for our ttys.
- figure out why kuickshow is broken.
- make sure we get all dependencies.
- repair kscd.
- find out why nsplugins does not like the native jdk.
- figure out how to get kvim to work.
- change filenames or adjust check-lib-depends to cope.
2004-02-01 14:59:21 +00:00

90 lines
2.5 KiB
Plaintext

$OpenBSD: patch-kcontrol_clock_tzone_cpp,v 1.2 2004/02/01 14:59:22 espie Exp $
--- kcontrol/clock/tzone.cpp.orig 2004-01-17 13:47:47.000000000 +0100
+++ kcontrol/clock/tzone.cpp 2004-01-21 01:20:49.000000000 +0100
@@ -50,8 +50,14 @@
#include <sys/stat.h>
#define ZONEINFODIR "/usr/share/lib/zoneinfo"
+#define FIND_BINARY "/bin/find"
#define INITFILE "/etc/default/init"
#endif
+#ifdef __OpenBSD__
+#define ZONEINFODIR "/usr/share/zoneinfo"
+#define FIND_BINARY "/usr/bin/find"
+#include <sys/param.h>
+#endif
Tzone::Tzone(QWidget * parent, const char *name)
: QGroupBox(parent, name)
@@ -86,14 +92,15 @@ void Tzone::fillTimeZones()
tzonelist->insertItem(i18n("[No selection]"));
-#if defined(USE_SOLARIS) // MARCO
+#if defined(USE_SOLARIS) || defined(__OpenBSD__) // MARCO
FILE *fp;
char buf[MAXPATHLEN];
+ char *p = buf + strlen(ZONEINFODIR) + 1;
snprintf(buf, MAXPATHLEN,
- "/bin/find %s \\( -name src -prune \\) -o -type f -print | /bin/cut -b %d-",
- ZONEINFODIR, strlen(ZONEINFODIR) + 2);
+ "%s %s \\( -name src -prune \\) -o -type f -print",
+ FIND_BINARY, ZONEINFODIR);
fp = popen(buf, "r");
if (fp)
@@ -101,8 +108,8 @@ void Tzone::fillTimeZones()
while(fgets(buf, MAXPATHLEN - 1, fp) != NULL)
{
buf[strlen(buf) - 1] = '\0';
- list << i18n(buf);
- tzonenames << buf;
+ list << i18n(p);
+ tzonenames << p;
}
pclose(fp);
}
@@ -166,6 +173,14 @@ void Tzone::load()
}
pclose(fp);
}
+#elif defined(__OpenBSD__)
+ char buffer[MAXPATHLEN];
+ int n;
+ n = readlink("/etc/localtime", buffer, sizeof(buffer)-1);
+ if (n != -1) {
+ buffer[n] = 0;
+ sCurrentlySet = buffer + strlen(ZONEINFODIR)+1;
+ }
#else
QFile f("/etc/timezone");
if(f.open(IO_ReadOnly))
@@ -264,6 +279,7 @@ void Tzone::save()
QString val = selectedzone;
#else
+#if !defined(__OpenBSD__)
QFile fTimezoneFile("/etc/timezone");
if (fTimezoneFile.open(IO_WriteOnly | IO_Truncate) )
@@ -273,6 +289,7 @@ void Tzone::save()
fTimezoneFile.close();
}
+#endif
tz = "/usr/share/zoneinfo/" + selectedzone;
kdDebug() << "Set time zone " << tz << endl;
@@ -294,7 +311,9 @@ void Tzone::save()
} else {
#if !defined(USE_SOLARIS) // Do not update the System!
+#if !defined(__OpenBSD__)
unlink( "/etc/timezone" );
+#endif
unlink( "/etc/localtime" );
setenv("TZ", "", 1);