static unsigned long my_random(unsigned long base)
{
- FILE *fp;
unsigned long long l = 0;
- char *hard_coded_val;
-
- hard_coded_val = getenv("FORTUNE_MOD_RAND_HARD_CODED_VALS");
+ char *hard_coded_val = getenv("FORTUNE_MOD_RAND_HARD_CODED_VALS");
if (hard_coded_val)
{
return ((unsigned long)atol(hard_coded_val) % base);
{
goto fallback;
}
- fp = fopen("/dev/urandom", "rb");
+ FILE *const fp = fopen("/dev/urandom", "rb");
if (!fp)
{
goto fallback;
*/
static void calc_equal_probs(void)
{
- FILEDESC *fiddlylist;
-
Num_files = Num_kids = 0;
- fiddlylist = File_list;
+ FILEDESC *fiddlylist = File_list;
while (fiddlylist != NULL)
{
Num_files++;
{ /* don't display an error when trying language specific files */
if (env_lang)
{
- char *lang;
char llang[512];
char langdir[1024];
int ret = 0;
- char *p;
strncpy(llang, env_lang, sizeof(llang));
llang[sizeof(llang) - 1] = '\0';
- lang = llang;
+ char *lang = llang;
/* the language string can be like "es:fr_BE:ga" */
while (!ret && lang && (*lang))
{
- p = strchr(lang, ':');
+ char *p = strchr(lang, ':');
if (p)
*p++ = '\0';
snprintf(langdir, sizeof(langdir), "%s/%s", FORTDIR, lang);
* add_dir:
* Add the contents of an entire directory.
*/
-int add_dir(register FILEDESC *fp)
+int add_dir(FILEDESC *fp)
{
- register DIR *dir;
- register struct dirent *dirent;
- auto FILEDESC *tailp;
- auto char *name;
+ DIR *dir;
+ struct dirent *dirent;
char **names;
size_t i, count_names, max_count_names;
perror(fp->path);
return FALSE;
}
- tailp = NULL;
+ FILEDESC *tailp = NULL;
DPRINTF(1, (stderr, "adding dir \"%s\"\n", fp->path));
fp->num_children = 0;
max_count_names = 200;
{
if (dirent->d_name[0] == 0)
continue;
- name = strdup(dirent->d_name);
+ char *name = strdup(dirent->d_name);
if (count_names == max_count_names)
{
max_count_names += 200;
return (top_level__add_file(LOCFORTDIR) | cond_top_level__LOCFORTDIR());
}
-static int form_file_list(register char **files, register int file_cnt)
+static int form_file_list(char **files, int file_cnt)
{
- register int i, percent;
- register char *sp;
+ int i, percent;
+ char *sp;
char langdir[1024];
char fullpathname[512], locpathname[512];
if (env_lang)
{
- char *lang;
char llang[512];
int ret = 0;
- char *p;
strncpy(llang, env_lang, sizeof(llang));
llang[sizeof(llang) - 1] = '\0';
- lang = llang;
+ char *lang = llang;
/* the language string can be like "es:fr_BE:ga" */
while (!ret && lang && (*lang))
{
- p = strchr(lang, ':');
+ char *p = strchr(lang, ':');
if (p)
*p++ = '\0';
*/
static void getargs(int argc, char **argv)
{
- register int ignore_case;
+ int ignore_case = FALSE;
#ifndef NO_REGEX
- register char *pat = NULL;
+ char *pat = NULL;
#endif /* NO_REGEX */
int ch;
- ignore_case = FALSE;
-
#ifdef DEBUG
#define DEBUG_GETOPT "D"
#else
*/
static void init_prob(void)
{
- register FILEDESC *fp, *last;
- register int percent, num_noprob, frac;
+ FILEDESC *fp;
+ int percent = 0, num_noprob = 0, frac;
/*
* Distribute the residual probability (if any) across all
* files with unspecified probability (i.e., probability of 0)
* (if any).
*/
-
- percent = 0;
- num_noprob = 0;
- last = NULL;
+ FILEDESC *last = NULL;
for (fp = File_tail; fp != NULL; fp = fp->prev)
if (fp->percent == NO_PROB)
{
* zero_tbl:
* Zero out the fields we care about in a tbl structure.
*/
-static void zero_tbl(register STRFILE *tp)
+static void zero_tbl(STRFILE *tp)
{
tp->str_numstr = 0;
tp->str_longlen = 0;
*/
static void get_tbl(FILEDESC *fp)
{
- auto int fd;
- register FILEDESC *child;
+ int fd;
+ FILEDESC *child;
if (fp->read_tbl)
return;
* sum_noprobs:
* Sum up all the noprob probabilities, starting with fp.
*/
-static void sum_noprobs(register FILEDESC *fp)
+static void sum_noprobs(FILEDESC *fp)
{
static bool did_noprobs = FALSE;
*/
static FILEDESC *pick_child(FILEDESC *parent)
{
- register FILEDESC *fp;
- register int choice;
+ FILEDESC *fp;
+ int choice;
if (Equal_probs)
{
*/
static void get_fort(void)
{
- register FILEDESC *fp;
- register int choice;
+ FILEDESC *fp;
+ int choice;
if (File_list->next == NULL || File_list->percent == NO_PROB)
fp = File_list;
*/
static int maxlen_in_list(FILEDESC *list)
{
- register FILEDESC *fp;
- register int len, maxlen;
+ FILEDESC *fp;
+ int len, maxlen = 0;
- maxlen = 0;
for (fp = list; fp != NULL; fp = fp->next)
{
if (fp->child != NULL)
unsigned char *sp;
unsigned char *p; /* -allover */
unsigned char ch; /* -allover */
- register FILEDESC *fp;
+ FILEDESC *fp;
int in_file, nchar;
char *output;
static void display(FILEDESC *fp)
{
- register char *p, ch;
+ char *p, ch;
unsigned char line[BUFSIZ];
open_fp(fp);
*/
static int fortlen(void)
{
- register int nchar;
+ int nchar;
char line[BUFSIZ];
if (!(Fortfile->tbl.str_flags & (STR_RANDOM | STR_ORDERED)))
return nchar;
}
-static int mymax(register int i, register int j) { return (i >= j ? i : j); }
+static int mymax(int i, int j) { return (i >= j ? i : j); }
static void free_desc(FILEDESC *ptr)
{
free_desc(File_list);
free(Fortbuf);
exit(exit_code);
- /* NOTREACHED */
}