On Tue, Mar 16, 2010 at 10:54:32AM +0100, Joachim Breitner wrote:
> it’s hard to judge if this is the case. The randomization code looks
> good to me, but I might be wrong. It will have a slight preference for
> characters in the smaller Font, and for characters appearing in both
> fonts (FreeSans and DejaVu Sans).
> 
> Do you have both of these fonts installed?

I do.

> Besides that, I’d be glad if someone else looks over the code, maybe I’m
> missing something. It can be found at
> http://git.nomeata.de/?p=unicode-screensaver.git;a=blob;f=unicode.c;hb=HEAD

My screen is set to blank after a short amount of time after the
screensaver comes on, so I usually only see a few characters per run.

I took the version in the archive (0.2) and looked at utils/yarandom.c.
Apparently, the algorithm implemented is not the algorithm it claims.  I
looked at my copy of Knuth and there are some differences.  Whether
these affect the generator's effectiveness for this matter, I don't
know.

I patched the screensaver to dump some data for each character it
displays and then ran it thrice for 11 characters per run.  Those are
attached as dump1, dump2, and dump3.  The patch that I used to generate
this is also attached.  Note that where the same characters appear, the
same numbers are generated (look, for example, at the sequence starting
with U+A710 and continuing through U+1503).

My guess, just from looking at the code, is that perhaps the seeding
process is not effective.  It seems like it modifies the upper bits a
great deal, but has little to no effect on the lower bits.  I'll take a
look in more detail shortly.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
2 4e46f0a2 0 8d333813 0000145c 000607 000eb0
2 95d87bd2 0 8dfe1d12 0000145c 000a42 001f93
2 01ba4926 0 109922f1 0000145c 001241 00a710
2 1cdba6c3 1 70d295ae 00000c00 0009ae 002128
2 d469965e 0 d70d397a 0000145c 000b02 00205e
2 6d80071d 1 7e048751 00000c00 000751 001e50
2 c8583abb 1 d792c813 00000c00 000013 000033
2 a7a31772 0 8d8bfa95 0000145c 000779 001503
2 0e42d8d1 1 2fd9f9f8 00000c00 0009f8 002192
2 0fab837c 0 0fdea953 0000145c 000303 00035a
2 b6957ebc 0 a3262606 0000145c 00010e 00014f
2 5282d609 1 5f036c17 00000c00 000817 001f24
2 44b80903 1 03ee5321 00000c00 000321 000396
2 0cd93f85 1 758727a3 00000c00 0003a3 00043f
2 fb0ecf95 1 56e22bc6 00000c00 0007c6 001ec9
2 7f3be75a 0 15efc306 0000145c 0012d6 00fb73
2 7f4d2c8f 1 254a0ae0 00000c00 000ae0 002535
2 4ca54ad8 0 c99566b0 0000145c 000834 001d04
2 8ac15d6f 1 9fce57ec 00000c00 000bec 010909
2 efc01b0b 1 8696e116 00000c00 000516 000740
2 6ad7b20b 1 a06e586f 00000c00 00046f 000550
2 6d0a1af2 0 65b0571d 0000145c 00042d 00049c
2 b8759ae9 1 0adb1f88 00000c00 000b88 00fb47
2 edc0b0ac 0 c83ee7e1 0000145c 001139 002a8b
2 41a12e5d 1 ae5e4660 00000c00 000260 0002c3
2 64d7f0a2 0 da033813 0000145c 000c67 00222d
2 aed87bd2 0 ddfe1d12 0000145c 000516 0005bb
2 01ba4926 0 109922f1 0000145c 001241 00a710
2 1cdba6c3 1 70d295ae 00000c00 0009ae 002128
2 d469965e 0 d70d397a 0000145c 000b02 00205e
2 6d80071d 1 7e048751 00000c00 000751 001e50
2 c8583abb 1 d792c813 00000c00 000013 000033
2 a7a31772 0 8d8bfa95 0000145c 000779 001503
Only in unicode-screensaver-0.2/debian: patches
Only in unicode-screensaver-0.2: .pc
diff -ur unicode-screensaver.old/unicode.c unicode-screensaver-0.2/unicode.c
--- unicode-screensaver.old/unicode.c   2010-03-23 21:18:56.000000000 +0000
+++ unicode-screensaver-0.2/unicode.c   2010-03-23 23:04:42.000000000 +0000
@@ -11,6 +11,7 @@
  *
  */
 
+#include <stdio.h>
 #include <X11/Xft/Xft.h>
 
 #include "unicode-names.h"
@@ -125,12 +126,15 @@
        struct unicode_state *state = (struct unicode_state *)void_state;
 
        if (state->blank) {
+               unsigned int rand1, rand2;
                XWindowAttributes xgwa;
                XGetWindowAttributes (dpy, win, &xgwa);
 
-               font = random() % NUM_FONTS;
+               rand1 = random();
+               font = rand1 % NUM_FONTS;
 
-               pickn = random() % state->font_count[font];     
+               rand2 = random();
+               pickn = rand2 % state->font_count[font];        
 
                pickc = 0;
                for (ucs4 = FcCharSetFirstPage (state->fonts[font]->charset, 
map, &next);
@@ -145,7 +149,8 @@
                                    if (pickc++ == pickn) 
                                        pick = ucs4 + i * 32 + j;
                }
-               
+               fprintf(stderr, "%d %08x %d %08x %08x %06x %06x\n", NUM_FONTS, 
rand1,
+                               font, rand2, state->font_count[font], pickn, 
pick);
 
                sprintf(name,"U+%04X: ",pick);
                strcat(name, get_unicode_data_name(pick));

Attachment: signature.asc
Description: Digital signature

Reply via email to