SlickEdit Community
SlickEdit Product Discussion => SlickEdit® => Topic started by: JimmieC on September 12, 2018, 06:07:27 PM
-
I am running the beautifier on a C file. However, I cannot get the results I am looking for. I have found on a previous post that the beautifier does not have settings to put a blank line before if, while, do, & for.
https://community.slickedit.com/index.php/topic,16330.0.html (https://community.slickedit.com/index.php/topic,16330.0.html)
So, maybe there is no setting for this either. I have attached two files, before & after. Here are couple of snippets with tabs replaced as spaces to hold formatting in the forum text:
FlashProgram_WIR_routine(address, Data); /* Process routine in RAM */
ExitCritical(); /* Enable all low level interrupts */
if(AccessError()) /* Is an access error detected ? */
return ERR_NOTAVAIL; /* If yes then return the error */
return Err;
-------------------------------------
WANT
ExitCritical(); /* Enable all low level interrupts */
<<--- space here, covered in a previous post though
if(AccessError()) /* Is an access error detected ? */
return ERR_NOTAVAIL; /* If yes then return the error */
<<--- space here
return Err;
-------------------------------------
else
{
setReg(PFIU_PE, 0); /* Clear Program enable register */
if(Command == MASS_ERASE) /* Is the mass erase operation requested? */
{ setReg(PFIU_EE, 0x4000); /* Write page number and enable intelligent erase */
setRegBit(PFIU_CNTL, MAS1); /* If yes, then enable mass erase */
}
else setReg(PFIU_EE, (address >> 8) + 0x4000); /* Write page number and enable intelligent erase */
}
-------------------------------------
WANT
else
{
setReg(PFIU_PE, 0); /* Clear Program enable register */
<<--- space here, covered in a previous post though
if(Command == MASS_ERASE) /* Is the mass erase operation requested? */
{ setReg(PFIU_EE, 0x4000); /* Write page number and enable intelligent erase */
setRegBit(PFIU_CNTL, MAS1); /* If yes, then enable mass erase */
}
else <<----- statement on same line as else moved underneath else
{
setReg(PFIU_EE, (address >> 8) + 0x4000); /* Write page number and enable intelligent erase */
} <<----- if the preceding if for this else had braces, not single-line statement, then wrap braces around block even if single line.
} Or, would be OK to just put single-line statement without braces, if brace checking of prior if proves problematic.
-
There are some other areas of interest as well.
Beautifed file, line 220, mempcpy, beautifier un-indented 3 move instructions
Beautifed file, line 304, WriteWords, need option to use braces on parent for loop if next line is not a single-line
Beautifed file, line 305, WriteWords, braces for if statement are indented
-
Beautifed file, line 436, FlashProgram_SetByteFlash, want a space between variables & code.
word Data16;
byte rot;
<<------ Want a space here.
rot = (byte)((Addr % 2) * 8);
-
Beautifed file, line 261, procflash, code on same line as brace
if(Command == MASS_ERASE) /* Is the mass erase operation requested? */
{ setReg(PFIU_EE, 0x4000); /* Write page number and enable intelligent erase */
setRegBit(PFIU_CNTL, MAS1); /* If yes, then enable mass erase */
}
-
Beautifed file, line 261, procflash, code on same line as brace
if(Command == MASS_ERASE) /* Is the mass erase operation requested? */
{ setReg(PFIU_EE, 0x4000); /* Write page number and enable intelligent erase */
setRegBit(PFIU_CNTL, MAS1); /* If yes, then enable mass erase */
}
Please post your user.cfg.xml. That will give us your beautify profile settings. I wasn't able to reproduce this by just changing the "if" brace style.
Your other posts are feature requests. All good ones.
-
Here is the user.cfg.xml file.
I did dork with the beautify settings a little after I posted to the forum. I don't think I changed anything substantial; Was trying to get rid of the blank line after the opening paren of a function. I changed that setting.
-
In my earlier post:
Beautifed file, line 305, WriteWords, braces for if statement are indented
This is actually OK. The whole if statement is correctly indented. And, the braces are properly underneath the if. So, cancel this one.
-
Ok.
I'm debugging the brace without the newline now. I see what's wrong, and am deciding how to fix it now, so I expect it to be in the next v23 beta drop.
I need to take a closer look at the other features, but it's safe to say any of those would be post v23.0.0.
-
Yeah, most of the stuff I reported works out to be new features.
Just below the brace without newline, is an else without newline for the single-line statement:
-----------------
else setReg(PFIU_EE, (address >> 8) + 0x4000); /* Write page number and enable intelligent erase */
-----------------
else
setReg(PFIU_EE, (address >> 8) + 0x4000); /* Write page number and enable intelligent erase */
-----------------
I think that counts a bug too? My comment about optionally wrapping it in braces is a new feature. But, without adding braces, should that be put on a newline at least?
Not a front-burner issue anyway.
-
You can change the "Unblocked else statement on same line" to Off under Newlines -> 'if' statements for that. I'd turn off the "Unblocked then statement on the same line" too, for consistency.
-
Just confirming the fix for the brace without a newline will be in the next drop. Thanks.