nanochess / pretty6502

A pretty printer for 6502, Z80, CP1610, TMS9900, and 8088 assembler code
BSD 2-Clause "Simplified" License
34 stars 4 forks source link

Tip on not clobbering source and destination files #2

Closed robertlipe closed 6 years ago

robertlipe commented 6 years ago

https://github.com/nanochess/pretty6502/blob/192644256c104e5eee72d7c2e98bfff19629dcab/pretty6502.c#L87

Rather than relying on users to not do something dumb, consider calling realpath() on the two arguments that can be file names. realpath() returns a canonical, simplified version of the paths, so it'll detect the difference of foo.asm and ../src/foo.asm or "foo.asm" and "./foo.asm". Iff the strings returned by realpath differ, you know they're two different file names.

Again, just a tip.

nanochess commented 6 years ago

Thanks for the suggestion.