Please disregard my previous email... I think I've fixed it. Here's a patch:
This patch fixes the following:
- "#else" directives are now tagged with the proper scope - "#define" for things that are not functions do not get tagged as functions - Functions defined in multiple lines are tagged as functions.
Thanks,
-Oscar
Index: Bundles/C.tmbundle/Syntaxes/C.plist =================================================================== --- Bundles/C.tmbundle/Syntaxes/C.plist (revision 2567) +++ Bundles/C.tmbundle/Syntaxes/C.plist (working copy) @@ -10,9 +10,9 @@ <key>firstLineMatch</key> <string>-[*]-( Mode:)? C -[*]-</string> <key>foldingStartMarker</key> - <string>/**(?!*)|{\s*($|//|/*(?!.*?*/.*\S))|^@(interface| protocol|implementation)\b</string> + <string>(/**|{\s*(/*.**/\s*|//.*)?$)</string> <key>foldingStopMarker</key> - <string>(?<!*)**/|^\s*}|^@end\b</string> + <string>(**/|^\s*})</string> <key>keyEquivalent</key> <string>~^C</string> <key>name</key> @@ -141,7 +141,7 @@ </dict> <dict> <key>begin</key> - <string>^\s*#\s*(define)\s+([a-zA-Z_][a-zA-Z0-9_]*)(?:(((?:\s*[a- zA-Z_][a-zA-Z0-9_]*\s*,?)*))|\b)</string> + <string>^\s*#\s*(define)\s+([a-zA-Z_][a-zA-Z0-9_]*)(?:(((?:\s*[a- zA-Z_][a-zA-Z0-9_]*\s*,?)*)))</string> <key>captures</key> <dict> <key>1</key> @@ -239,7 +239,7 @@ </dict> <dict> <key>begin</key> - <string>^\s*#\s*(defined|elif|else|if|ifdef|ifndef|line|pragma| undef)\b</string> + <string>^\s*#\s*(define|defined|elif|else|if|ifdef|ifndef|line| pragma|undef)\b</string> <key>captures</key> <dict> <key>1</key> @@ -294,9 +294,9 @@ ) ) ([A-Za-z_][A-Za-z0-9_:]+) # actual name - \s*( (?=[^)]*) # match "(" and use look- ahead for ")" + \s*( ((?=[^)]*) # match "(" and use look- ahead for ")" (\s+const)?\s* # optional const modifier - ({|\n)) # start bracket or end-of- line + ({|\n))|\n) # start bracket or end-of-line </string> <key>beginCaptures</key> <dict> @@ -319,39 +319,6 @@ </array> </dict> <dict> - <key>begin</key> - <string>(?x) - (?: ^ # begin-of-line - | (?: (?<!else|new) (?<=\w)\s+ # or word + space before name - | (?<!&&) (?<=[*&])\s* # or type modifier before name - ) - ) - ([A-Za-z_][A-Za-z0-9_:]+) # actual name - \s*( (?=[^)]*) # match "(" and use look- ahead for ")" - (\s+const)?\s* # optional const modifier - (;)) # start bracket or end-of- line - </string> - <key>beginCaptures</key> - <dict> - <key>1</key> - <dict> - <key>name</key> - <string>entity.name.function.c</string> - </dict> - </dict> - <key>end</key> - <string>)</string> - <key>name</key> - <string>declaration.function.prototype.c</string> - <key>patterns</key> - <array> - <dict> - <key>include</key> - <string>$base</string> - </dict> - </array> - </dict> - <dict> <key>include</key> <string>source.open-gl</string> </dict> @@ -554,7 +521,7 @@ <key>preprocessor-rule-other</key> <dict> <key>begin</key> - <string>^\s*(#\s*(if(n?def)?)\b.*(?:(?=(?://|/*))|$))</string> + <string>^\s*(#\s*(if(n?def)?)\b)</string> <key>captures</key> <dict> <key>1</key> @@ -584,7 +551,7 @@ <array> <dict> <key>match</key> - <string>\(\|[abefnprtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-zA-Z0-9]+) </string> + <string>\(\|[abefnrtv'"?]|[0-3]\d{,2}|[4-7]\d?|x[a-zA-Z0-9]+) </string> <key>name</key> <string>constant.character.escape.c</string> </dict>
-- pgp fingerprint: BC64 2E7A CAEF 39E1 9544 80CA F7D5 784D FB46 16C1
On 20/1/2006, at 0:18, Oscar Bonilla wrote:
Please disregard my previous email... I think I've fixed it. Here's a patch:
This patch fixes the following:
- "#else" directives are now tagged with the proper scope
I couldn't see anything in your patch affecting this, and it does not seem to be broken!?!
- "#define" for things that are not functions do not get tagged as
functions
I applied this.
- Functions defined in multiple lines are tagged as functions.
I wasn't comfortable with this patch -- your patch actually contained 7 changes to the C.plist, I think 4 of them reverting something to a prior version. As for the function markup, it seemed to also remove a large part of the syntax which ensure a storage type in front of the function name. Maybe intentional because you only have the function name on the line? But it would conflict with custom macros like “foreach(something)”.
Btw: Mail lose the leading space on lines when followed by a tab (because of how it uses WebKit and tries to workaround the WebKit whitespace stripping rules, but is not fully successful), so patches for files which use leading tabs gets mangled by Mail when pasted into the mail body, i.e. better to gzip them or similar (as long as Mail has this problem).
On Jan 25, 2006, at 2:29 PM, Allan Odgaard wrote:
On 20/1/2006, at 0:18, Oscar Bonilla wrote:
Please disregard my previous email... I think I've fixed it. Here's a patch:
This patch fixes the following:
- "#else" directives are now tagged with the proper scope
I couldn't see anything in your patch affecting this, and it does not seem to be broken!?!
That's because I based the patch on an old version of the file... duh!
- "#define" for things that are not functions do not get tagged as
functions
I applied this.
Thanks.
- Functions defined in multiple lines are tagged as functions.
I wasn't comfortable with this patch -- your patch actually contained 7 changes to the C.plist, I think 4 of them reverting something to a prior version. As for the function markup, it seemed to also remove a large part of the syntax which ensure a storage type in front of the function name. Maybe intentional because you only have the function name on the line? But it would conflict with custom macros like “foreach(something)”.
No. The problem occurred with an older version of the C syntax file that didn't seem to handle declarations such as:
void TclCompileExprWords(interp, tokenPtr, numWords, envPtr) Tcl_Interp *interp; /* Used for error and status reporting. */ Tcl_Token *tokenPtr; /* Points to first in an array of word tokens * tokens for the expression to compile * inline. */ int numWords; /* Number of word tokens starting at tokenPtr. * Must be at least 1. Each word token * contains one or more subtokens. */ CompileEnv *envPtr; /* Holds the resulting instructions. */ { }
It seems the new C.plist handles them. I just didn't have the latest version...
Btw: Mail lose the leading space on lines when followed by a tab (because of how it uses WebKit and tries to workaround the WebKit whitespace stripping rules, but is not fully successful), so patches for files which use leading tabs gets mangled by Mail when pasted into the mail body, i.e. better to gzip them or similar (as long as Mail has this problem).
Thanks for the tip, I'll keep it in mind.
Regards,
-Oscar
-- pgp fingerprint: BC64 2E7A CAEF 39E1 9544 80CA F7D5 784D FB46 16C1
On 25/01/2006, at 23:52, Oscar Bonilla wrote:
void TclCompileExprWords(interp, tokenPtr, numWords, envPtr) Tcl_Interp *interp; /* Used for error and status reporting. */ Tcl_Token *tokenPtr; /* Points to first in an array of word tokens * tokens for the expression to compile * inline. */ int numWords; /* Number of word tokens starting at tokenPtr. * Must be at least 1. Each word token * contains one or more subtokens. */ CompileEnv *envPtr; /* Holds the resulting instructions. */ { }
I thought K&R style prototypes are no longer legal in C?
-- Sune.
On 25 janv. 06, at 23:55, Sune Foldager wrote:
I thought K&R style prototypes are no longer legal in C?
K&R style, aka 'pre-standard traditional form' is listed as an obsolescent feature in C99, which just means that it *may* not be supported in the future.
As of today, the Ruby interpreter code still uses this style, for example.
On 26/01/2006, at 11:28, Luc Heinrich wrote:
K&R style, aka 'pre-standard traditional form' is listed as an obsolescent feature in C99, which just means that it *may* not be supported in the future. As of today, the Ruby interpreter code still uses this style, for example.
Yeah, I noticed... struck me as bit weird, but it gives a nice overview. Then again the same or better can be done with: void name( arg1 *blah, arg2 foo... )
-- Sune.