Browse Source

src/frontend/** whitespace, indentation, ...

checked for object file invariance on linux
rlar 14 years ago
parent
commit
ab98f03622
  1. 2
      src/frontend/arg.c
  2. 2
      src/frontend/com_dl.h
  3. 1
      src/frontend/com_dump.c
  4. 4
      src/frontend/com_ghelp.c
  5. 3
      src/frontend/com_history.c
  6. 3
      src/frontend/com_measure2.c
  7. 2
      src/frontend/com_rehash.c
  8. 2
      src/frontend/com_shift.c
  9. 2
      src/frontend/com_strcmp.c
  10. 2
      src/frontend/control.h
  11. 1
      src/frontend/define.h
  12. 99
      src/frontend/help/help.c
  13. 39
      src/frontend/help/provide.c
  14. 224
      src/frontend/help/readhelp.c
  15. 38
      src/frontend/help/textdisp.c
  16. 196
      src/frontend/help/x11disp.c
  17. 34
      src/frontend/help/xdisplay.c
  18. 5
      src/frontend/hpgl.h
  19. 4
      src/frontend/init.c
  20. 8
      src/frontend/interp.c
  21. 3
      src/frontend/inventory.c
  22. 8
      src/frontend/linear.c
  23. 2
      src/frontend/miscvars.c
  24. 4
      src/frontend/numparam/general.h
  25. 2
      src/frontend/postsc.c
  26. 1
      src/frontend/rawfile.c
  27. 1
      src/frontend/runcoms2.c
  28. 2
      src/frontend/spiceif.c

2
src/frontend/arg.c

@ -46,7 +46,7 @@ countargs(wordlist *wl)
wordlist *w;
for (w = wl; w; w = w->wl_next)
number++ ;
number++;
return (number);
}

2
src/frontend/com_dl.h

@ -1,5 +1,5 @@
#ifndef _COM_DL_H
#define _COM_DL_H 1
#define _COM_DL_H 1
#ifdef XSPICE
void com_codemodel(wordlist *wl);

1
src/frontend/com_dump.c

@ -19,6 +19,7 @@ com_dump(wordlist *wl)
fprintf(cp_err, "Error: no circuit loaded.\n");
return;
}
if_dump(ft_curckt->ci_ckt, cp_out);
return;
}

4
src/frontend/com_ghelp.c

@ -35,7 +35,7 @@ com_ghelp(wordlist *wl)
com_help(wl);
return;
}
#ifndef X_DISPLAY_MISSING /* 1 */
#ifndef X_DISPLAY_MISSING /* 1 */
path = npath;
if (cp_getvar("helpregfont", CP_STRING, buf))
hlp_regfontname = copy(buf);
@ -76,6 +76,6 @@ com_ghelp(wordlist *wl)
#ifdef HAS_WINDOWS
printf("Internal help is no longer avaialable!\n");
printf("Please check for\n");
printf("http://newton.ex.ac.uk/teaching/CDHW/Electronics2/userguide/\n");
printf("http://newton.ex.ac.uk/teaching/CDHW/Electronics2/userguide/\n");
#endif
}

3
src/frontend/com_history.c

@ -375,6 +375,7 @@ cp_addhistent(int event, wordlist *wlist)
cp_lastone->hi_next = NULL;
cp_lastone->hi_event = event;
cp_lastone->hi_wlist = wl_copy(wlist);
#if !defined(HAVE_GNUREADLINE) && !defined(HAVE_BSDEDITLINE)
freehist(histlength - cp_maxhistlength);
histlength++;
@ -570,7 +571,7 @@ com_history(wordlist *wl)
cp_hprint(cp_event - 1, cp_event - histlength, rev);
else
cp_hprint(cp_event - 1, cp_event - 1 - atoi(wl->wl_word), rev);
#endif /* defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) */
#endif
return;
}

3
src/frontend/com_measure2.c

@ -93,7 +93,8 @@ correct_vec(MEASUREPTR meas)
vec = meas->m_vec;
/* return if not of type VM() etc */
if ((*vec != 'v') || (!strstr(vec, "("))) return;
if ((*vec != 'v') || (!strstr(vec, "(")))
return;
if (*(++vec) != '(') {
vecfirst = copy(meas->m_vec);

2
src/frontend/com_rehash.c

@ -22,7 +22,9 @@ com_rehash(wordlist *wl)
fprintf(cp_err, "Error: unixcom not set.\n");
return;
}
s = getenv("PATH");
if (s)
cp_rehash(s, TRUE);
else

2
src/frontend/com_shift.c

@ -27,7 +27,7 @@ com_shift(wordlist *wl)
}
if (wl)
num = scannum(wl->wl_word);
for (v = variables; v; v = v->va_next)
if (eq(v->va_name, n))
break;

2
src/frontend/com_strcmp.c

@ -19,7 +19,7 @@ com_strcmp(wordlist *wl)
var = wl->wl_word;
s1 = cp_unquote(wl->wl_next->wl_word);
s2 = cp_unquote(wl->wl_next->wl_next->wl_word);
i = strcmp(s1, s2);
tfree(s1);/*DG cp_unquote memory leak*/
tfree(s2);

2
src/frontend/control.h

