9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Lyndon Nerenberg <lyndon@orthanc.ca>
To: 9front@9front.org
Subject: [9front] news(1) patch: make -a and -n get along
Date: Sun, 24 Jan 2021 02:28:48 -0800	[thread overview]
Message-ID: <1efbedde4f69c2a8@orthanc.ca> (raw)

[-- Attachment #1: Type: text/plain, Size: 143 bytes --]

[ I sent this to 9front-bugs but that copy seems to have
  been swallowed by a black home. ]

This patch makes 'news -an' do the right thing.


[-- Attachment #2: Type: text/plain, Size: 1147 bytes --]

/n/dump/2021/0122/sys/src/cmd/news.c:44,65 - news.c:44,72
  void
  main(int argc, char *argv[])
  {
- 	int i;
+ 	int i, aflag = 0, nflag = 0;
+ 	int doupdate = 1;
+ 	int printall = 0;
+ 	void (*printer)(char*) = print_item;
  
  	Binit(&bout, 1, OWRITE);
  	if(argc == 1) {
- 		eachitem(print_item, 0, 1);
+ 		eachitem(print_item, printall, doupdate);
  		exits(0);
  	}
  	ARGBEGIN{
  	case 'a':	/* print all */
- 		eachitem(print_item, 1, 0);
+ 		doupdate = 0;
+ 		printall = 1;
+ 		// eachitem(print_item, 1, 0);
  		break;
  
  	case 'n':	/* names only */
- 		eachitem(note, 0, 0);
- 		if(n_items)
- 			Bputc(&bout, '\n');
+ 		doupdate = 0;
+ 		printer = note;
+ 		// eachitem(note, 0, 0);
+ 		// if(n_items)
+ 		// 	Bputc(&bout, '\n');
  		break;
  
  	default:
/n/dump/2021/0122/sys/src/cmd/news.c:66,73 - news.c:73,87
  		fprint(2, "news: bad option %c\n", ARGC());
  		exits("usage");
  	}ARGEND
- 	for(i=0; i<argc; i++)
- 		print_item(argv[i]);
+ 	
+ 	if (argc == 0){
+ 		eachitem(printer, printall, doupdate);
+ 	}else{
+ 		for(i=0; i<argc; i++)
+ 			print_item(argv[i]);
+ 	}
+ 	if (n_items)
+ 		Bputc(&bout, '\n');
  	exits(0);
  }
  

             reply	other threads:[~2021-01-24 10:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-24 10:28 Lyndon Nerenberg [this message]
2021-01-24 18:13 ` ori
2021-01-24 19:03   ` Stanley Lieber
2021-01-24 19:14   ` ori
2021-01-24 21:48   ` Noam Preil
2021-01-25  0:59   ` Lyndon Nerenberg
     [not found]     ` <38af8e19-8e85-4131-8d92-5a29bc02932a@sirjofri.de>
2021-01-25 16:27       ` Lyndon Nerenberg
2021-01-25  7:30   ` telephil9
2021-01-25  7:42     ` Kurt H Maier
2021-01-25 16:26     ` Lyndon Nerenberg
2021-01-25 16:50       ` hiro
2021-01-25 19:42         ` ori
2021-01-25 17:44       ` Stanley Lieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1efbedde4f69c2a8@orthanc.ca \
    --to=lyndon@orthanc.ca \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).