Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site boring.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!genrad!panda!talcott!harvard!seismo!mcvax!boring!guido From: guido@boring.UUCP Newsgroups: net.sources.mac Subject: Re: New SUMacC rmaker.shar Message-ID: <6500@boring.UUCP> Date: Thu, 11-Jul-85 14:46:21 EDT Article-I.D.: boring.6500 Posted: Thu Jul 11 14:46:21 1985 Date-Received: Wed, 17-Jul-85 03:29:53 EDT References: <2287@ut-sally.UUCP> Reply-To: guido@mcvax.UUCP (Guido van Rossum) Distribution: net Organization: "Stamp Out BASIC" Committee, CWI, Amsterdam Lines: 363 Keywords: SUMacC, rmaker, compatibility Summary: Use hex escapes instead of C-like ones; POST = STR#; etc. Apparently-To: rnews@mcvax.LOCAL Here are some changes to the improved rmaker source that was posted last week by Brian Powell. Immediately after I received his version I communicated a compatibility problem with the \ escapes, and got his consent to post my version. There are some more changes to be found in this diff listing (see below for a detailed account). Brian and I hope this posting makes it in time to most of the rmaker hackers to prevent proliferation of different versions again. (Readers of net.micro.mac may remember my plea for compatibility in The Case Of The Harmonic Series Benchmarks :-). I also sent a copy to Croft -- hope he agrees too. Guido van Rossum, CWI, Amsterdam (the capital of Copenhagen :-) guido@mcvax.UUCP --------------------------------------------------------------------------- A detailed account of the changes: - \ escapes. Inside Mac documents only the following form of \ escapes: \XX where XX are two hexadecimal digits. I (and Brian) thought it better to stick to this convention rather than use some fancy incompatible scheme. (After all, it rarely is necessary to include hex codes at all.) IM doesn't document the effect of \ followed by garbage. I chose for letting the backslash in the string, except that \\ is replaced by a single \. - POST is now identical to STR#. Brian asked me to put this change in, because he had found out that blank lines really aren't necessary (I have no expertise in this field). - Finally, I added a mod which makes it easier to change the values of CRTLEN and RELLEN (CRTMAGIC and RELMAGIC are automatically adjusted). I once needed this to process a huge binary (~200 kbytes) Just recompile rmaker.c with -DCRTLEN=20 and use a version of crtmac.s with 20 long zeros instead of 10. Here are the diffs -- use patch to process. --------------------------------------------------------------------------- *** posted-rmaker.c Wed Jul 10 11:00:26 1985 --- rmaker.c Thu Jul 11 10:59:49 1985 *************** *** 36,41 * 06/29/85 Powell Added PROC. * 07/06/85 Powell Fix tolower bug in backslash code. Limit \ooo to three digits, \xhh to two. */ #include--- 36,47 ----- * 06/29/85 Powell Added PROC. * 07/06/85 Powell Fix tolower bug in backslash code. Limit \ooo to three digits, \xhh to two. + *** Branch 4 + * 07/09/85 GvR Allow CRTLEN and RELLEN to be overridden + * on compilation with -D; made CRTMAGIC and + * RELMAGIC self-adjusting; changed \ escapes + * to hex (as in Inside Mac). + * 11/09/85 GvR Changed POST to be identical to STR#. */ #include *************** *** 39,45 */ #include - #include #include #include #include --- 45,50 ----- */ #include #include #include #include *************** *** 60,66 }; /* "standard" segment 0 jump header/table */ char seg1[sizeof(struct codehead)] = { 0,0, 0,1 }; ! #define CRTMAGIC 0x602C /* jump at beginning of crtmac.s */ #define CRTLEN 10 /* length of relocation table in crtmac.s */ #define RELMAGIC 0x6034 /* jump at beginning of crt*.s */ #define RELLEN 12 /* length of relocation table in crt*.s */ --- 65,71 ----- }; /* "standard" segment 0 jump header/table */ char seg1[sizeof(struct codehead)] = { 0,0, 0,1 }; ! #ifndef CRTLEN #define CRTLEN 10 /* length of relocation table in crtmac.s */ #endif CRTLEN *************** *** 62,68 #define CRTMAGIC 0x602C /* jump at beginning of crtmac.s */ #define CRTLEN 10 /* length of relocation table in crtmac.s */ ! #define RELMAGIC 0x6034 /* jump at beginning of crt*.s */ #define RELLEN 12 /* length of relocation table in crt*.s */ #define NRESCOMP 50 /* max number of resources per compile */ --- 67,77 ----- #ifndef CRTLEN #define CRTLEN 10 /* length of relocation table in crtmac.s */ ! #endif CRTLEN ! ! #define CRTMAGIC (0x6004+4*CRTLEN) /* jump at beginning of crtmac.s */ ! ! #ifndef RELLEN #define RELLEN 12 /* length of relocation table in crt*.s */ #endif *************** *** 64,69 #define CRTLEN 10 /* length of relocation table in crtmac.s */ #define RELMAGIC 0x6034 /* jump at beginning of crt*.s */ #define RELLEN 12 /* length of relocation table in crt*.s */ #define NRESCOMP 50 /* max number of resources per compile */ --- 73,79 ----- #ifndef RELLEN #define RELLEN 12 /* length of relocation table in crt*.s */ + #endif #define RELMAGIC (0x6004+4*RELLEN) /* jump at beginning of crt*.s */ *************** *** 65,70 #define RELMAGIC 0x6034 /* jump at beginning of crt*.s */ #define RELLEN 12 /* length of relocation table in crt*.s */ #define NRESCOMP 50 /* max number of resources per compile */ struct rescomp { /* resource being compiled */ --- 75,82 ----- #define RELLEN 12 /* length of relocation table in crt*.s */ #endif + #define RELMAGIC (0x6004+4*RELLEN) /* jump at beginning of crt*.s */ + #define NRESCOMP 50 /* max number of resources per compile */ struct rescomp { /* resource being compiled */ *************** *** 137,143 "CDEF", handproc, "MDEF", handproc, "WDEF", handproc, ! "POST", handpost, "FKEY", handproc, "PROC", handproc, 0, 0 --- 149,155 ----- "CDEF", handproc, "MDEF", handproc, "WDEF", handproc, ! "POST", handstrl, "FKEY", handproc, "PROC", handproc, 0, 0 *************** *** 493,537 int i; for (datap++, len = 0 ; *sp ; len++) { ! if ((c = *sp++) != '\\') { ! *datap++ = c; ! continue; ! } ! switch (c = *sp++) { ! default: ! *datap++ = c; ! continue; ! case 'b': ! *datap++ = '\b'; ! continue; ! case 'f': ! *datap++ = '\f'; ! continue; ! case 'n': ! *datap++ = '\n'; ! continue; ! case 'r': ! *datap++ = '\r'; ! continue; ! case 't': ! *datap++ = '\t'; ! continue; ! case '0': ! case '1': ! case '2': ! case '3': ! case '4': ! case '5': ! case '6': ! case '7': /* octal constant */ ! *datap = c - '0'; /* stop after */ ! for (i = 2 ; i <= 3 ; i++) { /* three digits */ ! if ((c = *sp) < '0' || c > '7') /* or */ ! break; /* non-octal digit */ ! c -= '0'; ! *datap <<= 3; ! *datap |= (c & 0x7); ! *++sp; } datap++; break; --- 505,518 ----- int i; for (datap++, len = 0 ; *sp ; len++) { ! /* \XX where XX are two hex digits emits ASCII code XX; ! \\ emits a single backslash; ! \ followed by garbage emits the \ and the garbage. */ ! if (*sp == '\\') { ! if (ishex(sp[1]) && ishex(sp[2])) { ! *datap++ = tohex(sp[1])*16 + tohex(sp[2]); ! sp += 3; ! continue; } /* else */ if (sp[1] == '\\') ++sp; *************** *** 533,557 *datap |= (c & 0x7); *++sp; } ! datap++; ! break; ! case 'x': /* hex constant */ ! *datap = 0; ! for (i = 1 ; i <= 2; i++) { /* stop after two */ ! c = *sp; /* digits or */ ! if (!isxdigit (c)) /* non-hex digit */ ! break; ! else if (isdigit(c)) ! c -= '0'; ! else ! c -= isupper(c) ? 'A' - 10 : 'a' - 10; ! *datap <<= 4; ! *datap |= (c & 0xf); ! *++sp; ! } ! datap++; ! break; ! } } *cp = len; len++; --- 514,523 ----- sp += 3; continue; } ! /* else */ if (sp[1] == '\\') ! ++sp; ! } ! *datap++ = *sp++; } *cp = len; len++; *************** *** 562,567 return (len); } /* * Scan next number from line and return it. --- 528,539 ----- return (len); } + ishex(c) + char c; + { + return c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || + c >= 'a' && c <= 'f'; + } tohex(c) char c; *************** *** 563,568 } /* * Scan next number from line and return it. */ --- 535,549 ----- c >= 'a' && c <= 'f'; } + tohex(c) + char c; + { + if (c >= 'a') return c - 'a' + 10; + if (c >= 'A') return c - 'A' + 10; + return c - '0'; + } + + /* * Scan next number from line and return it. */ *************** *** 1329,1358 /* end of items */ *datap++ = 0; *flagsp = htonl(flags); - } - - - /* - * Handle postscript strings ("Laser Prep" file). - * First line is number of lines that follow. - * Each following line is a string. - */ - handpost() - { - int count; - int nbytes; - - if (getline() == 0) /* get string count */ - abort("missing string in POST"); - sscanf(lp, "%d", &count); - *datap++ = count >> 8; - *datap++ = count & 0xff; - while (count--) { - getline(); - datastring(lp,0); - } - /* Pad whole resource if odd byte count (is this necessary?) */ - nbytes = datap - data; - if (nbytes & 1) - *datap++ = '\0'; } --- 1310,1313 ----- /* end of items */ *datap++ = 0; *flagsp = htonl(flags); }