summaryrefslogtreecommitdiffabout
path: root/src/prog.c
Unidiff
Diffstat (limited to 'src/prog.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/prog.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/prog.c b/src/prog.c
index 83401ef..75b5228 100644
--- a/src/prog.c
+++ b/src/prog.c
@@ -384,7 +384,7 @@ env_get_locus(eval_environ_t env, struct mu_locus_range *locus)
384{ 384{
385 mu_locus_range_init(locus); 385 mu_locus_range_init(locus);
386 locus->beg.mu_file = (char*)(env->dataseg + env->locus.file); 386 locus->beg.mu_file = (char*)(env->dataseg + env->locus.file);
387 env_register_auto(env, (void*) locus->beg.mu_file); 387 env_register_auto(env, (void*) &locus->beg.mu_file);
388 locus->beg.mu_line = env->locus.line; 388 locus->beg.mu_line = env->locus.line;
389#if 0 389#if 0
390 locus->beg.mu_col = env->locus.point; 390 locus->beg.mu_col = env->locus.point;
@@ -493,32 +493,39 @@ env_function_cleanup_add(eval_environ_t env, void *data,
493static void 493static void
494env_register_auto(eval_environ_t env, void *ptr) 494env_register_auto(eval_environ_t env, void *ptr)
495{ 495{
496 char *addr = *(char**)ptr;
497
496 if (env->numautos == MAX_AUTO_PTR) 498 if (env->numautos == MAX_AUTO_PTR)
497 runtime_error(env, "INTERNAL ERROR at %s:%d, please report", 499 runtime_error(env, "INTERNAL ERROR at %s:%d, please report",
498 __FILE__, __LINE__); 500 __FILE__, __LINE__);
501 /* Check if address is within the dataseg */
502 if (!(addr >= (char*) env->dataseg
503 && (addr < (char*) (env->dataseg + datasize + env->stack_size))))
504 ptr = NULL;
499 env->auto_ptr[env->numautos++] = ptr; 505 env->auto_ptr[env->numautos++] = ptr;
500} 506}
501 507
502/* Pop the last registered auto variable */ 508/* Pop the last registered auto variable */
503void 509static void
504env_pop_auto(eval_environ_t env) 510env_pop_auto(eval_environ_t env)
505{ 511{
506 env->numautos--; 512 env->numautos--;
507} 513}
508 514
509void 515static void
510env_unregister_autos(eval_environ_t env) 516env_unregister_autos(eval_environ_t env)
511{ 517{
512 env->numautos = 0; 518 env->numautos = 0;
513} 519}
514 520
515void 521static void
516env_fixup_autos(eval_environ_t env, ptrdiff_t offset) 522env_fixup_autos(eval_environ_t env, ptrdiff_t offset)
517{ 523{
518 int i; 524 int i;
519 for (i = 0; i < env->numautos; i++) { 525 for (i = 0; i < env->numautos; i++) {
520 STKVAL *pptr = env->auto_ptr[i]; 526 STKVAL *pptr = env->auto_ptr[i];
521 mf_c_val(*pptr,str) += offset; /*FIXME*/ 527 if (pptr)
528 mf_c_val(*pptr,str) += offset; /*FIXME*/
522 } 529 }
523} 530}
524 531
@@ -799,7 +806,7 @@ heap_obstack_grow(eval_environ_t env, void * MFL_DATASEG ptr, size_t size)
799 size_t words = B2STACK(size); 806 size_t words = B2STACK(size);
800 char *ret; 807 char *ret;
801 808
802 env_register_auto(env, ptr); 809 env_register_auto(env, (void*) &ptr);
803 if (env->tos - env->toh < words + B2STACK(env->temp_size)) 810 if (env->tos - env->toh < words + B2STACK(env->temp_size))
804 expand_dataseg(env, words, 811 expand_dataseg(env, words,
805 _("memory chunk too big to fit into heap")); 812 _("memory chunk too big to fit into heap"));
@@ -829,7 +836,7 @@ pushs(eval_environ_t env, const char * MFL_DATASEG s)
829{ 836{
830 size_t off; 837 size_t off;
831 838
832 env_register_auto(env, (void*) s); 839 env_register_auto(env, (void*) &s);
833 off = heap_reserve(env, strlen(s) + 1); 840 off = heap_reserve(env, strlen(s) + 1);
834 strcpy((char*) env_data_ref(env, off), s); 841 strcpy((char*) env_data_ref(env, off), s);
835 env_pop_auto(env); 842 env_pop_auto(env);

Return to:

Send suggestions and report system problems to the System administrator.