tpircher-zz / pycrc

Free, easy to use Cyclic Redundancy Check (CRC) calculator and source code generator
https://pycrc.org
MIT License
169 stars 36 forks source link

Fix Header Guard generation #21

Closed andre-hartmann closed 7 years ago

andre-hartmann commented 7 years ago

All symbols that start with one underscore followed by uppercase letter, or all symbols that contain two underscores are reserved for the compiler and the standard library. They should not be used in user code.

andre-hartmann commented 7 years ago

Hi, pycrc is a very nice product.

I only have one small adoption to the header generation. Please see e.g. https://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier for more information.

tpircher-zz commented 7 years ago

...if you return 'PYCRC_' + out_str, then the line filename = 'pycrc_stdout' should be changed to filename = 'stdout'

Sorry for the feature creep. :)

andre-hartmann commented 7 years ago

Hi Thomas, you have a good point here.

But instead of adding something to the front, the pure filename should be used IMHO. E.g. /path/to/file.h should result in FILE_H, not in _PATH_TO_FILE_H

I have to admit, that my Python knowlegde is rather limited, but I'll have a second look later.

tpircher-zz commented 7 years ago

That's my mistake, apologies... _pretty_hdrprotection() uses os.path.basename(), which returns the name of the file, not the whole path. So your change is absolutely fine, but I would still like having the comment updated, i.e. change (e.g. __CRC_IMPLEMENTATION_H__) to (e.g. CRC_IMPLEMENTATION_H)

Thanks for using and contributing to pycrc!

andre-hartmann commented 7 years ago

I've amended my master branch... Anything else I need to do to update the merge request?

tpircher-zz commented 7 years ago

Nope, GitHub has updated the pull request automatically. I's all merged and submitted. Thanks!