version 1.1.1.1, 2000/01/09 17:00:51 |
version 1.1.1.3, 2003/09/15 07:09:25 |
Line 36 static char *RCSid = "$Id$"; |
|
Line 36 static char *RCSid = "$Id$"; |
|
|
|
#include "plot.h" |
#include "plot.h" |
|
|
#define SAME 0 /* for strcmp() */ |
|
|
|
#include "help.h" /* values passed back */ |
#include "help.h" /* values passed back */ |
|
|
void int_error __PROTO((char str[], int t_num)); |
void int_error __PROTO((char str[], int t_num)); |
Line 150 static FILE *helpfp = NULL; |
|
Line 148 static FILE *helpfp = NULL; |
|
|
|
static int LoadHelp __PROTO((char *path)); |
static int LoadHelp __PROTO((char *path)); |
static void sortkeys __PROTO((void)); |
static void sortkeys __PROTO((void)); |
static int keycomp __PROTO((struct key_s * a, struct key_s * b)); |
int keycomp __PROTO((SORTFUNC_ARGS a, SORTFUNC_ARGS b)); |
static LINEBUF *storeline __PROTO((char *text)); |
static LINEBUF *storeline __PROTO((char *text)); |
static LINKEY *storekey __PROTO((char *key)); |
static LINKEY *storekey __PROTO((char *key)); |
static KEY *FindHelp __PROTO((char *keyword)); |
static KEY *FindHelp __PROTO((char *keyword)); |
Line 187 TBOOLEAN *subtopics; /* (in) - subtopics only? */ |
|
Line 185 TBOOLEAN *subtopics; /* (in) - subtopics only? */ |
|
** Calling routine may access errno to determine cause of H_ERROR. |
** Calling routine may access errno to determine cause of H_ERROR. |
*/ |
*/ |
errno = 0; |
errno = 0; |
if (strncmp(oldpath, path, PATHSIZE) != SAME) |
if (strncmp(oldpath, path, PATHSIZE) != 0) |
FreeHelp(); |
FreeHelp(); |
if (keys == NULL) { |
if (keys == NULL) { |
status = LoadHelp(path); |
status = LoadHelp(path); |
|
|
{ |
{ |
LINEBUF *new; |
LINEBUF *new; |
|
|
new = (LINEBUF *) malloc(sizeof(LINEBUF)); |
new = (LINEBUF *) gp_alloc(sizeof(LINEBUF), "new line buffer"); |
if (new == NULL) |
if (text) |
int_error("not enough memory to store help file", -1); |
new->line = gp_strdup(text); |
if (text != NULL) { |
else |
new->line = (char *) malloc((unsigned int) (strlen(text) + 1)); |
|
if (new->line == NULL) |
|
int_error("not enough memory to store help file", -1); |
|
(void) strcpy(new->line, text); |
|
} else |
|
new->line = NULL; |
new->line = NULL; |
|
|
new->next = NULL; |
new->next = NULL; |
|
|
|
|
key[strlen(key) - 1] = NUL; /* cut off \n */ |
key[strlen(key) - 1] = NUL; /* cut off \n */ |
|
|
new = (LINKEY *) malloc(sizeof(LINKEY)); |
new = (LINKEY *) gp_alloc(sizeof(LINKEY), "new key list"); |
if (new == NULL) |
if (key) |
int_error("not enough memory to store help file", -1); |
new->key = gp_strdup(key); |
new->key = (char *) malloc((unsigned int) (strlen(key) + 1)); |
|
if (new->key == NULL) |
|
int_error("not enough memory to store help file", -1); |
|
(void) strcpy(new->key, key); |
|
|
|
/* add to front of list */ |
/* add to front of list */ |
new->next = keylist; |
new->next = keylist; |
Line 341 static void sortkeys() |
|
Line 330 static void sortkeys() |
|
int i; /* index into key array */ |
int i; /* index into key array */ |
|
|
/* allocate the array */ |
/* allocate the array */ |
keys = (KEY *) malloc((unsigned int) ((keycount + 1) * sizeof(KEY))); |
keys = (KEY *) gp_alloc((keycount + 1) * sizeof(KEY), "key array"); |
if (keys == NULL) |
|
int_error("not enough memory to store help file", -1); |
|
|
|
/* copy info from list to array, freeing list */ |
/* copy info from list to array, freeing list */ |
for (p = keylist, i = 0; p != NULL; p = n, i++) { |
for (p = keylist, i = 0; p != NULL; p = n, i++) { |
Line 363 static void sortkeys() |
|
Line 350 static void sortkeys() |
|
/* sort the array */ |
/* sort the array */ |
/* note that it only moves objects of size (two pointers + long + int) */ |
/* note that it only moves objects of size (two pointers + long + int) */ |
/* it moves no strings */ |
/* it moves no strings */ |
qsort((char *) keys, keycount, sizeof(KEY), (sortfunc) keycomp); |
qsort((char *) keys, keycount, sizeof(KEY), keycomp); |
} |
} |
|
|
static int keycomp(a, b) |
/* HBB 20010720: changed to make this match the prototype qsort() |
KEY *a, *b; |
* really expects. Casting function pointers, as we did before, is |
|
* illegal! */ |
|
/* HBB 20010720: removed 'static' to avoid HP-sUX gcc bug */ |
|
int |
|
keycomp(arg1, arg2) |
|
SORTFUNC_ARGS arg1; |
|
SORTFUNC_ARGS arg2; |
{ |
{ |
|
const KEY *a = arg1; |
|
const KEY *b = arg2; |
|
|
return (strcmp(a->key, b->key)); |
return (strcmp(a->key, b->key)); |
} |
} |
|
|
Line 515 TBOOLEAN *subtopics; /* (in) - subtopics only? */ |
|
Line 511 TBOOLEAN *subtopics; /* (in) - subtopics only? */ |
|
/* ShowSubtopics: |
/* ShowSubtopics: |
* Print a list of subtopic names |
* Print a list of subtopic names |
*/ |
*/ |
|
/* The maximum number of subtopics per line */ |
#define PER_LINE 4 |
#define PER_LINE 4 |
|
|
static void ShowSubtopics(key, subtopics) |
static void ShowSubtopics(key, subtopics) |
Line 562 TBOOLEAN *subtopics; /* (out) are there any subtopics |
|
Line 559 TBOOLEAN *subtopics; /* (out) are there any subtopics |
|
*line = NUL; |
*line = NUL; |
pos = 0; |
pos = 0; |
} |
} |
if (pos == PER_LINE) { |
if (pos >= PER_LINE) { |
(void) strcat(line, "\n"); |
(void) strcat(line, "\n"); |
OutLine(line); |
OutLine(line); |
*line = NUL; |
*line = NUL; |
pos = 0; |
pos = 0; |
} |
} |
/* adapted by DvdSchaaf */ |
#define FIRSTCOL 4 |
{ |
#define COLLENGTH 18 |
#define FIRSTCOL 6 |
|
#define COLLENGTH 15 |
|
|
|
if (pos == 0) |
/* adapted by DvdSchaaf */ |
spacelen = FIRSTCOL; |
if (pos == 0) |
for (ispacelen = 0; |
spacelen = FIRSTCOL; |
ispacelen < spacelen; ispacelen++) |
for (ispacelen = 0; ispacelen < spacelen; ispacelen++) |
(void) strcat(line, " "); |
(void) strcat(line, " "); |
/* commented out * |
(void) strncat(line, start, sublen); |
(void) strcat(line, "\t"); |
spacelen = COLLENGTH - sublen; |
*/ |
|
(void) strncat(line, start, sublen); |
while (spacelen <= 0) { |
spacelen = COLLENGTH - sublen; |
spacelen += COLLENGTH; |
if (spacelen <= 0) |
pos++; |
spacelen = 1; |
|
} |
} |
|
|
pos++; |
pos++; |
prev = start; |
prev = start; |
} |
} |