On Tuesday, January 28, 2020 at 12:45:41 PM UTC-8, Sam Hathaway wrote:
>
> There are two tasks I end up doing manually in C a lot and I’d like to not.
>
> Thing one: putting guards around header files.
>
>  

> [snip]
>
 

> Thing two: maintaining function prototypes in header files.
>

[snip] 

Look at the "Filters and Scripts" section of BBEdit's User Manual.  Amongst 
other environment variables, BBEdit sets BB_DOC_NAME and BB_DOC_PATH. With 
those you can easily check for the existence of the counterpart header and 
if it doesn't exist create one with the appropriate include file guards.

If it was me, I would use Perl for the scripting language since that allows 
you to use the same regular expression as you would use in BBEdit to search 
for C function headers in your .c file(s). How easily that will be depends 
largely upon how clean or ugly you write C code. (Without testing it, I 
think you can reject static function headings using a negative 
lookahead/lookbehind on static in the function heading.) I don't know if it 
is still the case, but BBEdit at one time shipped with a C function header 
grep pattern in the find/search dialogs.  You could use that as a starting 
point to work up to a regular expression that will find just the function 
headings in a .c file that you need/want to generation function prototypes 
for. 

I also wouldn't get too fancy with the prototype updating. Todays machines 
have cycles to spare so just regenerate the whole header contents anew, 
compare old with new, and then replace the old with the new if there is a 
difference between the two. Exactly how fine grained the replacing needs to 
be depends upon how you structure your header files and what else (e.g., 
comments and other non-function declarations) you put in the files. 

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/d5940b6f-2260-4d5e-8ae1-be49f25a9846%40googlegroups.com.

Reply via email to