Heh.  Do you have this fcn in Scheme?

;-)

Stuart


> 
> 
> > This gets a bit confusing for more than 9 pins: P10 winds up between
> > P1 and P2!
> 
> My local copy of PCB uses this string comparison function to sort
> embedded numbers numerically.  I use this to sort netlists, because of
> the same pin numbering bug you mention.
> 
> static int
> string_cmp (const char *a, const char *b)
> {
>   while (*a && *b)
>     {
>       if (isdigit(*a) && isdigit(*b))
>       {
>       int ia = atoi(a);
>       int ib = atoi(b);
>       if (ia != ib)
>         return ia - ib;
>       while (isdigit(*a))
>         a++;
>       while (isdigit(*b))
>         b++;
>       }
>       else if (tolower(*a) != tolower(*b))
>       return tolower(*a) - tolower(*b);
>       a++;
>       b++;
>     }
>   if (*a)
>     return 1;
>   if (*b)
>     return -1;
>   return 0;
> }
> 

Reply via email to