Browse Source

* src/hlp/readhelp.c src/parser/var2.c: reordered comparison


			
			
				pre-master-46
			
			
		
arno 26 years ago
parent
commit
1662ce6e11
  1. 85
      src/hlp/readhelp.c
  2. 26
      src/parser/var2.c

85
src/hlp/readhelp.c

@ -14,13 +14,44 @@ Modified 1999 Emmanuel Rouat
static char *getsubject(fplace *place);
static toplink *getsubtoplink(char **ss);
extern void sortlist(toplink **tlp), tlfree(toplink *tl);
extern int sortcmp(toplink **tlp1, toplink **tlp2);
static topic *alltopics = NULL;
static fplace *copy_fplace(fplace *place);
static int
sortcmp(const void *a, const void *b)
{
toplink **tlp1 = (toplink **) a;
toplink **tlp2 = (toplink **) b;
return (strcmp((*tlp1)->description, (*tlp2)->description));
}
static void
sortlist(toplink **tlp)
{
toplink **vec, *tl;
int num = 0, i;
for (tl = *tlp; tl; tl = tl->next)
num++;
if (!num)
return;
vec = (toplink **) tmalloc(sizeof (toplink *) * num);
for (tl = *tlp, i = 0; tl; tl = tl->next, i++)
vec[i] = tl;
(void) qsort((char *) vec, num, sizeof (toplink *), sortcmp);
*tlp = vec[0];
for (i = 0; i < num - 1; i++)
vec[i]->next = vec[i + 1];
vec[i]->next = NULL;
tfree(vec);
return;
}
topic *
hlp_read(fplace *place)
{
@ -241,33 +272,24 @@ getsubject(fplace *place)
return (copy(&buf[9])); /* don't copy "SUBJECT: " */
}
static
void sortlist(toplink **tlp)
void tlfree(toplink *tl)
{
toplink **vec, *tl;
int num = 0, i;
toplink *nt = NULL;
for (tl = *tlp; tl; tl = tl->next)
num++;
if (!num)
return;
vec = (toplink **) tmalloc(sizeof (toplink *) * num);
for (tl = *tlp, i = 0; tl; tl = tl->next, i++)
vec[i] = tl;
(void) qsort((char *) vec, num, sizeof (toplink *), sortcmp);
*tlp = vec[0];
for (i = 0; i < num - 1; i++)
vec[i]->next = vec[i + 1];
vec[i]->next = NULL;
tfree(vec);
while (tl) {
tfree(tl->description);
tfree(tl->place->filename);
tfree(tl->place);
/* Don't free the button stuff... */
nt = tl->next;
tfree(tl);
tl = nt;
}
return;
}
static int
sortcmp(toplink **tlp1, toplink **tlp2)
{
return (strcmp((*tlp1)->description, (*tlp2)->description));
}
void
hlp_free(void)
@ -287,23 +309,6 @@ hlp_free(void)
return;
}
static
void tlfree(toplink *tl)
{
toplink *nt = NULL;
while (tl) {
tfree(tl->description);
tfree(tl->place->filename);
tfree(tl->place);
/* Don't free the button stuff... */
nt = tl->next;
tfree(tl);
tl = nt;
}
return;
}
static fplace *
copy_fplace(fplace *place)
{

26
src/parser/var2.c

@ -14,8 +14,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
/* Print the values of currently defined variables. */
static int vcmp(struct xxx *v1, struct xxx *v2);
extern struct variable *variables;
/* A variable substitution is
@ -234,6 +232,19 @@ vareval(char *string)
}
static int
vcmp(const void *a, const void *b)
{
int i;
struct xxx *v1 = (struct xxx *) a;
struct xxx *v2 = (struct xxx *) b;
if ((i = strcmp(v1->x_v->va_name, v2->x_v->va_name)))
return (i);
else
return (v1->x_char - v2->x_char);
}
void
cp_vprint(void)
@ -295,17 +306,6 @@ cp_vprint(void)
return;
}
static int
vcmp(struct xxx *v1, struct xxx *v2)
{
int i;
if ((i = strcmp(v1->x_v->va_name, v2->x_v->va_name)))
return (i);
else
return (v1->x_char - v2->x_char);
}
/* The set command. Syntax is
* set [opt ...] [opt = val ...]. Val may be a string, an int, a float,
* or a list of the form (elt1 elt2 ...).

Loading…
Cancel
Save