BCPP C/C++ Code Beautifier V1.9

Find Tips and tricks on how to better use the Zeus editor. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
Site Admin
Posts: 2449
Joined: Fri Aug 13, 2004 5:10 pm

BCPP C/C++ Code Beautifier V1.9

Post by jussij » Wed Feb 28, 2007 10:43 pm

I found this C/C++ code beautifier:
C/C++ Code Beautifier V1.9

Written by Steven De Toni December 1995
Updated by Thomas Dickey January 1997

The above link only contains the source code, so I created a Windows build of this code which can be found here:


A typical command line to format example.cpp and write the beautified code to result.cpp would be:
c:\bcpp\bcpp.exe -fnc c:\bcpp\bcpp.cfg -fi example.cpp -fo result.cpp
If you add the c:\bcpp\ instalation directory to the PATH environment variable the following command line can be used instead:
bcpp.exe -fi example.cpp -fo result.cpp
In this case the bcpp.exe will go looking for the bcpp.cfg by searching the PATH environment variable.

Dispite the fact the number of configuration options provided seem fairly limited (i.e. just the bare minimum), IMHO it does a very good job of cleaning up the code ;)

Cheers Jussi

Site Admin
Posts: 2449
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij » Thu Mar 01, 2007 1:40 am

It is possible to integrate BCPP directly into Zeus as follows:

Step 1:
Create a bcpp.cmd batch file to first backup then format the file supplied:

Code: Select all

@echo off

if %1 == "" goto BadInputData
if %2 == "" goto BadInputData

REM Make a backup copy of the file
if not exist %1 goto Failed
copy %1 %2

REM Make sure we have the backup copy
if not exist %2 goto Failed

REM Reformat the file by formating the backup copy
echo bcpp.exe -fi %2 -fo %1
bcpp.exe -fi %2 -fo %1

REM Success
goto End

REM BadInputData
Echo Bad input data provided.
Echo USAGE: bcpp.cmd "$fn" "$zdzBackup\$f"
exit -1

REM Failed
Echo Unexpected error with input files!
exit -1

exit 0
Step 2:
Put the bcpp.cmd batch file in the Zeus install directory and run the batch file using the following bcpp.lua Lua macro:

Code: Select all

--        Name: BCPP Lua Macro
--      Author: Jussi Jumppanen
--    Language: Lua Macro
-- Description: This simple Lua macro will run the bcpp.cmd
--              which will formats the currently active file.

function key_macro()
  -- macro only works for documents
  if is_document() == 0 then
    message("This macro only works for document files!")

  -- macro only works for read/write documents
  if is_read_only() == 1 then
    message("The current document is marked as read only!")

  -- build up the file names
  local file_source = macro_tag("$fn")
  local file_backup = macro_tag("$zdzBackup\\") .. macro_tag("$f")

  -- build up the command line
  local cmd = "bcpp.cmd \"" .. file_source .. "\" \"" .. file_backup .. "\""

  message("BCPP Comand:" .. cmd)

  -- help with debugging
  -- message_box(1, cmd)

  -- setup command control falgs (see Zeus Macro help for more details)
  --  1 : save the document before running the program
  -- 16 : the program uses MS-DOS command interpreter (ie. dir *.* etc)
  -- 32 : wait for the program to complete (the ESC key will cancel the wait)
  local flags = 1+16+32

  -- run command
  system(cmd, "", flags)

  -- relaod teh formated file

  message("Formating complete")

key_macro() -- run the macro
Cheers Jussi

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 1 guest