about summary refs log tree commit diff
path: root/src/libcore/rand.rs
blob: 4cb5e58b73331855e22e44002f2db3b03429ba01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Random number generation

use int;
use prelude::*;
use str;
use task;
use u32;
use uint;
use util;
use vec;
use libc::size_t;

/// A type that can be randomly generated using an RNG
pub trait Rand {
    static fn rand(rng: @rand::Rng) -> Self;
}

impl Rand for int {
    static fn rand(rng: @rand::Rng) -> int {
        rng.gen_int()
    }
}

impl Rand for i8 {
    static fn rand(rng: @rand::Rng) -> i8 {
        rng.gen_i8()
    }
}

impl Rand for i16 {
    static fn rand(rng: @rand::Rng) -> i16 {
        rng.gen_i16()
    }
}

impl Rand for i32 {
    static fn rand(rng: @rand::Rng) -> i32 {
        rng.gen_i32()
    }
}

impl Rand for i64 {
    static fn rand(rng: @rand::Rng) -> i64 {
        rng.gen_i64()
    }
}

impl Rand for u8 {
    static fn rand(rng: @rand::Rng) -> u8 {
        rng.gen_u8()
    }
}

impl Rand for u16 {
    static fn rand(rng: @rand::Rng) -> u16 {
        rng.gen_u16()
    }
}

impl Rand for u32 {
    static fn rand(rng: @rand::Rng) -> u32 {
        rng.gen_u32()
    }
}

impl Rand for u64 {
    static fn rand(rng: @rand::Rng) -> u64 {
        rng.gen_u64()
    }
}

impl Rand for float {
    static fn rand(rng: @rand::Rng) -> float {
        rng.gen_float()
    }
}

impl Rand for f32 {
    static fn rand(rng: @rand::Rng) -> f32 {
        rng.gen_f32()
    }
}

impl Rand for f64 {
    static fn rand(rng: @rand::Rng) -> f64 {
        rng.gen_f64()
    }
}

impl Rand for char {
    static fn rand(rng: @rand::Rng) -> char {
        rng.gen_char()
    }
}

impl Rand for bool {
    static fn rand(rng: @rand::Rng) -> bool {
        rng.gen_bool()
    }
}

impl<T:Rand> Rand for Option<T> {
    static fn rand(rng: @rand::Rng) -> Option<T> {
        if rng.gen_bool() {
            Some(Rand::rand(rng))
        } else {
            None
        }
    }
}

#[allow(non_camel_case_types)] // runtime type
pub enum rust_rng {}

#[abi = "cdecl"]
pub mod rustrt {
    use libc::size_t;
    use rand::rust_rng;

    pub extern {
        unsafe fn rand_seed_size() -> size_t;
        unsafe fn rand_gen_seed(buf: *mut u8, sz: size_t);
        unsafe fn rand_new_seeded(buf: *u8, sz: size_t) -> *rust_rng;
        unsafe fn rand_next(rng: *rust_rng) -> u32;
        unsafe fn rand_free(rng: *rust_rng);
    }
}

/// A random number generator
pub trait Rng {
    /// Return the next random integer
    fn next(&self) -> u32;
}

/// A value with a particular weight compared to other values
pub struct Weighted<T> {
    weight: uint,
    item: T,
}

