NAME
mv - move blog
SYNOPSIS
mv URL
DESCRIPTION
Blog was moved off blogger
SEE ALSO
https://blog.deschouwer.co.za/
AUTHOR
Berend De Schouwer
NAME
mv - move blog
SYNOPSIS
mv URL
DESCRIPTION
Blog was moved off blogger
SEE ALSO
https://blog.deschouwer.co.za/
AUTHOR
Berend De Schouwer
select 'Mon May 11 11:21:31 SAST 2015'::date;This works, but only for some timezones:
select 'Mon May 11 11:21:31 CAT 2015'::date; ERROR: invalid input syntax for type date: "Mon May 11 11:21:31 CAT 2015" LINE 1: select 'Mon May 11 11:21:31 CAT 2015'::date ;CAT is unknown.
The problem is caused by a peculiar characteristic of C: char is machine specific. char can be signed or unsigned, depending on the processor.char c = -1 // -1; int i = c // -1; call_something(i /* -1 */);
The difference is because C auto-promotes signed char to signed int, and unsigned char to signed int.char c = -1; // 255 int i = c; // 255 call_something(i /* 255 */);
#includevoid foo(char *fmt, ...){ va_list ap; va_start(ap, fmt); int i = va_arg(ap, int); ... va_end(ap); }
void foo(char *fmt, int i){ }
However, it will auto-promote chars. You cannot use va_arg(ap, char). va_list and friends are macros. So you have to be very careful if you think you'll grab all instances of char.
AC_C_CHAR_UNSIGNED
if test $ac_cv_c_char_unsigned = yes && test "$GCC" = yes; then
CFLAGS+=" -fsigned-char "
fi
// list of strings
char * list[] = {
"apple",
"pear",
NULL
}
char ** s;
for (s = list; *s; ++s) {
printf("%s\n", *s);
}
if (malloc(-1) == NULL) return (-1);
// list of strings
char * list[] = {
"apple",
"pear",
NULL,
"banana",
NULL
}
we'd never get to "banana". We'd never free it. There would be a memory leak.
char * list[] = {
"apple",
"pear",
(void *)-1,
"banana",
NULL
}
Now we can check for (void *)-1 to know that the list isn't finished (not NULL), but that the contents at this index are uninitialized.
Implementing central authentication with password expiry on systems that implement NSS is actually broken.
if [ -r /home/berend.deschouwer/.gnupg/gpg-agent-hostname ]; then . .gnupg/gpg-agent-info-hostname export GPG_AGENT_INFO SSH_AUTH_SOCK SSH_AGENT_PID fi
export DISPLAY=:0.0 gnome-shell --replace &
--- unix/xc/programs/Xserver/vnc/XserverDesktop.cc.timer 2010-06-04 11:18:07.000000000
+0200
+++ unix/xc/programs/Xserver/vnc/XserverDesktop.cc 2010-06-04 11:48:45.000000000 +0200
@@ -1000,6 +1000,10 @@
}
dev->kbdfeed->ctrl = ctrl;
(*dev->kbdfeed->CtrlProc)(dev, &dev->kbdfeed->ctrl);
+ vlog.info("Resetting keyboard timer.");
+ deferredUpdateTimerSet = false;
+ deferredUpdateTimer = 0;
+ server->tryUpdate();
}
bool XserverDesktop::getKeyRepeat()
Section "Module" Load "vnc" EndSection Section "Screen" Option "RemapKeys" "0xffae->0x2e,0xffb0->0x30,0xffb1->0x31,0xffb2->0x32,0xffb3->0x33,0xffb4->0x34,0xffb5->0x35,0xffb6->0x36,0xffb7->0x37,0xffb8->0x38,0xffb9->0x39" EndSection
--- common/rfb/VNCServerST.h.orig 2010-05-27 15:41:38.000000000 +0200
+++ common/rfb/VNCServerST.h 2010-05-27 15:42:10.000000000 +0200
@@ -219,6 +219,7 @@
QueryConnectionHandler* queryConnectionHandler;
KeyRemapper* keyRemapper;
bool useEconomicTranslate;
+ bool savedRepeat;
};
};
--- common/rfb/VNCServerST.cxx.orig 2010-05-27 15:42:20.000000000 +0200
+++ common/rfb/VNCServerST.cxx 2010-05-27 15:42:53.000000000 +0200
@@ -79,6 +79,7 @@
useEconomicTranslate(false)
{
slog.debug("creating single-threaded server %s", name.buf);
+ savedRepeat = true;
}
VNCServerST::~VNCServerST()
--- common/rfb/InputHandler.h.orig 2010-05-27 12:09:44.000000000 +0200
+++ common/rfb/InputHandler.h 2010-05-27 15:40:29.000000000 +0200
@@ -32,9 +32,10 @@
public:
virtual ~InputHandler() {}
virtual void keyEvent(rdr::U32 key, bool down) {}
+ virtual void keyRepeat(bool on) {}
+ virtual bool getKeyRepeat() { return false; }
virtual void pointerEvent(const Point& pos, int buttonMask) {}
virtual void clientCutText(const char* str, int len) {}
};
-
}
#endif
--- common/rfb/VNCSConnectionST.cxx.down 2010-05-27 10:19:25.000000000 +0200
+++ common/rfb/VNCSConnectionST.cxx 2010-05-27 15:43:24.000000000 +0200
@@ -61,6 +61,8 @@
std::set::iterator i;
for (i=pressedKeys.begin(); i!=pressedKeys.end(); i++)
server->desktop->keyEvent(*i, false);
+ if (server->clients.size() == 1)
+ server->desktop->keyRepeat(server->savedRepeat);
if (server->pointerClient == this)
server->pointerClient = 0;
@@ -308,6 +310,9 @@
// - Mark the entire display as "dirty"
updates.add_changed(server->pb->getRect());
+ // If we're the first connection, save the keyboard repeat
+ if (server->clients.size() == 1) server->savedRepeat = server->desktop->getKeyRepeat();
+ server->desktop->keyRepeat(false);
}
void VNCSConnectionST::queryConnection(const char* userName)
--- unix/xc/programs/Xserver/vnc/XserverDesktop.cc.orig 2010-05-27 11:56:16.000000000 +0200
+++ unix/xc/programs/Xserver/vnc/XserverDesktop.cc 2010-05-28 10:20:24.000000000 +0200
@@ -985,6 +985,29 @@
}
+void XserverDesktop::keyRepeat(bool on)
+{
+ DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice();
+ KeybdCtrl ctrl = dev->kbdfeed->ctrl;
+ if (on) {
+ vlog.info("Switching keyboard repeat on");
+ ctrl.autoRepeat = TRUE;
+ } else {
+ vlog.info("Switching keyboard repeat off");
+ ctrl.autoRepeat = FALSE;
+ }
+ dev->kbdfeed->ctrl = ctrl;
+ (*dev->kbdfeed->CtrlProc)(dev, &dev->kbdfeed->ctrl);
+}
+
+bool XserverDesktop::getKeyRepeat()
+{
+ DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice();
+ KeybdCtrl ctrl = dev->kbdfeed->ctrl;
+ vlog.info("Keyboard repeat was: %s", ctrl.autoRepeat ? "on" : "off");
+ return ctrl.autoRepeat;
+}
+
void XConvertCase(KeySym sym, KeySym *lower, KeySym *upper)
{
*lower = sym;
--- unix/xc/programs/Xserver/vnc/XserverDesktop.h.orig 2010-05-27 11:58:16.000000000 +0200
+++ unix/xc/programs/Xserver/vnc/XserverDesktop.h 2010-05-27 14:38:52.000000000 +0200
@@ -87,6 +87,8 @@
// rfb::SDesktop callbacks
virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
virtual void keyEvent(rdr::U32 key, bool down);
+ virtual void keyRepeat(bool on);
+ virtual bool getKeyRepeat();
virtual void clientCutText(const char* str, int len);
virtual rfb::Point getFbSize() { return rfb::Point(width(), height()); }
#include <stdio.h>
/* No int main() { } here */
printf("Hello world\n");