[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Dec 5 16:55:46 1992 
Subject:Does PRINTF *really* call SYS_SYSPR? 
From:Luc Beaudoin 
Volume-ID:921205.04 

Hi all,

Today's question is: If the two characters,37and 80, i.e., %P, occur
successively in the string that PRINTF takes as a first or second argument,
does PRINTF *really* call SYS_SYSPR to print the corresponding item from the
stack (or the list). I've performed a couple of tests which suggest that it
doesn't. One of these tests was to trace sys_syspr in the following context:

    sysunprotect("sys_syspr");
    trace sys_syspr;
    sysprotect("sys_syspr");

;;;And the test:
: 3, printf('%P');
3:

Hmmm, no trace of SYS_SYSPR.

The context in which I discovered this was to try to assign PR to
SYS_SYSPR, to affect PRINTF's behaviour. In the following example, I
assign SQRT to SYS_SYSPR, which should cause PRINTF to mishap if given a
'%P' which collects a non number from the stack.

  sysunprotect("sys_syspr"); ;;;required for the compilation of PRR

  define prr() with_nargs 1;
      lvars SYS_SYSPR = sys_syspr;
      sysunprotect("sys_syspr");
      sqrt -> sys_syspr; ;;;This assignment works, but doesn't affect printf
      printf();
      SYS_SYSPR -> sys_syspr;
      sysprotect("sys_syspr");
  enddefine;

 sysprotect("sys_syspr");

/* However when we test PRR, in the obvious way, it doesn't fail!*/

"foo",prr('%P');
 foo

Is it the case that I should recompile printf in order to see the
change? But I don't see why that should be necessary, since if, instead
of modifying SYS_SYSPR within PRR, we assign SQRT to PR, which is
invoked by PRINTF when its argument string contains '%p', we get a
mishap when expected:

    sysunprotect("pr");

    define prr() with_nargs 1;
        lvars PR = pr;
        sysunprotect("pr");
        sqrt -> pr; ;;;This assignment works, but doesn't affect printf
        printf();
        PR -> pr;
        sysprotect("pr");
    enddefine;

    sysprotect("pr");

;;;causes SQRT to be applied to "foo"
: "foo",prr('%p');

 ;;; MISHAP - NUMBER NEEDED
 ;;; INVOLVING:
 ;;; MISHAP - NUMBER NEEDED
 ;;; INVOLVING:  foo
 ;;; DOING    :  sysprmishap mishap sqrt spr applist sysprmessage sysprmishap
      mishap sqrt appdata printf prr <false> sysEXECUTE pop11_exec_stmnt_seq_
     to sysCOMPILE pop11_comp_stream compile pop_setpop_compiler vedsetpop
      ved_im veddocommand veddocr runproc veddocr vedprocesschar vedprocess
      runproc vededitor pop11_comp_prec_expr ...

 Setpop

All this seems to suggest that PRINTF doesn't call SYS_SYSPR. Yet we
know that it doesn't call SYSPR, nor PR for printing with %P. If I'm
right, then, what does it call?

Thanks,

Luc
-- 
-------------------------------------- -----------------------------------
Luc Beaudoin                          |  School of Computer Science
E-mail: lpb@cs.bham.ac.uk             |  University of Birmingham
voice:  +44 (21) 414-4766 or 3743     |  Birmingham B15 2TT, UK