wietse@wzv.win.tue.nl (Wietse Z. Venema) (07/05/89)
Considering the interest for nn on '286 machines I am posting a series
of prelimirary patches to get nn running under 16-bit UNIX (Microport
System-V/AT v2.3). This is the result of two evenings with jove+lint.
Having no more time to work on nn, I hope it will serve as a starting
point for others. The more people work on this, the sooner we will
have an official release that fully supports brain-damaged hardware.
Of course, this article was posted from within nn.
In the patches I use a macro INT(x) in order to validate some long ->
int conversions (these being the most common source of problems). You
may want to define it (e.g. in config.h) as:
#define INT(x) (int)(x)
Make sure you keep an unaltered version of the nn source so that future
official patches from the original author can still be applied.
*** ./articles.c- Thu Jun 29 20:55:46 1989
--- ./articles.c Tue Jul 4 19:49:56 1989
***************
*** 99,105 ****
if (current_str_t->next_thunk == NULL)
new_thunk(current_str_t,
malloc(STR_THUNK_SIZE),
! STR_THUNK_SIZE,
"string bytes");
current_str_t = current_str_t->next_thunk;
--- 99,105 ----
if (current_str_t->next_thunk == NULL)
new_thunk(current_str_t,
malloc(STR_THUNK_SIZE),
! (long) STR_THUNK_SIZE,
"string bytes");
current_str_t = current_str_t->next_thunk;
***************
*** 322,328 ****
if (n_articles <= 1) return;
! qsort(articles, n_articles, sizeof(article_header *), article_comp);
for (n = n_articles - 1, app = articles + 1; --n >= 0; app++)
if (article_equal(app, app - 1)) (**app).flag |= A_SAME;
--- 322,328 ----
if (n_articles <= 1) return;
! qsort(articles, INT(n_articles), sizeof(article_header *), article_comp);
for (n = n_articles - 1, app = articles + 1; --n >= 0; app++)
if (article_equal(app, app - 1)) (**app).flag |= A_SAME;
***************
*** 357,363 ****
articles[i]->flag &= ~A_SAME;
if (n_articles <= 1) return;
! qsort(articles, n_articles, sizeof(article_header *),
arrival ? offset_cmp : age_cmp);
}
--- 357,363 ----
articles[i]->flag &= ~A_SAME;
if (n_articles <= 1) return;
! qsort(articles, INT(n_articles), sizeof(article_header *),
arrival ? offset_cmp : age_cmp);
}
*** ./data.h- Mon Jul 3 20:52:28 1989
--- ./data.h Tue Jul 4 20:20:06 1989
***************
*** 36,43 ****
int32 group_flag;
! # define MF(n) (1<<(n-1))
! # define CF(n) (1<<(n+15))
# define G_MASTER_FLAGS (MF(17)-1) /* flags that are saved on file */
--- 36,43 ----
int32 group_flag;
! # define MF(n) (((int32)1)<<(n-1))
! # define CF(n) (((int32)1)<<(n+15))
# define G_MASTER_FLAGS (MF(17)-1) /* flags that are saved on file */
***************
*** 122,128 ****
int32 flag; /* flags: */
! # define AF(n) (1<<(n-1))
# define A_SELECT AF(1) /* article has been selected */
# define A_SAME AF(2) /* same subject as prev. article */
--- 122,128 ----
int32 flag; /* flags: */
! # define AF(n) (((int32) 1)<<(n-1))
# define A_SELECT AF(1) /* article has been selected */
# define A_SAME AF(2) /* same subject as prev. article */
*** ./answer.c- Mon Jul 3 20:52:25 1989
--- ./answer.c Tue Jul 4 19:49:49 1989
***************
*** 26,31 ****
--- 26,34 ----
char *pgm, *first_action, *record_file;
int edit_message;
char *str;
+ #if defined(iAPX286) && defined(lint)
+ static
+ #endif
news_header_buffer nhbuf, dhbuf;
first_action = "edit";
*** ./collect.c- Mon Jul 3 20:52:26 1989
--- ./collect.c Tue Jul 4 19:49:51 1989
***************
*** 90,95 ****
--- 90,98 ----
article_number art_num;
{
FILE *art_file;
+ #if defined(iAPX286) && defined(lint)
+ static
+ #endif
news_header_buffer nhbuf, dgbuf;
article_header art_hdr;
int mode, count;
*** ./db.c- Thu Jun 29 20:55:48 1989
--- ./db.c Tue Jul 4 19:49:59 1989
***************
*** 177,183 ****
update_group(gh)
group_header *gh;
{
! int flag;
flag = gh->group_flag & ~G_MASTER_FLAGS;
--- 177,183 ----
update_group(gh)
group_header *gh;
{
! int32 flag;
flag = gh->group_flag & ~G_MASTER_FLAGS;
*** ./group.c- Mon Jul 3 20:52:31 1989
--- ./group.c Tue Jul 4 19:50:05 1989
***************
*** 456,462 ****
if (menu_cmd == ME_READ || menu_cmd == ME_NO_ARTICLES) {
if (did_selection) {
! int was_read = gh->group_flag & G_READ;
prev_last = gh->last_l_article;
gh->last_l_article = last_article;
--- 456,462 ----
if (menu_cmd == ME_READ || menu_cmd == ME_NO_ARTICLES) {
if (did_selection) {
! int32 was_read = gh->group_flag & G_READ;
prev_last = gh->last_l_article;
gh->last_l_article = last_article;
***************
*** 855,861 ****
printf("\r%s", cur->group_name); clrline();
! access_group(cur, -1, cur->last_l_article, access_mode, submask, do_kill);
}
merge_memory();
if (n_articles == 0) return;
--- 855,861 ----
printf("\r%s", cur->group_name); clrline();
! access_group(cur, (article_number) -1, cur->last_l_article, access_mode, submask, do_kill);
}
merge_memory();
if (n_articles == 0) return;
*** ./kill.c- Mon Jul 3 20:52:37 1989
--- ./kill.c Tue Jul 4 19:50:07 1989
***************
*** 385,396 ****
if (fread(&header, sizeof(header), 1, killf) != 1) goto err;
if (header.ckh_magic != COMP_KILL_MAGIC) goto err;
! patterns = malloc(header.ckh_pattern_size);
! mem_check(patterns, header.ckh_pattern_size, "kill bytes");
kill_tab = (kill_list_entry *)
! calloc(header.ckh_entries, sizeof(kill_list_entry));
! mem_check(kill_tab, header.ckh_entries, "kill entries");
for (n = header.ckh_entries, kl = kill_tab; --n >= 0; kl++) {
if (fread(&entry, sizeof(entry), 1, killf) != 1) goto err;
--- 385,396 ----
if (fread(&header, sizeof(header), 1, killf) != 1) goto err;
if (header.ckh_magic != COMP_KILL_MAGIC) goto err;
! patterns = malloc(INT(header.ckh_pattern_size));
! mem_check(patterns, INT(header.ckh_pattern_size), "kill bytes");
kill_tab = (kill_list_entry *)
! calloc(INT(header.ckh_entries), sizeof(kill_list_entry));
! mem_check(kill_tab, INT(header.ckh_entries), "kill entries");
for (n = header.ckh_entries, kl = kill_tab; --n >= 0; kl++) {
if (fread(&entry, sizeof(entry), 1, killf) != 1) goto err;
***************
*** 412,419 ****
}
}
! if (fread(patterns, sizeof(char), header.ckh_pattern_size, killf)
! != header.ckh_pattern_size) goto err;
fclose(killf);
--- 412,419 ----
}
}
! if (fread(patterns, sizeof(char), INT(header.ckh_pattern_size), killf)
! != INT(header.ckh_pattern_size)) goto err;
fclose(killf);
*** ./master.c- Mon Jul 3 20:52:41 1989
--- ./master.c Tue Jul 4 21:47:52 1989
***************
*** 412,418 ****
save_group(gh)
group_header *gh;
{
! int flag;
flag = gh->group_flag;
gh->group_flag &= G_MASTER_FLAGS;
--- 412,418 ----
save_group(gh)
group_header *gh;
{
! int32 flag;
flag = gh->group_flag;
gh->group_flag &= G_MASTER_FLAGS;
***************
*** 534,540 ****
open_master(OPEN_CREATE);
! fseek(master_file, sizeof(master), 0);
master.number_of_groups = 0;
--- 534,540 ----
open_master(OPEN_CREATE);
! fseek(master_file, (long) sizeof(master), 0);
master.number_of_groups = 0;
*** ./regexp.c- Thu Jun 29 20:56:33 1989
--- ./regexp.c Tue Jul 4 19:50:12 1989
***************
*** 248,254 ****
FAIL("regexp too big");
/* Allocate space. */
! r = (regexp *) malloc(sizeof(regexp) + (unsigned) regsize);
if (r == NULL)
FAIL("out of space");
--- 248,254 ----
FAIL("regexp too big");
/* Allocate space. */
! r = (regexp *) malloc(sizeof(regexp) + (unsigned int) regsize);
if (r == NULL)
FAIL("out of space");
*** ./term.c- Mon Jul 3 20:53:22 1989
--- ./term.c Tue Jul 4 23:01:01 1989
***************
*** 36,41 ****
--- 36,42 ----
#define HAS_CAP(str) (str && *str)
+ char *tgoto();
#else
#define USE_TERMCAP
***************
*** 233,239 ****
#endif
#ifdef USE_TERMINFO
! setupterm(0,1,0);
Columns = columns;
Lines = lines;
cookie_size = magic_cookie_glitch;
--- 234,240 ----
#endif
#ifdef USE_TERMINFO
! setupterm((char *) 0,1,(int *) 0);
Columns = columns;
Lines = lines;
cookie_size = magic_cookie_glitch;
*** ./unshar.c- Thu Jun 29 20:56:39 1989
--- ./unshar.c Tue Jul 4 19:49:52 1989
***************
*** 32,37 ****
--- 32,40 ----
long pos, ftell ();
/* Results from star matcher */
+ #if defined(iAPX286) && defined(lint)
+ static
+ #endif
char res1[BUFSIZ], res2[BUFSIZ], res3[BUFSIZ], res4[BUFSIZ];
char *result[4];
*** ./nn.c- Thu Jun 29 20:56:23 1989
--- ./nn.c Tue Jul 4 19:50:09 1989
***************
*** 352,358 ****
cur->last_l_article = 0;
}
} else
! menu_cmd = group_menu(cur, -1,
match_subject, do_kill_handling, menu);
if (menu_cmd != ME_NO_ARTICLES)
--- 352,358 ----
cur->last_l_article = 0;
}
} else
! menu_cmd = group_menu(cur, (article_number) -1,
match_subject, do_kill_handling, menu);
if (menu_cmd != ME_NO_ARTICLES)
*** ./admin.c- Thu Jun 29 20:55:45 1989
--- ./admin.c Tue Jul 4 20:24:59 1989
***************
*** 49,55 ****
long min_val, max_val;
{
char buf[100];
! int val;
loop:
--- 49,55 ----
long min_val, max_val;
{
char buf[100];
! long val;
loop:
***************
*** 219,225 ****
case 'O':
c = get_cmd("r)epeat_delay e)xpire_level", "OPTION");
if (c != 'r' && c != 'e') break;
! value = get_entry("Option value", 1, 10000);
if (value < 0) break;
send_master(c, (long)value, 0L);
break;
--- 219,225 ----
case 'O':
c = get_cmd("r)epeat_delay e)xpire_level", "OPTION");
if (c != 'r' && c != 'e') break;
! value = get_entry("Option value", (long) 1, (long) 10000);
if (value < 0) break;
send_master(c, (long)value, 0L);
break;
*** ./rc.c- Mon Jul 3 20:51:23 1989
--- ./rc.c Tue Jul 4 20:53:17 1989
***************
*** 423,429 ****
int was_unread;
art = gh->last_l_article - gh->last_article;
! was_unread = (gh->group_flag & G_UNREAD_COUNT);
if (mode > 0) {
if (was_unread) return 0;
--- 423,429 ----
int was_unread;
art = gh->last_l_article - gh->last_article;
! was_unread = ((gh->group_flag & G_UNREAD_COUNT) != 0);
if (mode > 0) {
if (was_unread) return 0;
*** ./sequence.c- Mon Jul 3 20:51:42 1989
--- ./sequence.c Tue Jul 4 21:08:16 1989
***************
*** 359,365 ****
static faked_entry(name, flag)
char *name;
! int flag;
{
group_header *gh;
--- 359,365 ----
static faked_entry(name, flag)
char *name;
! int32 flag;
{
group_header *gh;