@ -26,7 +26,7 @@ struct control {
struct control *co_elseblock; /* For if-then-else. */
struct control *co_next;
struct control *co_prev;
} ;
};
enum co_command {
CO_UNFILLED,

1
src/frontend/define.h

@ -10,5 +10,4 @@ void com_define(wordlist *wlist);
void com_undefine(wordlist *wlist);
#endif

99
src/frontend/help/help.c

@ -1,6 +1,6 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
Modified 1999 Emmanuel Rouat
**********/
@ -20,6 +20,7 @@ char *hlp_directory;
extern char *hlp_filelist[];
int hlp_ftablesize = 0;
void
hlp_main(char *path, wordlist *wl)
{
@ -32,7 +33,7 @@ hlp_main(char *path, wordlist *wl)
while (wl) {
if ((place = findglobalsubject(wl->wl_word)) == NULL) {
fprintf(stderr, "Error: No such topic: %s\n",
wl->wl_word);
wl->wl_word);
wl = wl->wl_next;
continue;
}
@ -46,8 +47,8 @@ hlp_main(char *path, wordlist *wl)
}
} else {
if ((place = findglobalsubject("main")) == NULL) {
fprintf(stderr, "Error: no main topic\n");
return;
fprintf(stderr, "Error: no main topic\n");
return;
}
if ((top = hlp_read(place)) == NULL) {
fprintf(stderr, "Error: can't read topic\n");
@ -63,6 +64,7 @@ hlp_main(char *path, wordlist *wl)
return;
}
fplace *
findglobalsubject(char *subject)
{
@ -73,33 +75,37 @@ findglobalsubject(char *subject)
place = 0;
for (dict = hlp_filelist; *dict && **dict; dict++) {
fpos = findsubject(*dict, subject);
if (fpos != -1) {
place = TMALLOC(fplace, 1);
place->fpos = fpos;
place->filename = copy(*dict);
place->fp = hlp_fopen(*dict);
break;
}
fpos = findsubject(*dict, subject);
if (fpos != -1) {
place = TMALLOC(fplace, 1);
place->fpos = fpos;
place->filename = copy(*dict);
place->fp = hlp_fopen(*dict);
break;
}
}
return(place);
return (place);
}
/* see if file is on filelist */
bool
hlp_approvedfile(char *filename)
{
char **s;
for (s = hlp_filelist; *s && **s; s++) {
if (cieq(*s, filename)) return(TRUE);
}
return(FALSE);
for (s = hlp_filelist; *s && **s; s++)
if (cieq(*s, filename))
return (TRUE);
return (FALSE);
}
/* keep file pointers on top level files so we don't always have to do
fopen's */
FILE *hlp_fopen(char *filename)
fopen's */
FILE *
hlp_fopen(char *filename)
{
static struct {
char filename[BSIZE_SP];
@ -108,11 +114,9 @@ FILE *hlp_fopen(char *filename)
int i;
char buf[BSIZE_SP];
for (i=0; i < hlp_ftablesize; i++) {
if (cieq(filename, hlp_ftable[i].filename)) {
return(hlp_ftable[i].fp);
}
}
for (i = 0; i < hlp_ftablesize; i++)
if (cieq(filename, hlp_ftable[i].filename))
return (hlp_ftable[i].fp);
/* not already in table */
strcpy(buf, hlp_directory); /* set up pathname */
@ -121,17 +125,18 @@ FILE *hlp_fopen(char *filename)
strcat(buf, ".txt");
hlp_pathfix(buf);
if ((hlp_ftable[hlp_ftablesize].fp = fopen(buf, "r")) == NULL) {
perror(buf);
return (NULL);
perror(buf);
return (NULL);
}
strcpy(hlp_ftable[hlp_ftablesize].filename, filename);
hlp_ftablesize++;
return(hlp_ftable[hlp_ftablesize - 1].fp);
return (hlp_ftable[hlp_ftablesize - 1].fp);
}
/* ARGSUSED */
void
hlp_pathfix(char *buf)
@ -142,31 +147,31 @@ hlp_pathfix(char *buf)
dir_pathsep = DIR_PATHSEP;
if (!buf)
return;
return;
s = cp_tildexpand(buf);
if (sizeof(DIR_PATHSEP) == 2) {
if (*dir_pathsep != '/') {
for (t = s; *t; t++) {
if (*t == '/')
*t = *dir_pathsep;
}
} else
strcpy(buf, s);
if (*dir_pathsep != '/') {
for (t = s; *t; t++) {
if (*t == '/')
*t = *dir_pathsep;
}
} else
strcpy(buf, s);
} else {
/* For vms; this probably doesn't work, but neither did the old code */
for (s = bufx, t = buf; *t; t++) {
if (*t == '/')
for (u = DIR_PATHSEP; *u; u++) {
*s++ = *u;
}
else
*s++ = *t;
}
*s = 0;
strcpy(buf, s);
/* For vms; this probably doesn't work, but neither did the old code */
for (s = bufx, t = buf; *t; t++) {
if (*t == '/')
for (u = DIR_PATHSEP; *u; u++)
*s++ = *u;
else
*s++ = *t;
}
*s = '\0';
strcpy(buf, s);
}
if (s)
tfree(s);
tfree(s);
return;
}

39
src/frontend/help/provide.c

@ -1,6 +1,6 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
Modified 1999 Emmanuel Rouat
**********/
@ -20,6 +20,7 @@ Modified 1999 Emmanuel Rouat
bool hlp_usex = FALSE;
void
hlp_provide(topic *top)
{
@ -27,7 +28,7 @@ hlp_provide(topic *top)
topic *parent, *newtop;
if (!top)
return;
return;
#ifndef X_DISPLAY_MISSING
if (getenv("DISPLAY") || hlp_displayname)
@ -48,9 +49,10 @@ hlp_provide(topic *top)
}
#ifndef X_DISPLAY_MISSING /* X11 does this asynchronously */
if (hlp_usex) return;
if (hlp_usex)
return;
#endif
for (;;) {
if (hlp_usex)
res = hlp_xhandle(&parent);
@ -59,8 +61,9 @@ hlp_provide(topic *top)
if (!res && !parent) {
/* No more windows. */
hlp_killfamily(top);
if (hlp_usex) hlp_xclosedisplay(); /* need to change
display pointer back J.H. */
if (hlp_usex)
hlp_xclosedisplay(); /* need to change
display pointer back J.H. */
return;
}
if (res) {
@ -81,26 +84,26 @@ hlp_provide(topic *top)
newtop->yposition = parent->yposition + 50;
if (hlp_usex) {
if (!hlp_xdisplay(newtop)) {
fprintf(stderr, "Couldn't open win\n");
return;
fprintf(stderr, "Couldn't open win\n");
return;
}
} else {
if (!hlp_tdisplay(newtop)) {
fprintf(stderr, "Couldn't display\n");
return;
fprintf(stderr, "Couldn't display\n");
return;
}
}
} else {
/* Blow this one and its descendants away. */
hlp_killfamily(parent);
hlp_fixchildren(parent);
hlp_fixchildren(parent);
if (parent == top)
return;
}
}
}
void
hlp_fixchildren(topic *parent)
{
@ -109,21 +112,19 @@ hlp_fixchildren(topic *parent)
if (parent->parent) {
if (parent->parent->children == parent)
parent->parent->children =
parent->next;
parent->parent->children = parent->next;
else {
for (pa = parent->parent->children;
pa->next; pa = pa->next)
for (pa = parent->parent->children; pa->next; pa = pa->next)
if (pa->next == parent)
break;
if (!pa->next) {
if (!pa->next)
fprintf(stderr, "bah...\n");
}
pa->next = pa->next->next;
}
}
}
/* Note that this doesn't actually free the data structures, just gets
* rid of the window.
*/
@ -135,10 +136,12 @@ hlp_killfamily(topic *top)
for (ch = top->children; ch; ch = ch->next)
hlp_killfamily(ch);
if (hlp_usex)
hlp_xkillwin(top);
else
hlp_tkillwin(top);
top->children = NULL;
return;
}

