[news.admin] problem with getmaps.c

barnett@vdsvax.steinmetz.UUCP (Bruce G Barnett) (05/06/87)

	The version of getmaps.c that I have has a problem when
unpacking the maps files: it sorts the file names alphabetically
instead of numerically. That is, it extracts 1, 10, 11, .. 19, then
2, 3, .. 9.

	So if the update to a map is in article 19, and the original
is in article 2 - you lose the update if you unpack them at the same time.

	With the new group name - and the articles starting with
number 1, I suppect that others may have similar problems.

	Does anyone have a different sort program to use in getmaps.c?

	Also - the patch that someone provided to fix the \EOF problem
is based on a slightly different version of getmaps.c than the one I
got with news 2.11. Did I miss out on a new revision?




-- 
			Bruce G. Barnett 
barnett@ge-crd.arpa, barnett@steinmetz.uucp
	...!{chinet,rochester}!steinmetz!barnett

jgd@pollux.UUCP (Dr. James George Dunham) (05/19/87)

In article <1414@vdsvax.steinmetz.UUCP> barnett@ge-crd.arpa  (Bruce G Barnett) writes:
>
>	The version of getmaps.c that I have has a problem when
>unpacking the maps files: it sorts the file names alphabetically
>instead of numerically. That is, it extracts 1, 10, 11, .. 19, then
>2, 3, .. 9.
>
This is a real problem, especially if you automatically unpack the maps on
a regular basis. The next map to be unpacked after 9 is 90, and all the
one between are not unpacked. Here are diffs to sort in numerical order.

*** getmap.c.orig	Wed May  6 08:40:01 1987
--- getmap.c	Tue May 19 15:18:44 1987
***************
*** 98,104
  	struct direct **filst;
  	int	nfils, x;
  	struct stat stbuf;
! 	extern int scandir(), alphasort();
  	extern char *strcpy(), *strncat();
  
  	if ((nfils = scandir(grp, &filst, (int (*)())NULL, alphasort)) == -1)

--- 98,104 -----
  	struct direct **filst;
  	int	nfils, x;
  	struct stat stbuf;
! 	extern int scandir(), numsort();
  	extern char *strcpy(), *strncat();
  
  	if ((nfils = scandir(grp, &filst, (int (*)())NULL, numsort)) == -1)
***************
*** 101,107
  	extern int scandir(), alphasort();
  	extern char *strcpy(), *strncat();
  
! 	if ((nfils = scandir(grp, &filst, (int (*)())NULL, alphasort)) == -1)
  		myabort("scandir failed");
  
  	(void )strcpy(nbuf, grp);

--- 101,107 -----
  	extern int scandir(), numsort();
  	extern char *strcpy(), *strncat();
  
! 	if ((nfils = scandir(grp, &filst, (int (*)())NULL, numsort)) == -1)
  		myabort("scandir failed");
  
  	(void )strcpy(nbuf, grp);
***************
*** 128,134
  		}
  		if ((stbuf.st_mode & S_IFMT) == S_IFDIR)
  			continue;
! 		if (strcmp(seqbuf, filst[x]->d_name) >= 0)
  			continue;
  
  		mkmaps(nbuf);

--- 128,134 -----
  		}
  		if ((stbuf.st_mode & S_IFMT) == S_IFDIR)
  			continue;
! 		if (atoi(seqbuf) >= atoi(filst[x]->d_name))
  			continue;
  
  		mkmaps(nbuf);
***************
*** 334,336
  }
  
  

--- 338,353 -----
  }
  
  
+ numsort(d1, d2)
+ struct direct **d1, **d2;
+ {
+   int n1, n2;
+   n1=atoi((*d1)->d_name);
+   n2=atoi((*d2)->d_name);
+   if (n1 > n2)
+     return(1);
+   else if (n1 < n2)
+     return(-1);
+   else
+     return(0);
+ }