#!/bin/sed # This script preprocesses some forth source code which is # in the os.asm assembly file. Because nasm doesn't seem to have # any multiline 'db' or 'dw' syntax, I use sed to put "db '" around # each line of source code. /code{ *$/,/}code *$/ { # ignore lines starting with "times" in code blocks # 't' jumps to end of script. s/^ *times/times/;t; # ignore lines ending with index labels s/\.so: *$/.so:/;t; /^ *$/d; /^ *;/d; /code{/d; /}code/d; # need to 'escape' double quotes s/"/",'"',"/g; s/^ */db " /; # put newline on the end of each line #s/ *$/ "/ # what happens if we use unix line endings \n, not \r # s/ *$/ ",13,10/ # move to this soon, unix s/ *$/ ",10/ }