home *** CD-ROM | disk | FTP | other *** search
- Customising and extending mkdrawf
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- The simplest way to customise mkdrawf is to #define some of the symbols
- described at the start of mkdrawf.c, and recompile. The consequences of
- these things are described at the start of that file, so I shan't go into
- details here.
-
- If you make any other changes, YOU MAY NOT DISTRIBUTE THE RESULTING PROGRAM
- IN ANY FORM without first checking with me. I am very anxious that there be
- coherence among versions of mkdrawf; I am also anxious that I should not
- get the credit for your clever code, nor the blame for your bad code. If
- you come up with improvements to mkdrawf, please let me know; they may well
- get into the standard distribution.
-
- Both as a matter of good programming practice and to improve the chances
- of my being happy with your changes, you should arrange for any changes
- you make (apart from bugfixes!) to be selectable at compile time with #ifdef.
- If you're careful about how you arrange things, it should be possible to do
- this without mkdrawf.c becoming a solid mass of preprocessor directives.
-
- To add a new operator, you need to:
- - add an entry for it in the |enum| typedef'ed to |spec_type|. The
- convention used for names should be clear.
- - add an |insert_spec()| call to the |init_global_hash()| function,
- to put the operator's name into the hash table. Remember to put
- the name in lower case.
- - add a case in |read_x_token()| to make it do the right thing.
- It is safe to read more tokens here, using |read_token()| (if
- you don't want expansion) or |read_x_token()| (if you do want
- expansion, which you almost certainly do). When you're done,
- you should fill in |the_token| (both fields) if the expansion
- is a single token; or |goto foo;| if the expansion is empty;
- or contruct a token list and start reading that, if the expansion
- is several tokens. This last option is hairier than the others.
-
- Please be careful about memory management. It is seldom possible
- to free anything; the point is that tokens can find their way into
- macro definitions and loops and things, so you can't free anything
- that might find its way into a token. This is a real mess, and
- eventually I might sort it out, with reference counts or something.
- Until then, don't free anything unless you know you're safe. Search
- mkdrawf.c for "free(" to get some idea of when it is safe to free
- things. Oh, and if you *do* free anything, call |xfree()| not |free()|;
- when memory-use debugging is compiled in this displays useful messages.
-
- It would be helpful if you could adhere to my layout style (very little
- whitespace, substantial comments before blocks of code, short comments
- for obscure code); but I know how hard I find it conforming to others'
- conventions, and it wouldn't really be fair to insist that you conform
- to mine.
-
- If you do make changes and they do make it into the "official" version
- of mkdrawf, you will be credited with the code that's yours. Copyright
- for the program as a whole, though, remains mine; I make no claims on
- anyone else's code, but the restrictions on what's done with my code
- remain.
-