[TUHS] v7 source code for sh

Will Senn will.senn at gmail.com
Sun Feb 20 01:43:05 AEST 2022

I have been poring through the v7 source code lately, and came across an 
oddity I would like to know more about. Specifically, in sh. The code 
for sh is c, but it makes *extensive* use of of macros, for example:

    WHILE (c=nextc(0), space(c)) DONE

The macros for sh are defined in mac.h:

    #define BEGIN   {
    #define END     }
    #define SWITCH  switch(
    #define IN      ){
    #define ENDSW   }
    #define FOR     for(
    #define WHILE   while(
    #define DO      ){
    #define OD      ;}
    #define REP     do{
    #define PER     }while(
    #define DONE    );

I can read the resultant code through the lens of my experience coding 
c, but I'm curious why the macros and how this came about? In v6, the sh 
source is straight up c. Is there a story behind it worth knowing?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20220219/ff33b6ed/attachment.htm>

More information about the TUHS mailing list