Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Canon

Tool

SYNTAX

Canon dictionaryFile [inputFile1] [inputFile2]… [-a] [-c n] [-s]

DESCRIPTION

The Canon tool copies the specified files to standard output, replacing their identifiers with those listed in dictionaryFile. This allows you to easily change the spelling or case of identifiers that appear in your input files, making them uniform throughout.

INPUT

Standard input, unless you specify input files (inputFile…).

OUTPUT

Standard output. After processing, Canon writes the input files with the corrected spellings to standard output.

STATUS

Canon can return the following status codes:

0

no errors

1

syntax error

2

other errors

PARAMETERS

dictionaryFile

Specifies the identifiers to be replaced and gives their canonical spellings.

For each line in the dictionary you may specify either a pair of identifiers or a single identifier. If you specify two identifiers, the first represents the identifier to replace, and the second its canonical spelling. For example, the dictionary entry

NIL  NULL  # change NIL to NULL

changes each occurrence of NIL to NULL.

If you specify a single identifier, the identifier represents both the identifier to match and its canonical spelling. You can use this form only to change the case of an identifier. This is because pattern matching is normally not case sensitive and therefore all characters in an identifier are significant.

For example, the dictionary entry

true

changes all occurrences of TRUE, True, tRUE, and so on to true.

You can specify a left context for the first identifier on each line of the dictionary by preceding it with a sequence of nonidentifier characters. Replacement then occurs only if the left context in the input file exactly matches the left context in the dictionary.

For example, if the C structure component upperLeft should be replaced with topLeft, the dictionary might include the following:

upperLeft  topLeft
->upperLeft  topLeft

Note that you can include comments in the dictionary file by using the # symbol. The Canon tool ignores everything from the right of it to the end of the line.

The maximum line length for the dictionary file is 256 characters.

inputFile1 [inputFile2]…

Specifies the files you want Canon to process.

OPTIONS

-a

Causes the characters $, %, and @ to be considered letters (for the purpose of defining identifiers). Normally, MPW defines identifiers as a letter followed by any number of letters (including underscore characters) and digits. The -a option extends this definition, allowing you to match characters for identifiers in assembly-language sources.

-c n

Considers only the first n characters of an identifier to be significant. Normally Canon considers all characters to be significant.

-s

Uses case-sensitive matching. Normally pattern matching is not case sensitive.

EXAMPLES

The following command line copies the file Source.c to the Temp file after having replaced identifiers whose first eight characters match a dictionary entry with that entry. The -c 8 option is useful when porting source code from other systems that consider only the first eight characters to be significant.

Canon -c 8 "{MPW}"Tools:Canon.Dict Source.c > Temp

Note that you can find the file Canon.Dict from the above example in the Tools folder. It contains a list of all the identifiers used in the Standard C Library and the Inside Macintosh C interfaces.

You can use the Canon.Dict file when correcting the spelling of identifiers in C source files. You can also use it to port Pascal programs from other systems, as long as you use the canonical capitalizations for the Standard C Library identifiers.

LIMITATIONS

The Canon tool allows a maximum line length of 256 characters in the dictionary file.

Canon replaces identifiers in the comment sections of input files.

 
 


Last Updated July 2000