pub trait RngUtil {
    fn gen<T:Rand>(&self) -> T;
    /// Return a random int
    fn gen_int(&self) -> int;
    fn gen_int_range(&self, start: int, end: int) -> int;
    /// Return a random i8
    fn gen_i8(&self) -> i8;
    /// Return a random i16
    fn gen_i16(&self) -> i16;
    /// Return a random i32
    fn gen_i32(&self) -> i32;
    /// Return a random i64
    fn gen_i64(&self) -> i64;
    /// Return a random uint
    fn gen_uint(&self) -> uint;
    /**
     * Return a uint randomly chosen from the range [start, end),
     * failing if start >= end
     */
    fn gen_uint_range(&self, start: uint, end: uint) -> uint;
    /// Return a random u8
    fn gen_u8(&self) -> u8;
    /// Return a random u16
    fn gen_u16(&self) -> u16;
    /// Return a random u32
    fn gen_u32(&self) -> u32;
    /// Return a random u64
    fn gen_u64(&self) -> u64;
    /// Return a random float in the interval [0,1]
    fn gen_float(&self) -> float;
    /// Return a random f32 in the interval [0,1]
    fn gen_f32(&self) -> f32;
    /// Return a random f64 in the interval [0,1]
    fn gen_f64(&self) -> f64;
    /// Return a random char
    fn gen_char(&self) -> char;
    /**
     * Return a char randomly chosen from chars, failing if chars is empty
     */
    fn gen_char_from(&self, chars: &str) -> char;
    /// Return a random bool
    fn gen_bool(&self) -> bool;
    /// Return a bool with a 1 in n chance of true
    fn gen_weighted_bool(&self, n: uint) -> bool;
    /**
     * Return a random string of the specified length composed of A-Z,a-z,0-9
     */
    fn gen_str(&self, len: uint) -> ~str;
    /// Return a random byte string of the specified length
    fn gen_bytes(&self, len: uint) -> ~[u8];
    /// Choose an item randomly, failing if values is empty
    fn choose<T:Copy>(&self, values: &[T]) -> T;
    /// Choose Some(item) randomly, returning None if values is empty
    fn choose_option<T:Copy>(&self, values: &[T]) -> Option<T>;
    /**
     * Choose an item respecting the relative weights, failing if the sum of
     * the weights is 0
     */
    fn choose_weighted<T:Copy>(&self, v : &[Weighted<T>]) -> T;
    /**
     * Choose Some(item) respecting the relative weights, returning none if
     * the sum of the weights is 0
     */
    fn choose_weighted_option<T:Copy>(&self, v: &[Weighted<T>]) -> Option<T>;
    /**
     * Return a vec containing copies of the items, in order, where
     * the weight of the item determines how many copies there are
     */
    fn weighted_vec<T:Copy>(&self, v: &[Weighted<T>]) -> ~[T];
    /// Shuffle a vec
    fn shuffle<T:Copy>(&self, values: &[T]) -> ~[T];
    /// Shuffle a mutable vec in place
    fn shuffle_mut<T>(&self, values: &mut [T]);
}

/// Extension methods for random number generators
impl RngUtil for @Rng {
    /// Return a random value for a Rand type
    fn gen<T:Rand>(&self) -> T {
        Rand::rand(*self)
    }

    /// Return a random int
    fn gen_int(&self) -> int {
        self.gen_i64() as int
    }

    /**
     * Return an int randomly chosen from the range [start, end),
     * failing if start >= end
     */
    fn gen_int_range(&self, start: int, end: int) -> int {
        fail_unless!(start < end);
        start + int::abs(self.gen_int() % (end - start))
    }

    /// Return a random i8
    fn gen_i8(&self) -> i8 {
        self.next() as i8
    }

    /// Return a random i16
    fn gen_i16(&self) -> i16 {
        self.next() as i16
    }

    /// Return a random i32
    fn gen_i32(&self) -> i32 {
        self.next() as i32
    }

    /// Return a random i64
    fn gen_i64(&self) -> i64 {
        (self.next() as i64 << 32) | self.next() as i64
    }

    /// Return a random uint
    fn gen_uint(&self) -> uint {
        self.gen_u64() as uint
    }

    /**
     * Return a uint randomly chosen from the range [start, end),
     * failing if start >= end
     */
    fn gen_uint_range(&self, start: uint, end: uint) -> uint {
        fail_unless!(start < end);
        start + (self.gen_uint() % (end - start))
    }

    /// Return a random u8
    fn gen_u8(&self) -> u8 {
        self.next() as u8
    }

    /// Return a random u16
    fn gen_u16(&self) -> u16 {
        self.next() as u16
    }

    /// Return a random u32
    fn gen_u32(&self) -> u32 {
        self.next()
    }

    /// Return a random u64
    fn gen_u64(&self) -> u64 {
        (self.next() as u64 << 32) | self.next() as u64
    }

    /// Return a random float in the interval [0,1]
    fn gen_float(&self) -> float {
        self.gen_f64() as float
    }

    /// Return a random f32 in the interval [0,1]
    fn gen_f32(&self) -> f32 {
        self.gen_f64() as f32
    }

