Skip to content

Instantly share code, notes, and snippets.

@yuvalif
Last active July 24, 2018 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuvalif/d8c6ab4c5c40da0555f2d1440743dc02 to your computer and use it in GitHub Desktop.
Save yuvalif/d8c6ab4c5c40da0555f2d1440743dc02 to your computer and use it in GitHub Desktop.
some preparations for converting a matlab/octave file to cpp
# fix comments
sed -i 's/%/\/\//g' $1
# fix "end"
sed -i 's/end/}/g' $1
# fix "3 dots"
sed -i 's/\.\.\.//g' $1
# fix "elseif"
sed -i 's/elseif/}\nelse if/g' $1
# fix "else"
sed -i 's/else/}\nelse\n{/g' $1
# fix "error()"
sed -i 's/error(/assert(/g' $1
# remove trailing spaces
sed -i 's/[ \t]*$//' $1
# modify brackets of array my_arr
# sed -E 's/my_arr\(([^()]*)\)/my_arr[\1]/g' $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment