> From: RobGreene@aol.com
> Date: Tue, 28 Feb 1995 19:51:29 -0500
> To: miquels@drinkel.ow.org
> Subject: Minicom 1.70
>
> patch for Sort in dial menu.
>
> ============= dial.c.patch =================
> *** dial.c.original Tue Feb 28 17:48:38 1995
> --- dial.c  Tue Feb 28 17:52:44 1995
> ***************
> *** 12,17 ****
> --- 12,18 ----
>    */
>   #include "port.h"
>   #include "minicom.h"
> + #include <ctype.h>
>   
>   #if VC_MUSIC
>   #  if defined(__linux__)
> ***************
> *** 35,40 ****
> --- 36,54 ----
>   #define FL_TAG        0x80    /* This entry is tagged. */
>   #define FL_SAVE       0x0f    /* Which portions of flags to save. */
>   
> + #define DIALOPTS 6
> + int stricmp(s1, s2)
> + char *s1, *s2;
> + {
> +     while (*s1 != '\0' && *s2 != '\0' && toupper(*s1) == toupper(*s2)) {
> +   s1++;
> +   s2++;
> +     }
> +     if (toupper(*s1) == toupper(*s2)) return 0;
> +     if (toupper(*s1) < toupper(*s2)) return -1;
> +     return 1;
> + }
> + 
>   /* Dialing directory. */
>   struct v1_dialent {
> 	char name[32];
> ***************
> *** 823,829 ****
>   }
>   
>   static WIN *dsub;
> ! static char *what =  "  Dial    Find    Add     Edit   Remove  Manual ";
>   static int dprev;
>   
>   /*
> --- 837,843 ----
>   }
>   
>   static WIN *dsub;
> ! static char *what =  "  Dial    Find    Add     Edit    Sort   Remove
>  Manual ";
>   static int dprev;
>   
>   /*
> ***************
> *** 835,841 ****
> 	if (k == dprev) return;
>   
> 	if (dprev >= 0) {
> !       wlocate(dsub, 14 + 8*dprev, 0);
> 	if (!useattr) {
> 		wputs(dsub, " ");
> 	} else {
> --- 849,855 ----
> 	if (k == dprev) return;
>   
> 	if (dprev >= 0) {
> !       wlocate(dsub, 10 + 8*dprev, 0);
> 	if (!useattr) {
> 		wputs(dsub, " ");
> 	} else {
> ***************
> *** 844,850 ****
> 	}
> 	}
> 	dprev = k;
> !   wlocate(dsub, 14 + 8*k, 0);
> 	if (!useattr) {
> 	wputs(dsub, ">");
> 	} else {
> --- 858,864 ----
> 	}
> 	}
> 	dprev = k;
> !   wlocate(dsub, 10 + 8*k, 0);
> 	if (!useattr) {
> 	wputs(dsub, ">");
> 	} else {
> ***************
> *** 989,995 ****
> 	wcursor(w, CNONE);
> 	wtitle(w, TMID, "Dialing Directory");
> 	wputs(w, "     Name               Number       Line Format Terminal Script\n"
> );
> !   wlocate(dsub, 14, 0);
> 	wputs(dsub, what);
>   
> 	wsetregion(w, 1, w->ys - 1);
> --- 1003,1009 ----
> 	wcursor(w, CNONE);
> 	wtitle(w, TMID, "Dialing Directory");
> 	wputs(w, "     Name               Number       Line Format Terminal
> Script\n");
> !   wlocate(dsub, 10, 0);
> 	wputs(dsub, what);
>   
> 	wsetregion(w, 1, w->ys - 1);
> ***************
> *** 1022,1032 ****
> 			case K_LT:
> 			case 'h':
> 			subm--;
> !           if (subm < 0) subm = 5;
> 				break;
> 			case K_RT:
> 			case 'l':
> !               subm = (subm + 1) % 6;
> 				break;
> 			case K_PGUP:
> 			case '\002': /* Control-B */
> --- 1036,1046 ----
> 			case K_LT:
> 			case 'h':
> 			subm--;
> !           if (subm < 0) subm = DIALOPTS;
> 				break;
> 			case K_RT:
> 			case 'l':
> !               subm = (subm + 1) % (DIALOPTS+1);
> 				break;
> 			case K_PGUP:
> 			case '\002': /* Control-B */
> ***************
> *** 1054,1067 ****
> 			subm = 3;
> 			quit = 1;
> 			break;
> !       case 'r':    /* Remove. */
> 			subm = 4;
> 			quit = 1;
> 			break;
> !       case 'm':    /* Manual. */
> 			subm = 5;
> 			quit = 1;
> 			break;
> 		case ' ':    /* Tag. */
> 				wlocate(w, 4, cur + 1 - top);
> 			d->flags ^= FL_TAG;
> --- 1068,1085 ----
> 			subm = 3;
> 			quit = 1;
> 			break;
> !       case 's':    /* Sort */
> 			subm = 4;
> 			quit = 1;
> 			break;
> !       case 'r':    /* Remove. */
> 			subm = 5;
> 			quit = 1;
> 			break;
> +       case 'm':    /* Manual. */
> +           subm = 6;
> +           quit = 1;
> +           break;
> 		case ' ':    /* Tag. */
> 				wlocate(w, 4, cur + 1 - top);
> 			d->flags ^= FL_TAG;
> ***************
> *** 1199,1207 ****
> 		wprintf(w, fmt, cur+1, (d->flags & FL_TAG) ? 16 : ' ', d->name,
> 	d->number, d->baud, d->bits, d->parity, te[d->term - 1], d->script);
> 	}
> 	
> 	/* Delete an entry from the list */
> !   if (subm == 4 && ask("Remove entry?", d_yesno) == 0) {
> 		if (nrents == 1) {
> 			free((char *)d);
> 			d = dialents = mkstdent();
> --- 1217,1259 ----
> 		wprintf(w, fmt, cur+1, (d->flags & FL_TAG) ? 16 : ' ', d->name,
> 	d->number, d->baud, d->bits, d->parity, te[d->term - 1], d->script);
> 	}
> + 
> +   /* Sort - not the greatest technique, but it works. */
> +   if (subm == 4 && ask("Sort entries?", d_yesno) == 0) {
> +   struct dialent *pnew, *psearch, *pprev, *p0, *p1, *pwork, *pstart;
> +   pstart= dialents;
> +   p0= pprev= pnew= pwork= NULL;
> +   p1= psearch= pstart;
> +   while (psearch) {
> +       /* Found lowest, track previous and current entry */
> +       if (stricmp(psearch->name, p1->name) < 0) {
> +       p0= pprev;
> +       p1= psearch;
> +       }
> +       /* Next ... */
> +       pprev= psearch;
> +       psearch= psearch->next;
> +       /* End of list */
> +       if (!psearch) {
> +       /* Remove next entry from dialents and add to new list */
> +       if (pwork) pwork->next= p1; /* > 1 node */
> +       else pwork= p1;         /* only 1 node */
> +       if (p0) p0->next= p1->next; /* in middle */
> +       else pstart= p1->next;      /* at start */
> +       p1->next= NULL;
> +       if (!pnew) pnew= pwork;
> +       if (pwork->next) pwork= pwork->next;
> +       /* Reset for next locate */
> +       p0= pprev= NULL;
> +       p1= psearch= pstart;
> +       }
> +   }
> +   dialents= pnew;
> +   prdir(w, top, top);  
> +   }
> 	
> 	/* Delete an entry from the list */
> !   if (subm == 5 && ask("Remove entry?", d_yesno) == 0) {
> 		if (nrents == 1) {
> 			free((char *)d);
> 			d = dialents = mkstdent();
> ***************
> *** 1229,1235 ****
> 		ocur = cur;
> 	}
> 	/* Dial a number manually. */
> !   if (subm == 5) {
> 	s = input("Enter number", manual);
> 	if (s && *s) {
> 			writedialdir();
> --- 1281,1287 ----
> 		ocur = cur;
> 	}
> 	/* Dial a number manually. */
> !   if (subm == 6) {
> 	s = input("Enter number", manual);
> 	if (s && *s) {
> 			writedialdir();
> =============== end of patch ================
>