224
src/frontend/help/readhelp.c

@ -1,6 +1,6 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
Modified 1999 Emmanuel Rouat
**********/
@ -24,6 +24,7 @@ static topic *alltopics = NULL;
static fplace *copy_fplace(fplace *place);
static int
sortcmp(const void *a, const void *b)
{
@ -70,13 +71,15 @@ hlp_read(fplace *place)
bool mof = FALSE;
if (!place)
return 0;
return 0;
top->place = copy_fplace(place);
/* get the title */
if (!place->fp) place->fp = hlp_fopen(place->filename);
if (!place->fp) return(NULL);
if (!place->fp)
place->fp = hlp_fopen(place->filename);
if (!place->fp)
return (NULL);
fseek(place->fp, place->fpos, SEEK_SET);
(void) fgets(buf, BSIZE_SP, place->fp); /* skip subject */
(void) fgets(buf, BSIZE_SP, place->fp);
@ -88,20 +91,22 @@ hlp_read(fplace *place)
/* get the text */
/* skip to TEXT: */
while (fgets(buf, BSIZE_SP, place->fp)) {
if (!strncmp("TEXT: ", buf, 6)) break;
if ((*buf == '\0') || /* SJB - bug fix */
!strncmp("SEEALSO: ", buf, 9) ||
!strncmp("SUBTOPIC: ", buf, 10)) {
/* no text */
top->text = NULL;
goto endtext;
}
if (!strncmp("TEXT: ", buf, 6))
break;
if ((*buf == '\0') || /* SJB - bug fix */
!strncmp("SEEALSO: ", buf, 9) ||
!strncmp("SUBTOPIC: ", buf, 10))
{
/* no text */
top->text = NULL;
goto endtext;
}
}
mof = TRUE;
while (mof && !strncmp("TEXT: ", buf, 6)) {
for (s = &buf[6], fchanges = 0; *s && (*s != '\n'); s++)
if (((s[0] == '\033') && s[1]) ||
((s[0] == '_') && (s[1] == '\b')))
((s[0] == '_') && (s[1] == '\b')))
fchanges++;
*s = '\0';
wl_append_word(&(top->text), &end, copy(&buf[6]));
@ -117,15 +122,15 @@ endtext:
while(mof && !strncmp("SUBTOPIC: ", buf, 10)) {
s = &buf[10];
/* process tokens within line, updating pointer */
while (*s) {
if ((topiclink = getsubtoplink(&s)) != NULL) {
if (tend)
tend->next = topiclink;
else
top->subtopics = topiclink;
tend = topiclink;
}
}
while (*s) {
if ((topiclink = getsubtoplink(&s)) != NULL) {
if (tend)
tend->next = topiclink;
else
top->subtopics = topiclink;
tend = topiclink;
}
}
mof = fgets(buf, BSIZE_SP, place->fp) == NULL ? FALSE : TRUE;
}
@ -134,94 +139,104 @@ endtext:
while(mof && !strncmp("SEEALSO: ", buf, 9)) {
s = &buf[9];
/* process tokens within line, updating pointer */
while (*s) {
if ((topiclink = getsubtoplink(&s)) != NULL) {
if (tend)
tend->next = topiclink;
else
top->seealso = topiclink;
tend = topiclink;
}
}
while (*s) {
if ((topiclink = getsubtoplink(&s)) != NULL) {
if (tend)
tend->next = topiclink;
else
top->seealso = topiclink;
tend = topiclink;
}
}
mof = fgets(buf, BSIZE_SP, place->fp) == NULL ? FALSE : TRUE;
}
/* Now we have to fill in the subjects
for the seealsos and subtopics. */
/* Now we have to fill in the subjects
for the seealsos and subtopics. */
for (tl = top->seealso; tl; tl = tl->next)
tl->description = getsubject(tl->place);
for (tl = top->subtopics; tl; tl = tl->next)
tl->description = getsubject(tl->place);
sortlist(&top->seealso);
/* sortlist(&top->subtopics); It looks nicer if they
are in the original order */
are in the original order */
top->readlink = alltopics;
alltopics = top;
return (top);
}
/* *ss is of the form filename:subject */
static toplink *getsubtoplink(char **ss)
static toplink *
getsubtoplink(char **ss)
{
toplink *tl;
char *tmp, *s, *t;
char subject[BSIZE_SP];
if (!**ss) return(NULL);
if (!**ss)
return (NULL);
s = *ss;
tl = alloc(toplink);
if ((tmp =strchr(s, ':')) != NULL) {
tl->place = alloc(fplace);
tl->place->filename = strncpy(
TMALLOC(char, tmp - s + 1),
s, (size_t) (tmp - s));
tl->place->filename[tmp - s] = '\0';
strtolower(tl->place->filename);
/* see if filename is on approved list */
if (!hlp_approvedfile(tl->place->filename)) {
tfree(tl->place);
tfree(tl);
/* skip up to next comma or newline */
while (*s && *s != ',' && *s != '\n') s++;
while (*s && (*s == ',' || *s == ' ' || *s == '\n')) s++;
tl->place = alloc(fplace);
tl->place->filename =
strncpy(TMALLOC(char, tmp - s + 1), s, (size_t) (tmp - s));
tl->place->filename[tmp - s] = '\0';
strtolower(tl->place->filename);
/* see if filename is on approved list */
if (!hlp_approvedfile(tl->place->filename)) {
tfree(tl->place);
tfree(tl);
/* skip up to next comma or newline */
while (*s && *s != ',' && *s != '\n')
s++;
while (*s && (*s == ',' || *s == ' ' || *s == '\n'))
s++;
*ss = s;
return (NULL);
}
tl->place->fp = hlp_fopen(tl->place->filename);
for (s = tmp + 1, t = subject; *s && *s != ',' && *s != '\n'; s++)
*t++ = *s;
*t = '\0';
tl->place->fpos = findsubject(tl->place->filename, subject);
if (tl->place->fpos == -1) {
tfree(tl->place);
tfree(tl);
while (*s && (*s == ',' || *s == ' ' || *s == '\n'))
s++;
*ss = s;
return (NULL);
}
} else {
fprintf(stderr, "bad filename:subject pair %s\n", s);
/* skip up to next free space */
while (*s && *s != ',' && *s != '\n')
s++;
while (*s && (*s == ',' || *s == ' ' || *s == '\n'))
s++;
*ss = s;
return(NULL);
}
tl->place->fp = hlp_fopen(tl->place->filename);
for (s = tmp + 1, t = subject; *s && *s != ',' && *s != '\n'; s++) {
*t++ = *s;
}
*t = '\0';
tl->place->fpos = findsubject(tl->place->filename, subject);
if (tl->place->fpos == -1) {
tfree(tl->place);
tfree(tl);
while (*s && (*s == ',' || *s == ' ' || *s == '\n')) s++;
*ss = s;
return(NULL);
}
} else {
fprintf(stderr, "bad filename:subject pair %s\n", s);
/* skip up to next free space */
while (*s && *s != ',' && *s != '\n') s++;
while (*s && (*s == ',' || *s == ' ' || *s == '\n')) s++;
*ss = s;
tfree(tl->place);
tfree(tl);
return(NULL);
return (NULL);
}
while (*s && (*s == ',' || *s == ' ' || *s == '\n')) s++;
while (*s && (*s == ',' || *s == ' ' || *s == '\n'))
s++;
*ss = s;
return(tl);
return (tl);
}
/* returns a file position, -1 on error */
long
findsubject(char *filename, char *subject)
@ -232,67 +247,69 @@ findsubject(char *filename, char *subject)
struct hlp_index indexitem;
if (!filename) {
return -1;
return -1;
}
/* open up index for filename */
sprintf(buf, "%s%s%s.idx", hlp_directory, DIR_PATHSEP, filename);
hlp_pathfix(buf);
if ((fp = fopen(buf, "rb")) == NULL) {
perror(buf);
return(-1);
perror(buf);
return (-1);
}
/* try it exactly (but ignore case) */
while(fread(&indexitem, sizeof (struct hlp_index), 1, fp)) {
if (!strncasecmp(subject, indexitem.subject, 64)) { /* sjb - ignore case */
fclose(fp);
return(indexitem.fpos);
}
if (!strncasecmp(subject, indexitem.subject, 64)) { /* sjb - ignore case */
fclose(fp);
return (indexitem.fpos);
}
}
fclose(fp);
if ((fp = fopen(buf, "rb")) == NULL) {
perror(buf);
return(-1);
perror(buf);
return (-1);
}
/* try it abbreviated (ignore case) */
while(fread(&indexitem, sizeof (struct hlp_index), 1, fp)) {
if (!strncasecmp(indexitem.subject,subject, strlen(subject))) {
fclose(fp);
return(indexitem.fpos);
}
if (!strncasecmp(indexitem.subject,subject, strlen(subject))) {
fclose(fp);
return (indexitem.fpos);
}
}
fclose(fp);
if ((fp = fopen(buf, "rb")) == NULL) {
perror(buf);
return(-1);
perror(buf);
return (-1);
}
/* try it within */ /* FIXME: need a case independent version of strstr() */
/* try it within */ /* FIXME: need a case independent version of strstr() */
while(fread(&indexitem, sizeof (struct hlp_index), 1, fp)) {
if (strstr(indexitem.subject,subject)) {
fclose(fp);
return(indexitem.fpos);
}
if (strstr(indexitem.subject,subject)) {
fclose(fp);
return (indexitem.fpos);
}
}
fclose(fp);
return(-1);
return (-1);
}
static char *
getsubject(fplace *place)
{
char buf[BSIZE_SP], *s;
if (!place->fp) place->fp = hlp_fopen(place->filename);
if (!place->fp) return(NULL);
if (!place->fp)
place->fp = hlp_fopen(place->filename);
if (!place->fp)
return(NULL);
fseek(place->fp, place->fpos, SEEK_SET);
(void) fgets(buf, BSIZE_SP, place->fp);
@ -303,7 +320,7 @@ getsubject(fplace *place)
}
static
static
void tlfree(toplink *tl)
{
toplink *nt = NULL;
@ -339,6 +356,7 @@ hlp_free(void)
return;
}
static fplace *
copy_fplace(fplace *place)
{
@ -349,5 +367,5 @@ copy_fplace(fplace *place)
newplace->fpos = place->fpos;
newplace->fp = place->fp;
return(newplace);
return (newplace);
}

