From:	MERC::"uunet!WKUVX1.BITNET!MacroMan" 24-APR-1992 00:56:23.66
To:	<raxco!galaxy.dnet!gleeve@UUNET.UU.NET>
CC:	
Subj:	Re: BLISS vs. C: Which is the better language for VMS?

In article <1992Apr22.185038.1105@sunic.sunet.se> eric@sejnet.sunet.se writes:
> string, and it does solve the problem, except that it's a pain to type
> duh('text') all the time rather than just the text, and it wastes CPU time.

So write a preprocessor that converts `text` into "\004\000text". Of course
it needs to properly adjust to hardware configuration. How about:

%{
#include <stdio.h>
#include <ctype.h>
#ifdef M_XENIX
#define UCHAR char
typedef int size_t;
#else
#include <sys/types.h>
#define UCHAR unsigned char
#endif
char buffer[BUFSIZ] = "";
%}
%%
`[^\n`]*`       { strcat(buffer, yytext+1);
                }
.              { if(buffer[0]) {
                        outstr(buffer);
                        buffer[0] = 0;
                  }
                  ECHO;
                }
\n              { if(buffer[0]) {
                        outstr(buffer);
                        buffer[0] = 0;
                  }
                  ECHO;
                }
%%
outstr(buffer)
char *buffer;
{
        size_t len;
        UCHAR *foo;
        int i;

        len = 0;
        for(i = 0; buffer[i]; i++) {
                len++;
                switch(buffer[i]) {
                        case '\\':
                                if(strchr("abfnrt\\", buffer[i+1]))
                                        i++;
                                else if(isdigit(buffer[i+1])) {
                                        int j;
                                        for(j = 0; j < 3; j++)
                                                if(isdigit(buffer[i+1]))
                                                        i++;
                                                else
                                                        break;
                                }
                                break;
                        case '`':
                                if(!buffer[i+1]) {
                                        buffer[i] = 0;
                                        i--;
                                        len--;
                                }
                                break;
                }
        }

        putchar('"');
        /* Type punning! */
        foo = &len;
        for(i = 0; i < sizeof len; i++)
                printf("\\%03o", foo[i]);
        while(*buffer) {
                switch(*buffer) {
                        case '"':
                                putchar('\\');
                        default:
                                putchar(*buffer);
                }
                buffer++;
        }
        putchar('"');
}
--
Peter da Silva                                                      `-_-'
Programmer, network firefighter, thrillseeker                        'U`
Ferranti International Controls Corporation                    Have you hugged
Sugar Land, TX  77487-5012    +1 713 274 5180                  your wolf today?
