[Mew-dist 16972] Re: mewls range option

SAKAI Kiyotaka ksakai at example.com
2001年 3月 27日 (火) 15:06:05 JST


>> In article <20010311.143921.607980827.kasahara at example.com>, kasahara at example.com writes:

> 最悪人間が 2pass で処理すれば現状のままでもいいんですが、mewls が 
> 1pass でいるために人間が 2pass になるというのは、それはそれで本末転倒
> な気がします。

こんな感じで、qsort() の後、その結果を最後の N個だけを残すようにすれば、
mewls の処理はほとんど増やさずに対応できると思うのですが。
-- 
酒井 清隆 (E-mail: ksakai at example.com)
-------------- next part --------------
===================================================================
RCS file: RCS/mewls.c,v
retrieving revision 1.1
diff -c -r1.1 mewls.c
*** mewls.c	2001/03/27 05:34:06	1.1
--- mewls.c	2001/03/27 05:50:19
***************
*** 86,91 ****
--- 86,92 ----
  	char *folder;
  	unsigned int first;
  	unsigned int last;
+ 	unsigned int num;
  };
  
  private char Buf_header[MAX_HEADER];
***************
*** 656,661 ****
--- 657,663 ----
  	DIR *dirp;
  	struct dirent *dp;
  	char *fname;
+ 	int i;
  
  	ch_folder(fr->folder);
  
***************
*** 678,683 ****
--- 680,691 ----
  
  	qsort(Scan_ctx_buf, num, sizeof(int),
  	      (int (*)(const void *, const void *)) scan_intcompare);
+ 
+ 	if (fr->num > 0 && fr->num < num) {
+ 		for (i = 0; i < num; i++)
+ 			Scan_ctx_buf[i] = Scan_ctx_buf[num - fr->num + i] ;
+ 		num = fr->num;
+ 	}
  	
  	return num;
  }
***************
*** 844,856 ****
  	else
  		*range++ = NUL;
  	if (range == NULL)
  		fr->first = fr->last = 0;
! 	else if ((last = strchr(range, '-')) == NULL)
  		fr->first = fr->last = atoi(range);
! 	else {
  		*last++ = NUL;
  		fr->first = atoi(range);
  		fr->last = atoi(last);
  	}
  
  	if (folder == NULL) folder = INBOX;
--- 852,870 ----
  	else
  		*range++ = NUL;
  	if (range == NULL)
+ 		fr->first = fr->last = fr->num = 0;
+ 	else if (strncmp(range, "last:", 5) == 0) {
+ 		range += 5;
  		fr->first = fr->last = 0;
! 		fr->num = atoi(range);
! 	} else if ((last = strchr(range, '-')) == NULL) {
  		fr->first = fr->last = atoi(range);
! 		fr->num = 0;
! 	} else {
  		*last++ = NUL;
  		fr->first = atoi(range);
  		fr->last = atoi(last);
+ 		fr->num = 0;
  	}
  
  	if (folder == NULL) folder = INBOX;


Mew-dist メーリングリストの案内