mg

port of mg editor (openbsd to linux)
Log | Files | Refs | README

commit dc6a8a279d33e9db0910dde33bd04307f78f5484
parent 08414f5af620d148e548716012115e999829a690
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Mon, 24 Nov 2014 22:35:03 +0100

by popular request enable theo quotes

Diffstat:
Makefile | 2+-
libopenbsd/arc4random.c | 12++++++++++++
libopenbsd/util.h | 2++
main.c | 4++--
theo.c | 8+++++---
5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile @@ -24,7 +24,7 @@ SRCS= autoexec.c basic.c bell.c buffer.c cinfo.c dir.c display.c \ # # More or less standalone extensions. # -SRCS+= cmode.c cscope.c dired.c grep.c tags.c # theo.c +SRCS+= cmode.c cscope.c dired.c grep.c tags.c theo.c CFLAGS += -DDEFFILEMODE=0666 -D__dead="" -I. -Iinclude -Ilibutil CFLAGS += -Os diff --git a/libopenbsd/arc4random.c b/libopenbsd/arc4random.c @@ -0,0 +1,12 @@ +#include <sys/types.h> +#include <stdint.h> +#include <stdlib.h> +#include <time.h> +#include <unistd.h> + +uint32_t +arc4random(void) +{ + srand(time(NULL) ^ getpid() ^ 0x42); + return rand(); +} diff --git a/libopenbsd/util.h b/libopenbsd/util.h @@ -8,3 +8,4 @@ void * reallocarray(void *, size_t, size_t); size_t strlcat(char *, const char *, size_t); size_t strlcpy(char *, const char *, size_t); long long strtonum(const char *, long long, long long, const char **); +uint32_t arc4random(void);+ \ No newline at end of file diff --git a/main.c b/main.c @@ -78,13 +78,13 @@ main(int argc, char **argv) */ { extern void grep_init(void); -/* extern void theo_init(void);*/ + extern void theo_init(void); extern void cmode_init(void); extern void dired_init(void); dired_init(); grep_init(); -/* theo_init();*/ + theo_init(); cmode_init(); } diff --git a/theo.c b/theo.c @@ -195,10 +195,12 @@ static const int ntalk = sizeof(talk)/sizeof(talk[0]); static int theo_analyze(int f, int n) { - const char *str; - int len; + const char *str; + int len; + int i; - str = talk[arc4random_uniform(ntalk)]; + i = arc4random() % ntalk; + str = talk[i]; len = strlen(str); newline(FFRAND, 2);