[OpenBIOS] ping [PATCH] bootinfo_load.c: Translate \r to \n for Mac OS 9 compatibility
Programmingkid
programmingkidx at gmail.com
Fri Apr 15 18:47:06 CEST 2016
On Apr 15, 2016, at 12:20 PM, Mark Cave-Ayland wrote:
> On 15/04/16 17:05, Programmingkid wrote:
>
>>> Can you demonstrate how the patch breaks down the OS 9 loader into
>>> sections terminated by LF so we can see the individual chunks that are
>>> passed to "interpret". With this it is possible to get a good
>>> understanding as to how the patch works and determine how it will affect
>>> other OSs.
>>
>> Why do you think the loader terminates sections by Line Feed? Did you mean New Line?
>
> Simply extract the OS 9 bootloader and break it into individual sections
> terminated by either a CR/LF so we can see how bootinfo_load.c segments
> its calls into the Forth interpreter.
So you want something like this:
#include <stdio.h>
#include <string.h>
void print_words(char c)
{
static char buffer[100] = "";
static int index = 0;
static int word_count = 0;
// if whitespace is detected
if(c == '\r' || c == '\n' || c == ' ') {
word_count++;
buffer[index] = '\0';
printf("Word %d: %10s \tsize: %d\n", word_count, buffer, strlen(buffer));
index = 0;
return;
}
buffer[index] = c;
index++;
}
int main (int argc, const char * argv[]) {
char mystring[100] = "The quick brown fox jumps over the lazy dog";
mystring[3] = '\r';
mystring[9] = '\n';
for (int i = 0; i < strlen(mystring); i++) {
print_words(mystring[i]);
}
return 0;
}
Output:
Word 1: The size: 3
Word 2: quick size: 5
Word 3: brown size: 5
Word 4: fox size: 3
Word 5: jumps size: 5
Word 6: over size: 4
Word 7: the size: 3
Word 8: lazy size: 4
I will implement this into OpenBIOS if this is what you want.
More information about the OpenBIOS
mailing list