]> thyrsus.com Git - morse-classic.git/commitdiff
Assume we have srand48()/lrand48().
authorEric S. Raymond <esr@thyrsus.com>
Mon, 24 Jan 2005 19:40:35 +0000 (19:40 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 24 Jan 2005 19:40:35 +0000 (19:40 +0000)
HISTORY
Makefile
morse.c
morse.spec

diff --git a/HISTORY b/HISTORY
index de716b1fa2387f8fb6a8dfc25c77f839e8c072c8..4234cca022ac9aaccddc8cbb7be94ba2d1a3aca3 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -38,7 +38,7 @@ Eric S. Raymond <esr@thyrsus.com>, January 2005:
     Changed ERROR_FREQUENCY to runtime -x option.
     Changed ERROR_VOLUME to runtime -X option.
     Dropped BSD signal and tty support, it's all POSIX now.
-    Wrote the manual page.
+    QSO assumes that srand48/lrand48 is available, so morse will too.
     Wrote the manual page.
     Updated all code to use ANSI prototypes.
 
index 288e3a3cb2605e590ffbeac81013f833278b6ac6..5af8cbac526c2427a17bd2e016cffbe5ca07664b 100644 (file)
--- a/Makefile
+++ b/Makefile
 #DEVICE = Linux
 DEVICE = OSS
 
-#
-# For alternate random number generator, add either -DUSELRAND for lrand48(),
-#   or -DUSERAND for (ugh) rand(). Default is -DUSERANDOM for random().
-#DEFINES = -DUSELRAND
-#DEFINES = 
-
 VERS=$(shell sed <morse.spec -n -e '/Version: \(.*\)/s//\1/p')
 
 BEEPERS = beepLinux.c beepOSS.c beepX11.c
-SOURCES = alarm.c  morse.c alarm.h  beep.h  $(BEEPERS)
+SOURCES = alarm.c  morse.c alarm.h beep.h $(BEEPERS)
 MANPAGES = morse.1 QSO.1 
 DOCS = README HISTORY morse.xml morse.spec $(MANPAGES)
 ALL=  $(DOCS) Makefile $(SOURCES) test_input qso/*.[ch] qso/Makefile
 
 # The flags necessary to link with the X11 libraries.
-#X11LIBS = -L/usr/X11/lib -lX11 -lsocket -lnsl
 X11LIBS = -L/usr/X11/lib -lX11
 
 # Any additional flags your favorite C compiler requires to work.
diff --git a/morse.c b/morse.c
index 8c597cd9874cfb48a95d16fb5188980630c51af2..29af690cff24bc82e1164ebe2b4f2d155e8a089b 100644 (file)
--- a/morse.c
+++ b/morse.c
@@ -243,36 +243,6 @@ static int      error_floor = ERROR_FLOOR;
  */
 #undef FLUSHCODE
 
-/*
- * Choose your favorite random number generator!
- */
-#ifndef USERANDOM
-#ifndef USELRAND
-#ifndef USERAND
-#define USERANDOM      /* USELRAND or USERAND are the other choices */
-#endif
-#endif
-#endif
-
-#ifdef USERANDOM
-#define RANDOM()      random()
-#define SEEDRANDOM(s) srandom((int)s)
-#endif
-#ifdef USELRAND
-#define RANDOM()      lrand48()
-#define SEEDRANDOM(s) srand48((long)(s))
-long            lrand48 ();
-#endif
-#ifdef USERAND
-/*
- * UGH, are you really sure you want to use this one?
- * This one really stinks!
- */
-#define RANDOM()      rand()
-#define SEEDRANDOM(s) srand((int)(s))
-int             rand ();
-#endif
-
 static void            new_words_per_minute (void);
 static void            dowords (int c);
 static void            morse (int c);
@@ -713,7 +683,7 @@ extern time_t   time ();
     }
     else if (randomletters)
     {
-       SEEDRANDOM (time (NULL));
+       srand48(time (NULL));
        randexp = 1. / (1. - 1. / (float) (RANDWORDLEN));
        while (1)
        {
@@ -727,7 +697,7 @@ extern time_t   time ();
                /* Shift a few bits because the lower bits stink */
                /* Add in the time so it doesn't repeat from run to run */
                randnum = (float) (
-                                  (((RANDOM () >> 9) + (long) (time (NULL))) >> 4)
+                                  (((lrand48() >> 9) + (long) (time (NULL))) >> 4)
                                   & 0x00FFFFFF);
                randnum = randnum - randexp * (int) (randnum / randexp);
                if ((randnum >= 1.) && (linepos != 0)) dowords ((int) ' ');
@@ -1855,7 +1825,7 @@ static long     norepeat;
  */
     do
     {
-       ranspot = ((RANDOM () >> 4) % sum + norepeat) % sum;
+       ranspot = ((lrand48() >> 4) % sum + norepeat) % sum;
 
        sum2 = 0;
        for (ii = 0; ii < TWOFIFTYSIX - 1; ii++)
index a83db22522bea098bd77ee321ee9258df781dbd8..8ad0a2981f5349d6ffeba9501f5ae8175b270da9 100644 (file)
@@ -8,12 +8,13 @@ URL: http://catb.org/~esr/morse/
 Source0: %{name}-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-root
 
-%description
-morse is a training program for aspiring radio hams.  It can generate
-random tests or simulated QSOs resembling those used in the ARRL test
-(a QSO generator is included).  There are a plethora of options to
-vary the training method.  In one mode, it will take text input from
-standard input and render it as more beeps.
+%description 
+morse is a Morse-code training program for aspiring radio hams.  It
+can generate random tests or simulated QSOs resembling those used in
+the ARRL test (a QSO generator is included).  There are a plethora of
+options to vary the training method.  In one of the simpler modes,
+this program will take text from standard input and render it as
+Morse-code beeps.
 
 %prep
 %setup -q