Polyglot unmasked

Wednesday 16 June 2004This is more than 20 years old. Be careful.

I added PostScript support to SilverCity. Now I can show my polyglot code in a new way.

Here’s the code labelled as C code:

/* % Dual program: C or PostScript!
   % Ned Batchelder
   %
{pop}/,{}/={}/"{}/+{}/;{pop}/-{moveto}/printf{show}/return{showpage}9{def}repeat
   ( */
# include <stdio.h>
# include <string.h>
/* ) */char count , def = 0 ;
/* */main()
{
    char * /* */Courier = " findfont " + 36 , scalefont = 0 ;
    char * setfont = "(Hello, world!)" + 0 * 100 + 0 * 100 - 0 ;

    printf("%.*s\n", strlen(setfont)-2, setfont+1);
    return ;
}

char * exec ;

And here it is labelled as PostScript:

/* % Dual program: C or PostScript!
   % Ned Batchelder
   %
{pop}/,{}/={}/"{}/+{}/;{pop}/-{moveto}/printf{show}/return{showpage}9{def}repeat
   ( */
# include <stdio.h>
# include <string.h>
/* ) */char count , def = 0 ;
/* */main()
{
    char * /* */Courier = " findfont " + 36 , scalefont = 0 ;
    char * setfont = "(Hello, world!)" + 0 * 100 + 0 * 100 - 0 ;

    printf("%.*s\n", strlen(setfont)-2, setfont+1);
    return ;
}

char * exec ;

OK, now I’ll shut up about the syntax coloring!

Comments

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.