    /// Return a random f64 in the interval [0,1]
    fn gen_f64(&self) -> f64 {
        let u1 = self.next() as f64;
        let u2 = self.next() as f64;
        let u3 = self.next() as f64;
        const scale : f64 = (u32::max_value as f64) + 1.0f64;
        return ((u1 / scale + u2) / scale + u3) / scale;
    }

    /// Return a random char
    fn gen_char(&self) -> char {
        self.next() as char
    }

    /**
     * Return a char randomly chosen from chars, failing if chars is empty
     */
    fn gen_char_from(&self, chars: &str) -> char {
        fail_unless!(!chars.is_empty());
        self.choose(str::chars(chars))
    }

    /// Return a random bool
    fn gen_bool(&self) -> bool {
        self.next() & 1u32 == 1u32
    }

    /// Return a bool with a 1 in n chance of true
    fn gen_weighted_bool(&self, n: uint) -> bool {
        if n == 0u {
            true
        } else {
            self.gen_uint_range(1u, n + 1u) == 1u
        }
    }

    /**
     * Return a random string of the specified length composed of A-Z,a-z,0-9
     */
    fn gen_str(&self, len: uint) -> ~str {
        let charset = ~"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
                       abcdefghijklmnopqrstuvwxyz\
                       0123456789";
        let mut s = ~"";
        let mut i = 0u;
        while (i < len) {
            s = s + str::from_char(self.gen_char_from(charset));
            i += 1u;
        }
        s
    }

    /// Return a random byte string of the specified length
    fn gen_bytes(&self, len: uint) -> ~[u8] {
        do vec::from_fn(len) |_i| {
            self.gen_u8()
        }
    }

    /// Choose an item randomly, failing if values is empty
    fn choose<T:Copy>(&self, values: &[T]) -> T {
        self.choose_option(values).get()
    }

    /// Choose Some(item) randomly, returning None if values is empty
    fn choose_option<T:Copy>(&self, values: &[T]) -> Option<T> {
        if values.is_empty() {
            None
        } else {
            Some(values[self.gen_uint_range(0u, values.len())])
        }
    }

    /**
     * Choose an item respecting the relative weights, failing if the sum of
     * the weights is 0
     */
    fn choose_weighted<T:Copy>(&self, v : &[Weighted<T>]) -> T {
        self.choose_weighted_option(v).get()
    }

    /**
     * Choose Some(item) respecting the relative weights, returning none if
     * the sum of the weights is 0
     */
    fn choose_weighted_option<T:Copy>(&self, v: &[Weighted<T>]) -> Option<T> {
        let mut total = 0u;
        for v.each |item| {
            total += item.weight;
        }
        if total == 0u {
            return None;
        }
        let chosen = self.gen_uint_range(0u, total);
        let mut so_far = 0u;
        for v.each |item| {
            so_far += item.weight;
            if so_far > chosen {
                return Some(item.item);
            }
        }
        util::unreachable();
    }

    /**
     * Return a vec containing copies of the items, in order, where
     * the weight of the item determines how many copies there are
     */
    fn weighted_vec<T:Copy>(&self, v: &[Weighted<T>]) -> ~[T] {
        let mut r = ~[];
        for v.each |item| {
            for uint::range(0u, item.weight) |_i| {
                r.push(item.item);
            }
        }
        r
    }

    /// Shuffle a vec
    fn shuffle<T:Copy>(&self, values: &[T]) -> ~[T] {
        let mut m = vec::from_slice(values);
        self.shuffle_mut(m);
        m
    }

    /// Shuffle a mutable vec in place
    fn shuffle_mut<T>(&self, values: &mut [T]) {
        let mut i = values.len();
        while i >= 2u {
            // invariant: elements with index >= i have been locked in place.
            i -= 1u;
            // lock element i in place.
            vec::swap(values, i, self.gen_uint_range(0u, i + 1u));
        }
    }

}

struct RandRes {
    rng: *rust_rng,
}

impl Drop for RandRes {
    fn finalize(&self) {
        unsafe {
            rustrt::rand_free(self.rng);
        }
    }
}

fn RandRes(rng: *rust_rng) -> RandRes {
    RandRes {
        rng: rng
    }
}

impl Rng for @RandRes {
    fn next(&self) -> u32 {
        unsafe {
            return rustrt::rand_next((*self).rng);
        }
    }
}

