Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!ut-ngp!infotel!pollux!jgd From: jgd@pollux.UUCP (Dr. James George Dunham) Newsgroups: news.admin Subject: Re: problem with getmaps.c Message-ID: <312@pollux.UUCP> Date: Tue, 19-May-87 16:33:12 EDT Article-I.D.: pollux.312 Posted: Tue May 19 16:33:12 1987 Date-Received: Sat, 23-May-87 10:18:52 EDT References: <1414@vdsvax.steinmetz.UUCP> Reply-To: jgd@pollux.UUCP (Dr. James George Dunham) Distribution: world Organization: Department of Electrical Engineering; S.M.U.; Dallas, TX Lines: 90 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); + }