38
src/frontend/help/textdisp.c

@ -1,6 +1,6 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
**********/
@ -24,6 +24,7 @@ static int putstuff(toplink *tl, int base);
int hlp_width = 72;
bool
hlp_tdisplay(topic *top)
{
@ -48,6 +49,7 @@ hlp_tdisplay(topic *top)
return (TRUE);
}
toplink *
hlp_thandle(topic **parent)
{
@ -73,28 +75,30 @@ hlp_thandle(topic **parent)
for (s = buf; *s && isspace(*s); s++)
;
switch (*s) {
case '?':
case '?':
fprintf(cp_out,
"\nType the number of a sub-topic or see also, or one of:\n\
\tr\tReprint the current topic\n\
\tp or CR\tReturn to the previous topic\n\
\tq\tQuit help\n\
\t?\tPrint this message\n\n");
"\n"
"Type the number of a sub-topic or see also, or one of:\n"
"\tr\tReprint the current topic\n"
"\tp or CR\tReturn to the previous topic\n"
"\tq\tQuit help\n"
"\t?\tPrint this message\n"
"\n");
continue;
case 'r':
case 'r':
(void) hlp_tdisplay(curtop);
continue;
case 'q':
case 'q':
quitflag = TRUE;
*parent = NULL;
return (NULL);
case 'p':
case '\n':
case '\r':
case '\0':
case 'p':
case '\n':
case '\r':
case '\0':
*parent = curtop;
return (NULL);
}
@ -124,6 +128,7 @@ hlp_thandle(topic **parent)
}
}
/* ARGSUSED */
void
hlp_tkillwin(topic *top)
@ -137,6 +142,7 @@ hlp_tkillwin(topic *top)
return;
}
/* This has to rip out the font changes from the lines... */
static void
@ -147,7 +153,7 @@ putline(char *s)
while (*s) {
if (((*s == '\033') && s[1]) ||
((*s == '_') && (s[1] == '\b')))
((*s == '_') && (s[1] == '\b')))
s += 2;
else
buf[i++] = *s++;
@ -157,6 +163,7 @@ putline(char *s)
return;
}
/* Figure out the number of columns we can use. Assume an entry like
* nn) word -- add 5 characters to the width...
*/
@ -195,7 +202,7 @@ putstuff(toplink *tl, int base)
for (j = 0; j < ncols; j++) {
if (tt)
out_printf("%2d) %-*s ", base + j * nrows + i + 1,
maxwidth - 5, tt->description);
maxwidth - 5, tt->description);
for (k = 0; k < nrows; k++)
if (tt)
tt = tt->next;
@ -205,4 +212,3 @@ putstuff(toplink *tl, int base)
return (nbuts);
}