/// Create a new random seed for seeded_rng
pub fn seed() -> ~[u8] {
    unsafe {
        let n = rustrt::rand_seed_size() as uint;
        let mut s = vec::from_elem(n, 0_u8);
        do vec::as_mut_buf(s) |p, sz| {
            rustrt::rand_gen_seed(p, sz as size_t)
        }
        s
    }
}

/// Create a random number generator with a system specified seed
pub fn Rng() -> @Rng {
    seeded_rng(seed())
}

/**
 * Create a random number generator using the specified seed. A generator
 * constructed with a given seed will generate the same sequence of values as
 * all other generators constructed with the same seed. The seed may be any
 * length.
 */
pub fn seeded_rng(seed: &[u8]) -> @Rng {
    @seeded_randres(seed) as @Rng
}

fn seeded_randres(seed: &[u8]) -> @RandRes {
    unsafe {
        do vec::as_imm_buf(seed) |p, sz| {
            @RandRes(rustrt::rand_new_seeded(p, sz as size_t))
        }
    }
}

struct XorShiftState {
    mut x: u32,
    mut y: u32,
    mut z: u32,
    mut w: u32,
}

impl Rng for XorShiftState {
    fn next(&self) -> u32 {
        let x = self.x;
        let mut t = x ^ (x << 11);
        self.x = self.y;
        self.y = self.z;
        self.z = self.w;
        let w = self.w;
        self.w = w ^ (w >> 19) ^ (t ^ (t >> 8));
        self.w
    }
}

pub pure fn xorshift() -> @Rng {
    // constants taken from http://en.wikipedia.org/wiki/Xorshift
    seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32)
}

pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> @Rng {
    @XorShiftState { x: x, y: y, z: z, w: w } as @Rng
}


// used to make space in TLS for a random number generator
fn tls_rng_state(_v: @RandRes) {}

/**
 * Gives back a lazily initialized task-local random number generator,
 * seeded by the system. Intended to be used in method chaining style, ie
 * task_rng().gen_int().
 */
pub fn task_rng() -> @Rng {
    let r : Option<@RandRes>;
    unsafe {
        r = task::local_data::local_data_get(tls_rng_state);
    }
    match r {
        None => {
            unsafe {
                let rng = seeded_randres(seed());
                task::local_data::local_data_set(tls_rng_state, rng);
                @rng as @Rng
            }
        }
        Some(rng) => @rng as @Rng
    }
}

/**
 * Returns a random uint, using the task's based random number generator.
 */
pub fn random() -> uint {
    task_rng().gen_uint()
}


#[cfg(test)]
pub mod tests {
    use option::{None, Option, Some};
    use rand;

    #[test]
    pub fn rng_seeded() {
        let seed = rand::seed();
        let ra = rand::seeded_rng(seed);
        let rb = rand::seeded_rng(seed);
        fail_unless!(ra.gen_str(100u) == rb.gen_str(100u));
    }

    #[test]
    pub fn rng_seeded_custom_seed() {
        // much shorter than generated seeds which are 1024 bytes
        let seed = [2u8, 32u8, 4u8, 32u8, 51u8];
        let ra = rand::seeded_rng(seed);
        let rb = rand::seeded_rng(seed);
        fail_unless!(ra.gen_str(100u) == rb.gen_str(100u));
    }

    #[test]
    pub fn rng_seeded_custom_seed2() {
        let seed = [2u8, 32u8, 4u8, 32u8, 51u8];
        let ra = rand::seeded_rng(seed);
        // Regression test that isaac is actually using the above vector
        let r = ra.next();
        error!("%?", r);
        fail_unless!(r == 890007737u32 // on x86_64
                     || r == 2935188040u32); // on x86
    }

    #[test]
    pub fn gen_int_range() {
        let r = rand::Rng();
        let a = r.gen_int_range(-3, 42);
        fail_unless!(a >= -3 && a < 42);
        fail_unless!(r.gen_int_range(0, 1) == 0);
        fail_unless!(r.gen_int_range(-12, -11) == -12);
    }

    #[test]
    #[should_fail]
    #[ignore(cfg(windows))]
    pub fn gen_int_from_fail() {
        rand::Rng().gen_int_range(5, -2);
    }

