<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div><br>On Apr 12, 2018, at 1:57 AM, Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de">marcel.taeumel@hpi.de</a>> wrote:<br><br></div><blockquote type="cite"><div><span></span></div></blockquote><blockquote type="cite"><div><div id="__MailbirdStyleContent" style="font-size: 12pt;font-family: calibri;color: #000000">
                                        
                                        
                                            
                                        
                                        
                                        What about this style:<div><br></div><div>'void main({1}) \{ return 1; \}' <span style="font-size: 12pt;line-height: 1.5">format: {'char* args'}.</span></div></div></div></blockquote><div><br></div>+1.  Exactly.<div><br></div><div><br><blockquote type="cite"><div><div id="__MailbirdStyleContent" style="font-size: 12pt;font-family: calibri;color: #000000"><div>Best,</div><div>Marcel</div><div class="mb_sig"></div>
                                        
                                        <blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 11.04.2018 20:49:12 schrieb Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>>:</p> <br>Hi David, Subbu,<br><br>    forgive me...<br><br>> On Apr 11, 2018, at 4:54 AM, <a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a> wrote:<br>> <br>> <br>> David T. Lewis uploaded a new version of ImageFormat to project VM Maker:<br>> <a href="http://source.squeak.org/VMMaker/ImageFormat-dtl.29.mcz">http://source.squeak.org/VMMaker/ImageFormat-dtl.29.mcz</a><br>> <br>> ==================== Summary ====================<br>> <br>> Name: ImageFormat-dtl.29<br>> Author: dtl<br>> Time: 11 April 2018, 8:54:16.07 am<br>> UUID: ea0c2ff3-c413-4917-a6fb-8177e5a2ebec<br>> Ancestors: ImageFormat-dtl.28<br>> <br>> Fix by K K Subbu: Use memcmp instead of strncmp in ckformat to compare byte arrays.<br>> <br>> =============== Diff against ImageFormat-dtl.28 ===============<br>> <br>> Item was changed:<br>>  ----- Method: ImageFormat class>>generateCkFormatProgram:on: (in category 'ckformat') -----<br>>  generateCkFormatProgram: programName on: stream<br>>      "Generate source code for an image format version reader. The program<br>>      is intended for testing image file format from a unix shell script such that<br>>      the shell script can decide what VM to run based on image requirements."<br>> <br>>      | formatNumber |<br>>      stream nextPutAll: '/* ', programName, ': Print the image format number on standard output */'; cr;<br>>              nextPutAll: '/* for use in a shell script to test image format requirements. */'; cr;<br>>              nextPutAll: '/* A non-zero return status code indicates failure. */'; cr; cr;<br>>              nextPutAll: '/* Usage: ', programName, ' imageFileName */'; cr; cr;<br>>              nextPutAll: '/* --- DO NOT EDIT THIS FILE --- */'; cr;<br>>              nextPutAll: '/* --- Automatically generated from class ', self name, ' ', DateAndTime now asString, '--- */'; cr;<br>>              nextPutAll: '/* --- Source code is in package ImageFormat in the VMMaker repository --- */'; cr;<br>>              nextPutAll: '/* --- DO NOT EDIT THIS FILE --- */'; cr; cr;<br>>              nextPutAll: '#include <stdio.h>'; cr;<br>>              nextPutAll: '#include <stdlib.h>'; cr;<br>>              nextPutAll: '#include <string.h>'; cr; cr;<br>>              nextPutAll: 'main(int argc, char **argv) {'; cr;<br>>              tab; nextPutAll: 'FILE *f;'; cr;<br>>              tab; nextPutAll: 'unsigned char buf[8];'; cr;        <br>>              tab; nextPutAll: 'int formatNumber;'; cr;        <br>>              tab; nextPutAll: 'unsigned char c;'; cr;        <br>>              tab; nextPutAll: 'int match;'; cr;        <br>>              tab; nextPutAll: 'if (argc !!= 2) {'; cr;<br>>              tab; tab; nextPutAll: 'printf("usage: ', programName,  ' imageFileName\n");'; cr;<br>>              tab; tab; nextPutAll: 'exit(1);'; cr;<br>>              tab; nextPutAll: '}'; cr;<br>>              tab; nextPutAll: 'f = fopen(argv[1], "r");'; cr;<br>>              tab; nextPutAll: 'if (f == NULL) {'; cr;<br>>              tab; tab; nextPutAll: 'perror(argv[1]);'; cr;<br>>              tab; tab; nextPutAll: 'exit(2);'; cr;<br>>              tab; nextPutAll: '}'; cr.<br>>      { 0. 512 } do: [:offset |<br>>          stream<br>>              tab; nextPutAll: 'if(fseek(f, '; nextPutAll: offset asString; nextPutAll: 'L, SEEK_SET) !!= 0) {';cr;<br>>              tab; tab; nextPutAll: 'fprintf(stderr, "cannot go to pos %d in %s\n", '; nextPutAll: offset asString; nextPutAll: ', argv[1]);'; cr;<br>>              tab; tab; nextPutAll: 'exit(3);'; cr;<br>>              tab; nextPutAll: '}'; cr;<br>>              tab; nextPutAll: 'if (fread(buf, 1, 8, f) < 8)="" {';=""><br>>              tab; tab; nextPutAll: 'fprintf(stderr, "cannot read %s\n", argv[1]);'; cr;<br>>              tab; tab; nextPutAll: 'exit(3);'; cr;<br>>              tab; nextPutAll: '}'; cr.<br>>          self versionNumberByteArrays withIndexDo: [ :v :tag | | b |<br>>              formatNumber := (self fromBytes: v) asInteger.<br>>              b := 'b_', formatNumber asString, '_', tag asString.<br>>              stream tab; nextPutAll: '{'; cr; tab; nextPutAll: 'unsigned char ', b, '[', v size asString, ']= { '.<br>>              v inject: true into: [:first : elem |<br>>                  first ifFalse: [stream nextPutAll: ', '].<br>>                  stream nextPutAll: elem asString.<br>>                  false].<br>>              stream nextPutAll: '};'; cr;<br>> +                    tab; nextPutAll: 'if (memcmp(buf, ', b, ', ', v size asString, ') == 0) {'; cr;<br>> -                    tab; nextPutAll: 'if (strncmp(buf, ', b, ', ', v size asString, ') == 0) {'; cr;<br>>                      tab; tab; nextPutAll: 'printf("%d\n", ', formatNumber, ');'; cr;<br>>                      tab; tab; nextPutAll: 'exit(0);'; cr;<br>>                      tab; nextPutAll: '}'; cr; tab; nextPutAll: '}'; cr]].<br>>      stream tab; nextPutAll: 'printf("0\n"); /* print an invalid format number */';cr;<br>>              tab; nextPutAll: 'exit (-1); /* not found, exit with error code */'; cr;<br>>              nextPutAll: '}'; cr<br>>  !<br><br>This is unreadable.  Either express it as a string or as a Slang program; anything but this horrid mashup of nextPutAll:s and C fragments :-(</string.h></stdlib.h></stdio.h>
                        </blockquote></div></div></blockquote></div></body></html>