196
src/frontend/help/x11disp.c

@ -31,16 +31,19 @@ static Atom atom_wm_delete_window;
static Atom atom_wm_protocols;
static Display *display;
/* callback function for catching window deletion by WM x-button */
static void handle_wm_messages(Widget w, XtPointer client_data, XEvent *event, Boolean *cont) {
static void
handle_wm_messages(Widget w, XtPointer client_data, XEvent *event, Boolean *cont)
{
topic *top = (topic *) client_data;
NG_IGNORE(cont);
NG_IGNORE(w);
if (event->type == ClientMessage
&& event->xclient.message_type == atom_wm_protocols
&& (Atom) event->xclient.data.l[0] == atom_wm_delete_window)
if (event->type == ClientMessage &&
event->xclient.message_type == atom_wm_protocols &&
(Atom) event->xclient.data.l[0] == atom_wm_delete_window)
{
hlp_killfamily(top);
hlp_fixchildren(top);
@ -90,122 +93,120 @@ hlp_xdisplay(topic *top)
if (!started) { /* have to init everything */
/* assume X toolkit already initialize */
/* assume X toolkit already initialize */
started = TRUE;
started = TRUE;
}
top->shellwidget = XtCreateApplicationShell("shell",
topLevelShellWidgetClass, NULL, 0);
top->shellwidget = XtCreateApplicationShell
("shell", topLevelShellWidgetClass, NULL, 0);
if (!top->parent) {
top->xposition = hlp_initxpos;
top->yposition = hlp_initypos;
top->xposition = hlp_initxpos;
top->yposition = hlp_initypos;
} else {
top->xposition = top->parent->xposition + X_INCR;
top->yposition = top->parent->yposition + Y_INCR;
top->xposition = top->parent->xposition + X_INCR;
top->yposition = top->parent->yposition + Y_INCR;
}
XtSetArg(formargs[0], XtNx, top->xposition);
XtSetArg(formargs[1], XtNy, top->yposition);
top->formwidget = XtCreateManagedWidget("form", formWidgetClass,
top->shellwidget, formargs, XtNumber(formargs));
top->formwidget = XtCreateManagedWidget
("form", formWidgetClass, top->shellwidget, formargs, XtNumber(formargs));
/* we really want a title bar widget for this, sigh */
top->titlewidget = XtCreateManagedWidget("title",
boxWidgetClass, top->formwidget,
titleargs, XtNumber(titleargs));
top->titlewidget = XtCreateManagedWidget
("title", boxWidgetClass, top->formwidget, titleargs, XtNumber(titleargs));
XtSetArg(labelargs[0], XtNlabel, top->title);
XtCreateManagedWidget("titlelabel", labelWidgetClass,
top->titlewidget, labelargs, 1);
XtCreateManagedWidget
("titlelabel", labelWidgetClass, top->titlewidget, labelargs, 1);
XtSetArg(buttonargs[0], XtNlabel, "quit help");
buttonwidget = XtCreateManagedWidget("quit", commandWidgetClass,
top->titlewidget, buttonargs, 1);
buttonwidget = XtCreateManagedWidget
("quit", commandWidgetClass, top->titlewidget, buttonargs, 1);
XtAddCallback(buttonwidget, XtNcallback, quit, top);
XtSetArg(buttonargs[0], XtNlabel, "delete window");
buttonwidget = XtCreateManagedWidget("delete", commandWidgetClass,
top->titlewidget, buttonargs, XtNumber(buttonargs));
buttonwidget = XtCreateManagedWidget
("delete", commandWidgetClass, top->titlewidget, buttonargs, XtNumber(buttonargs));
XtAddCallback(buttonwidget, XtNcallback, delete_w, top);
buf = TMALLOC(char, 80 * top->numlines + 100);
buf[0] = '\0';
for (wl = top->text; wl; wl = wl->wl_next) {
sputline(buf, wl->wl_word);
sputline(buf, wl->wl_word);
}
top->chartext = buf; /* make sure gets deallocated later XXX */
XtSetArg(htextargs[0], XtNstring, top->chartext);
XtSetArg(htextargs[1], XtNallowResize, True);
XtSetArg(htextargs[2], XtNscrollHorizontal, XawtextScrollWhenNeeded );
XtSetArg(htextargs[3], XtNscrollVertical, XawtextScrollAlways );
XtSetArg(htextargs[2], XtNscrollHorizontal, XawtextScrollWhenNeeded);
XtSetArg(htextargs[3], XtNscrollVertical, XawtextScrollAlways);
XtSetArg(htextargs[4], XtNfromVert, top->titlewidget);
XtSetArg(htextargs[5], XtNwidth, 660);
XtSetArg(htextargs[6], XtNheight, 350);
top->textwidget = XtCreateManagedWidget("helptext",
asciiTextWidgetClass, top->formwidget, htextargs,
XtNumber(htextargs));
top->textwidget = XtCreateManagedWidget
("helptext", asciiTextWidgetClass, top->formwidget, htextargs, XtNumber(htextargs));
if (top->subtopics) {
XtSetArg(labelargs[0], XtNfromVert, top->textwidget);
XtSetArg(labelargs[1], XtNvertDistance, 8);
XtSetArg(labelargs[2], XtNlabel, "Subtopics: ");
top->sublabelwidget = XtCreateManagedWidget("sublabel",
labelWidgetClass, top->formwidget, labelargs, XtNumber(labelargs));
XtSetArg(bboxargs[0], XtNwidth, 400);
XtSetArg(bboxargs[1], XtNallowResize, True);
XtSetArg(bboxargs[2], XtNfromVert, top->sublabelwidget);
top->subboxwidget = XtCreateManagedWidget("buttonbox",
boxWidgetClass, top->formwidget, bboxargs, XtNumber(bboxargs));
for (tl = top->subtopics; tl; tl = tl->next) {
tl->button.text = tl->description;
tl->button.tag = tl->place;
if (!tl->button.text)
tl->button.text = "<unknown>";
XtSetArg(buttonargs[0], XtNlabel, tl->button.text);
buttonwidget = XtCreateManagedWidget(tl->button.text,
commandWidgetClass, top->subboxwidget, buttonargs,
XtNumber(buttonargs));
/* core leak XXX */
hand = TMALLOC(handle, 1);
hand->result = tl;
hand->parent = top;
XtAddCallback(buttonwidget, XtNcallback, newtopic, hand);
}
XtSetArg(labelargs[0], XtNfromVert, top->textwidget);
XtSetArg(labelargs[1], XtNvertDistance, 8);
XtSetArg(labelargs[2], XtNlabel, "Subtopics: ");
top->sublabelwidget = XtCreateManagedWidget
("sublabel", labelWidgetClass, top->formwidget, labelargs, XtNumber(labelargs));
XtSetArg(bboxargs[0], XtNwidth, 400);
XtSetArg(bboxargs[1], XtNallowResize, True);
XtSetArg(bboxargs[2], XtNfromVert, top->sublabelwidget);
top->subboxwidget = XtCreateManagedWidget
("buttonbox", boxWidgetClass, top->formwidget, bboxargs, XtNumber(bboxargs));
for (tl = top->subtopics; tl; tl = tl->next) {
tl->button.text = tl->description;
tl->button.tag = tl->place;
if (!tl->button.text)
tl->button.text = "<unknown>";
XtSetArg(buttonargs[0], XtNlabel, tl->button.text);
buttonwidget = XtCreateManagedWidget
(tl->button.text, commandWidgetClass, top->subboxwidget, buttonargs, XtNumber(buttonargs));
/* core leak XXX */
hand = TMALLOC(handle, 1);
hand->result = tl;
hand->parent = top;
XtAddCallback(buttonwidget, XtNcallback, newtopic, hand);
}
}
if (top->seealso) {
if (top->subtopics)
XtSetArg(labelargs[0], XtNfromVert, top->subboxwidget);
else
XtSetArg(labelargs[0], XtNfromVert, top->textwidget);
XtSetArg(labelargs[1], XtNvertDistance, 8);
XtSetArg(labelargs[2], XtNlabel, "See also: ");
top->seelabelwidget = XtCreateManagedWidget("seelabel",
labelWidgetClass, top->formwidget, labelargs, XtNumber(labelargs));
XtSetArg(bboxargs[0], XtNwidth, 400);
XtSetArg(bboxargs[1], XtNallowResize, True);
XtSetArg(bboxargs[2], XtNfromVert, top->seelabelwidget);
top->seeboxwidget = XtCreateManagedWidget("buttonbox",
boxWidgetClass, top->formwidget, bboxargs, XtNumber(bboxargs));
for (tl = top->seealso; tl; tl = tl->next) {
tl->button.text = tl->description;
tl->button.tag = tl->place;
if (!tl->button.text)
tl->button.text = "<unknown>";
XtSetArg(buttonargs[0], XtNlabel, tl->button.text);
buttonwidget = XtCreateManagedWidget(tl->button.text,
commandWidgetClass, top->seeboxwidget, buttonargs, 1);
hand = TMALLOC(handle, 1);
/* core leak XXX */
hand->result = tl;
hand->parent = top;
XtAddCallback(buttonwidget, XtNcallback, newtopic, hand);
}
if (top->subtopics)
XtSetArg(labelargs[0], XtNfromVert, top->subboxwidget);
else
XtSetArg(labelargs[0], XtNfromVert, top->textwidget);
XtSetArg(labelargs[1], XtNvertDistance, 8);
XtSetArg(labelargs[2], XtNlabel, "See also: ");
top->seelabelwidget = XtCreateManagedWidget
("seelabel", labelWidgetClass, top->formwidget, labelargs, XtNumber(labelargs));
XtSetArg(bboxargs[0], XtNwidth, 400);
XtSetArg(bboxargs[1], XtNallowResize, True);
XtSetArg(bboxargs[2], XtNfromVert, top->seelabelwidget);
top->seeboxwidget = XtCreateManagedWidget
("buttonbox", boxWidgetClass, top->formwidget, bboxargs, XtNumber(bboxargs));
for (tl = top->seealso; tl; tl = tl->next) {
tl->button.text = tl->description;
tl->button.tag = tl->place;
if (!tl->button.text)
tl->button.text = "<unknown>";
XtSetArg(buttonargs[0], XtNlabel, tl->button.text);
buttonwidget = XtCreateManagedWidget
(tl->button.text, commandWidgetClass, top->seeboxwidget, buttonargs, 1);
hand = TMALLOC(handle, 1);
/* core leak XXX */
hand->result = tl;
hand->parent = top;
XtAddCallback(buttonwidget, XtNcallback, newtopic, hand);
}
}
XtRealizeWidget(top->shellwidget);
@ -222,9 +223,9 @@ hlp_xdisplay(topic *top)
XSetWMProtocols(display, XtWindow(top->shellwidget), &atom_wm_delete_window, 1);
return (TRUE);
}
static void
newtopic(Widget w, XtPointer client_data, XtPointer call_data)
{
@ -236,7 +237,7 @@ newtopic(Widget w, XtPointer client_data, XtPointer call_data)
NG_IGNORE(w);
if (!(newtop = hlp_read(result->place))) {
fprintf(stderr, "Internal error: bad link\n");
fprintf(stderr, "Internal error: bad link\n");
}
newtop->next = parent->children;
@ -250,10 +251,10 @@ newtopic(Widget w, XtPointer client_data, XtPointer call_data)
}
}
static void
delete_w(Widget w, XtPointer client_data, XtPointer call_data)
{
topic *top = (topic *) client_data;
NG_IGNORE(call_data);
@ -263,19 +264,22 @@ delete_w(Widget w, XtPointer client_data, XtPointer call_data)
hlp_fixchildren(top);
}
static void
quit(Widget w, XtPointer client_data, XtPointer call_data)
{
topic *top = (topic *) client_data, *parent = top->parent;
NG_IGNORE(call_data);
NG_IGNORE(w);
while (parent && parent->parent) parent = parent->parent;
while (parent && parent->parent)
parent = parent->parent;
hlp_killfamily(parent ? parent : top);
}
void
hlp_xkillwin(topic *top)
{
@ -284,8 +288,8 @@ hlp_xkillwin(topic *top)
if (top == topics)
topics = top->winlink;
else if (top->winlink) { /* we need this check for the
pathological case where you have two helps running,
normally hp_killfamily doesn't let this happen */
pathological case where you have two helps running,
normally hp_killfamily doesn't let this happen */
for (last = topics; last->winlink; last = last->winlink)
if (last->winlink == top) {
last->winlink = top->winlink;
@ -300,6 +304,7 @@ hlp_xkillwin(topic *top)
return;
}
/* rip out font changes and write at end of buffer */
static void
sputline(char *buf, char *s)
@ -310,11 +315,12 @@ sputline(char *buf, char *s)
while (*s) {
if (((*s == '\033') && s[1]) ||
((*s == '_') && (s[1] == '\b')))
((*s == '_') && (s[1] == '\b')))
s += 2;
else
tmp[i++] = *s++;
}
tmp[i] = '\0';
/* strcat can't handle long strings */

34
src/frontend/help/xdisplay.c

@ -1,6 +1,6 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
Author: 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
Modified 1999 Emmanuel Rouat
**********/
@ -22,24 +22,42 @@ int hlp_initypos = START_YPOS;
int hlp_buttonstyle = BS_LEFT;
#ifdef X_DISPLAY_MISSING
bool hlp_xdisplay(topic *top) {
bool
hlp_xdisplay(topic *top)
{
NG_IGNORE(top);
return (FALSE);
return (FALSE);
}
void hlp_xkillwin(topic *top) {
void
hlp_xkillwin(topic *top)
{
NG_IGNORE(top);
}
#endif
void hlp_xwait(topic *top, bool on)
void
hlp_xwait(topic *top, bool on)
{
NG_IGNORE(on);
NG_IGNORE(top);
}
void hlp_xclosedisplay(void) {}
toplink * hlp_xhandle(topic **pp) { *pp = NULL; return (NULL); }
void
hlp_xclosedisplay(void)
{
}
toplink *
hlp_xhandle(topic **pp)
{
*pp = NULL;
return (NULL);
}

5
src/frontend/hpgl.h

@ -3,7 +3,7 @@
************/
#ifndef HPGH_H
#define HPGH_H
#define HPGH_H
disp_fn_Init_t GL_Init;
disp_fn_NewViewport_t GL_NewViewport;
@ -16,4 +16,5 @@ disp_fn_SetLinestyle_t GL_SetLinestyle;
disp_fn_SetColor_t GL_SetColor;
disp_fn_Update_t GL_Update;
#endif /* HPGH_H */
#endif

4
src/frontend/init.c

@ -38,9 +38,9 @@ cp_init(void)
cp_curout = stdout;
cp_curerr = stderr;
/* io redirection in streams.c:
/* io redirection in streams.c:
cp_in set to cp_curin etc. */
cp_ioreset();
cp_ioreset();
return;
}

8
src/frontend/interp.c

@ -1,6 +1,6 @@
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
**********/
/*
@ -24,10 +24,12 @@ lincopy(struct dvec *ov, double *newscale, int newlen, struct dvec *oldscale)
fprintf(cp_err, "Warning: %s is not real\n", ov->v_name);
return;
}
if (ov->v_length < oldscale->v_length) {
fprintf(cp_err, "Warning: %s is too short\n", ov->v_name);
return;
}
v = alloc(struct dvec);
v->v_name = copy(ov->v_name);
v->v_type = ov->v_type;
@ -37,11 +39,13 @@ lincopy(struct dvec *ov, double *newscale, int newlen, struct dvec *oldscale)
nd = TMALLOC(double, newlen);
if (!ft_interpolate(ov->v_realdata, nd, oldscale->v_realdata,
oldscale->v_length, newscale, newlen, 1)) {
oldscale->v_length, newscale, newlen, 1))
{
fprintf(cp_err, "Error: can't interpolate %s\n", ov->v_name);
return;
}
v->v_realdata = nd;
vec_new(v);
return;
}

3
src/frontend/inventory.c

@ -41,12 +41,11 @@ com_inventory(wordlist *wl)
out_init();
out_send("Circuit Inventory\n\n");
for (k = 0; k < ft_sim->numDevices; k++) {
for (k = 0; k < ft_sim->numDevices; k++)
if (ft_sim->devices[k])
out_printf("%s: %d\n",
ft_sim->devices[k]->name,
devList[k].instNum);
}
out_send("\n");
return;
}

8
src/frontend/linear.c

@ -29,13 +29,13 @@ com_linearize(wordlist *wl)
if (!ft_curckt || !ft_curckt->ci_ckt ||
!if_tranparams(ft_curckt, &tstart, &tstop, &tstep)) {
fprintf(cp_err,
"Error: can't get transient parameters from circuit\n");
fprintf(cp_err,
"Error: can't get transient parameters from circuit\n");
return;
}
if (((tstop - tstart) * tstep <= 0.0) || ((tstop - tstart) < tstep)) {
fprintf(cp_err,
"Error: bad parameters -- start = %G, stop = %G, step = %G\n",
fprintf(cp_err,
"Error: bad parameters -- start = %G, stop = %G, step = %G\n",
tstart, tstop, tstep);
return;
}

2
src/frontend/miscvars.c

@ -129,4 +129,4 @@ char *ft_setkwords[] = {
"xfont",
NULL
} ;
};

4
src/frontend/numparam/general.h

@ -47,8 +47,8 @@ char rc(void);
int freadstr(FILE *f, SPICE_DSTRINGPTR dstr_p);
long np_round(double d); // sjb to avoid clash with round() in math.h
long np_trunc(double x); // sjb to avoid clash with trunc() in math.h
long np_round(double d); // sjb to avoid clash with round() in math.h
long np_trunc(double x); // sjb to avoid clash with trunc() in math.h
double absf(double x); /* abs */
long absi(long i);

2
src/frontend/postsc.c

@ -444,7 +444,7 @@ PS_SelectColor(int colorid) /* should be replaced by PS_DefineColor */
internalerror("bad colorid inside PS_SelectColor");
} else if (scale == 1) { /* colorN is not an rgbstring, use default color */
sprintf(colorstring, "%1.3f %1.3f %1.3f", colors[colorid].red/255.0,
colors[colorid].green/255.0, colors[colorid].blue/255.0) ;
colors[colorid].green/255.0, colors[colorid].blue/255.0);
strcpy(pscolor, colorstring);
}
}

1
src/frontend/rawfile.c

@ -804,6 +804,7 @@ spar_write(char *name, struct plot *pl, double Rbaseval)
}
(void) putc('\n', fp);
}
(void) fclose(fp);
return;
}

1
src/frontend/runcoms2.c

@ -254,6 +254,7 @@ com_remcirc(wordlist *wl)
}
prev = p;
}
/* make first entry in ft_circuits the actual circuit (or NULL) */
ft_curckt = ft_circuits;

2
src/frontend/spiceif.c

@ -708,7 +708,7 @@ spif_getparam_special(CKTcircuit *ckt, char **name, char *param, int ind, int do
*/
/* if (!(opt->dataType & IF_ASK) || (opt->dataType & IF_UNINTERESTING) || (opt->dataType & IF_STRING)) continue; */
if (!(opt->dataType & IF_ASK) || (opt->dataType & IF_UNINTERESTING ))
if (!(opt->dataType & IF_ASK) || (opt->dataType & IF_UNINTERESTING))
continue;
pv = doask(ckt, typecode, dev, mod, opt, ind);
if (pv) {

Loading…
Cancel
Save