print function now works for null tree
This commit is contained in:
6
mpc.c
6
mpc.c
@@ -2486,6 +2486,7 @@ void mpc_ast_delete(mpc_ast_t *a) {
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (a == NULL) { return; }
|
if (a == NULL) { return; }
|
||||||
|
|
||||||
for (i = 0; i < a->children_num; i++) {
|
for (i = 0; i < a->children_num; i++) {
|
||||||
mpc_ast_delete(a->children[i]);
|
mpc_ast_delete(a->children[i]);
|
||||||
}
|
}
|
||||||
@@ -2599,6 +2600,11 @@ mpc_ast_t *mpc_ast_state(mpc_ast_t *a, mpc_state_t s) {
|
|||||||
static void mpc_ast_print_depth(mpc_ast_t *a, int d, FILE *fp) {
|
static void mpc_ast_print_depth(mpc_ast_t *a, int d, FILE *fp) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (a == NULL) {
|
||||||
|
fprintf(fp, "NULL\n");
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < d; i++) { fprintf(fp, " "); }
|
for (i = 0; i < d; i++) { fprintf(fp, " "); }
|
||||||
|
|
||||||
if (strlen(a->contents)) {
|
if (strlen(a->contents)) {
|
||||||
|
Reference in New Issue
Block a user