C++ indentation and some request for help with C++ error

Hi,

I'm trying to "resurrect" old Turbo Vision library to use it on Linux/Solaris/*BSD.
I know that it is quite well-maintained version of TVision on https://git.code.sf.net/p/tvision/code, but it contains many things which extend or changes many original Borland version functionalities, so I've started working on Ioannis Tziakos fork. Ioannis week ago transferred his tvision repo to my account so now it is available on https://github.com/kloczek/tvision
If anyone may be interested help with this code feel free to join and/or sens some patches ar PR.
What I've stared has entirely non-commercial needs. Simple I plan to write few OSS TVision based applications which maybe even some people find useful :)
Simple, I always been dreaming about using TVision on U*nices as +20y ago I've been using TVision on DOS :P (both Pascal and C++ versions)

So far I've done:
- Full cleanup of the am/ac/lt build framework
- Fixed all compile errors using g++ 8.1.1 and most of the compile warnings
- Added easy build of the rpm package out of the source tree by:
"./boostrap.sh; ./configure; make dist-gzip; rpmbuild -ta tvision-0.8.0.tar.gz"
Everything passes as well dist-check target
- Added support for pkgconfig to detect tvsion library is it installed or not
- The whole git repo is now hooked to travis-ci.com where after each commit or PR request whole code (+ eventual PR patches as well) passes test build

So here starts kind of obstacles.
As I never passed regular C++ course and I'm still learning C++, I found some issue with my current code. Simple it fails on gcc/g++ 4.8.4 used on travis-ci.com. What is odd to me that I don't see reported on gcc/g++ 4.8.4 on my system where I have gcc 8.1.1.

Here is last build log https://travis-ci.org/kloczek/tvision/builds/389881026
also, here are two files involved in this error:
https://github.com/kloczek/tvision/blob/master/tvision/new.cc#L171
https://github.com/kloczek/tvision/blob/master/tvision/buffers.h#L75

I would glad if someone would help me understand nature of this error and/or write affected lines to be able to use this code on gcc/g++ 4.8.x and 8.1.x :)

I have as well the second kind of question(s).
I found that TVision is not well indented/formatted. Looks like different parts of the code are indented slightly different styles or indentation has been done manually. So far usually I've been using GNU indent. However most of my own work on this area was related to write C code, and typical local directory .indent.pro file content like with

-kr
-i8
-bad
-pcs
-l80

Was enough to have well formatted C code. However, I just found that the same set of intent options does not work well enough with C++. Additionally, I found that indent trashes C++ code. If it is used multiple times, it multiplies "const" keyword. Just found that GNU indent maintainer has no time to maintain indent code (https://github.com/thentenaar/indent).
GNU indent changes cde like

Complex method_name(arguments) const {
}

to:

Complex method_name(arguments) const const {
}

Nevertheless, my questions related to C++ indentation are:

- does anyone fixed "const" keywords "multiplication issue?(using google I was unable to find any traces of such fixes)

- maybe someone has some set of indent options which could format TVision code with as much as possible similar style to original style?

- maybe someone can recommend some other C++ indentation tool?

Thank you for any help or suggestions

kloczek
Last edited on
> maybe someone can recommend some other C++ indentation tool?

AStyle works reasonably well with C++ code. http://astyle.sourceforge.net/astyle.html
visual studio, notepad++ have indentation available/built in. You can also write your own in maybe 1/2 a page of code if you don't want anything too exotic. I wrote my own because a lot of the available ones won't move { to its own line, which is half the reason I wanted a tool, to fix 'book space saver' code to column aligned indention format.


notepad++ isn't an option.
First: it is not ported tp Linux/Solaris/*BSD.
Second: AFAIK indentation is not configurable and it cannot be used in batch mode.
clang-format uses parts of LLVM's compiler toolchain. It works well, even for language corner-cases.

https://clang.llvm.org/docs/ClangFormat.html
Last edited on
closed account (E0p9LyTq)
There is Scintilla (the source code editing engine notepad++ uses):
https://www.scintilla.org/

Used in the SciTE editor:
https://www.scintilla.org/SciTE.html
I use gnu indent: https://www.gnu.org/software/indent/
It's very flexible and it handles comments well.
@dhayden, under Bugs for indent it says:
While an attempt was made to get indent working for C++, it will not do a good job on any C++ source except the very simplest.


Are you mostly using it for C? Have you had any problems with C++ formatting?
Are you mostly using it for C? Have you had any problems with C++ formatting?

I use it for C++ exclusively. I suspect what they're talking about is use with template definitions. I seem to recall that it has trouble there. I've had to write very few templates.
Topic archived. No new replies allowed.