    #[test]
    pub fn gen_uint_range() {
        let r = rand::Rng();
        let a = r.gen_uint_range(3u, 42u);
        fail_unless!(a >= 3u && a < 42u);
        fail_unless!(r.gen_uint_range(0u, 1u) == 0u);
        fail_unless!(r.gen_uint_range(12u, 13u) == 12u);
    }

    #[test]
    #[should_fail]
    #[ignore(cfg(windows))]
    pub fn gen_uint_range_fail() {
        rand::Rng().gen_uint_range(5u, 2u);
    }

    #[test]
    pub fn gen_float() {
        let r = rand::Rng();
        let a = r.gen_float();
        let b = r.gen_float();
        debug!((a, b));
    }

    #[test]
    pub fn gen_weighted_bool() {
        let r = rand::Rng();
        fail_unless!(r.gen_weighted_bool(0u) == true);
        fail_unless!(r.gen_weighted_bool(1u) == true);
    }

    #[test]
    pub fn gen_str() {
        let r = rand::Rng();
        debug!(r.gen_str(10u));
        debug!(r.gen_str(10u));
        debug!(r.gen_str(10u));
        fail_unless!(r.gen_str(0u).len() == 0u);
        fail_unless!(r.gen_str(10u).len() == 10u);
        fail_unless!(r.gen_str(16u).len() == 16u);
    }

    #[test]
    pub fn gen_bytes() {
        let r = rand::Rng();
        fail_unless!(r.gen_bytes(0u).len() == 0u);
        fail_unless!(r.gen_bytes(10u).len() == 10u);
        fail_unless!(r.gen_bytes(16u).len() == 16u);
    }

    #[test]
    pub fn choose() {
        let r = rand::Rng();
        fail_unless!(r.choose([1, 1, 1]) == 1);
    }

    #[test]
    pub fn choose_option() {
        let r = rand::Rng();
        let x: Option<int> = r.choose_option([]);
        fail_unless!(x.is_none());
        fail_unless!(r.choose_option([1, 1, 1]) == Some(1));
    }

    #[test]
    pub fn choose_weighted() {
        let r = rand::Rng();
        fail_unless!(r.choose_weighted(~[
            rand::Weighted { weight: 1u, item: 42 },
        ]) == 42);
        fail_unless!(r.choose_weighted(~[
            rand::Weighted { weight: 0u, item: 42 },
            rand::Weighted { weight: 1u, item: 43 },
        ]) == 43);
    }

    #[test]
    pub fn choose_weighted_option() {
        let r = rand::Rng();
        fail_unless!(r.choose_weighted_option(~[
            rand::Weighted { weight: 1u, item: 42 },
        ]) == Some(42));
        fail_unless!(r.choose_weighted_option(~[
            rand::Weighted { weight: 0u, item: 42 },
            rand::Weighted { weight: 1u, item: 43 },
        ]) == Some(43));
        let v: Option<int> = r.choose_weighted_option([]);
        fail_unless!(v.is_none());
    }

    #[test]
    pub fn weighted_vec() {
        let r = rand::Rng();
        let empty: ~[int] = ~[];
        fail_unless!(r.weighted_vec(~[]) == empty);
        fail_unless!(r.weighted_vec(~[
            rand::Weighted { weight: 0u, item: 3u },
            rand::Weighted { weight: 1u, item: 2u },
            rand::Weighted { weight: 2u, item: 1u },
        ]) == ~[2u, 1u, 1u]);
    }

    #[test]
    pub fn shuffle() {
        let r = rand::Rng();
        let empty: ~[int] = ~[];
        fail_unless!(r.shuffle(~[]) == empty);
        fail_unless!(r.shuffle(~[1, 1, 1]) == ~[1, 1, 1]);
    }

    #[test]
    pub fn task_rng() {
        let r = rand::task_rng();
        r.gen_int();
        fail_unless!(r.shuffle(~[1, 1, 1]) == ~[1, 1, 1]);
        fail_unless!(r.gen_uint_range(0u, 1u) == 0u);
    }

    #[test]
    pub fn random() {
        // not sure how to test this aside from just getting a number
        let _n : uint = rand::random();
    }
}


// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End: