Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made reentrant by moving all globals/static variables to a struct and… #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
756 changes: 373 additions & 383 deletions am.c

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions am.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,20 @@ enum language_list {

/* Debugging macros: */
#if SILENT
#define list_esdebug(level, en) { ; } /* Display an equation space. */
#define list_tdebug(level) { ; } /* Display the temporary equation (e.g.: when solving). */
#define side_debug(level, p1, n1) { ; } /* Display any expression. */
#define debug_string(level, str) { ; } /* Display any ASCII string. */
#define list_esdebug(mathomatic, level, en) { ; } /* Display an equation space. */
#define list_tdebug(mathomatic, level) { ; } /* Display the temporary equation (e.g.: when solving). */
#define side_debug(mathomatic, level, p1, n1) { ; } /* Display any expression. */
#define debug_string(mathomatic, level, str) { ; } /* Display any ASCII string. */
#else
#define list_esdebug(level, en) list_debug(level, lhs[en], n_lhs[en], rhs[en], n_rhs[en])
#define list_tdebug(level) list_debug(level, tlhs, n_tlhs, trhs, n_trhs)
#define side_debug(level, p1, n1) list_debug(level, p1, n1, NULL, 0)
#define debug_string(level, str) { if (debug_level >= (level)) fprintf(gfp, "%s\n", str); }
#define list_esdebug(mathomatic, level, en) list_debug(mathomatic, level, mathomatic->lhs[en], mathomatic->n_lhs[en], mathomatic->rhs[en], mathomatic->n_rhs[en])
#define list_tdebug(mathomatic, level) list_debug(mathomatic, level, mathomatic->tlhs, mathomatic->n_tlhs, mathomatic->trhs, mathomatic->n_trhs)
#define side_debug(mathomatic, level, p1, n1) list_debug(mathomatic, level, p1, n1, NULL, 0)
#define debug_string(mathomatic, level, str) { if (mathomatic->debug_level >= (level)) fprintf(mathomatic->gfp, "%s\n", str); }
#endif

/* The correct ways to determine if equation number "en" (origin 0) contains an expression or equation. */
#define empty_equation_space(en) ((en) < 0 || (en) >= n_equations || n_lhs[(en)] <= 0)
#define equation_space_is_equation(en) ((en) >= 0 && (en) < n_equations && n_lhs[(en)] > 0 && n_rhs[(en)] > 0)
#define empty_equation_space(mathomatic, en) ((en) < 0 || (en) >= mathomatic->n_equations || mathomatic->n_lhs[(en)] <= 0)
#define equation_space_is_equation(mathomatic, en) ((en) >= 0 && (en) < mathomatic->n_equations && mathomatic->n_lhs[(en)] > 0 && mathomatic->n_rhs[(en)] > 0)

/*
* The following are macros for displaying help text.
Expand All @@ -192,10 +192,10 @@ enum language_list {
* This is helpful when the output device has less than 80 text character columns.
*/
#if NOT80COLUMNS
#define SP(str) fprintf(gfp, "%s ", str) /* display part of a paragraph, separated with spaces (Space Paragraph) */
#define EP(str) fprintf(gfp, "%s\n", str) /* display the end of a paragraph (End Paragraph) */
#define SP(mathomatic, str) fprintf(mathomatic->gfp, "%s ", str) /* display part of a paragraph, separated with spaces (Space Paragraph) */
#define EP(mathomatic, str) fprintf(mathomatic->gfp, "%s\n", str) /* display the end of a paragraph (End Paragraph) */
#else /* Otherwise the following only works nicely with 80 column or wider screens; */
/* all strings passed to it should be less than 80 columns if possible, so it doesn't wrap around. */
#define SP(str) fprintf(gfp, "%s\n", str)
#define EP(str) fprintf(gfp, "%s\n", str)
#define SP(mathomatic, str) fprintf(mathomatic->gfp, "%s\n", str)
#define EP(mathomatic, str) fprintf(mathomatic->gfp, "%s\n", str)
#endif
2 changes: 1 addition & 1 deletion blt.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int cnt;
if (cnt == 0) {
return dest;
} else {
error_bug("blt() cnt < 0");
error_bug(mathomatic, "blt() cnt < 0");
}
}
if (src == dest) {
Expand Down
Loading