mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Whitespace cleanup
Minor change to the perl postprocessing script and resulting changes to the affected source files. This deals with two issues: - "foreach"-like structures were not always treated correctly - some longer calculations that ended on "+ constant" were reformatted in a rather unatractive manner In one source file (divelist.c) I ended up adding braces to the sources... trying to cascade the indentation further down without having the block there seemed a lot more trouble than it's worth. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
917ce5aff5
commit
7c535452f9
10 changed files with 26 additions and 26 deletions
4
dive.c
4
dive.c
|
@ -670,7 +670,7 @@ static void fixup_duration(struct dive *dive)
|
||||||
int duration = 0;
|
int duration = 0;
|
||||||
|
|
||||||
for_each_dc(dive, dc)
|
for_each_dc(dive, dc)
|
||||||
duration = MAX(duration, dc->duration.seconds);
|
duration = MAX(duration, dc->duration.seconds);
|
||||||
|
|
||||||
dive->duration.seconds = duration;
|
dive->duration.seconds = duration;
|
||||||
}
|
}
|
||||||
|
@ -896,7 +896,7 @@ struct dive *fixup_dive(struct dive *dive)
|
||||||
dive->maxcns = dive->cns;
|
dive->maxcns = dive->cns;
|
||||||
|
|
||||||
for_each_dc(dive, dc)
|
for_each_dc(dive, dc)
|
||||||
fixup_dive_dc(dive, dc);
|
fixup_dive_dc(dive, dc);
|
||||||
|
|
||||||
fixup_water_salinity(dive);
|
fixup_water_salinity(dive);
|
||||||
fixup_surface_pressure(dive);
|
fixup_surface_pressure(dive);
|
||||||
|
|
|
@ -371,9 +371,10 @@ int get_divenr(struct dive *dive)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct dive *d;
|
struct dive *d;
|
||||||
for_each_dive(i, d)
|
for_each_dive(i, d) {
|
||||||
if (d == dive)
|
if (d == dive)
|
||||||
return i;
|
return i;
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
profile.c
18
profile.c
|
@ -1278,17 +1278,14 @@ static void calculate_gas_information(struct dive *dive, struct plot_info *pi)
|
||||||
* END just uses N2 */
|
* END just uses N2 */
|
||||||
entry->mod = (prefs.mod_ppO2 / fo2 * 1000 - 1) * 10000;
|
entry->mod = (prefs.mod_ppO2 / fo2 * 1000 - 1) * 10000;
|
||||||
entry->ead = (entry->depth + 10000) *
|
entry->ead = (entry->depth + 10000) *
|
||||||
(entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure -
|
(entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure - 10000;
|
||||||
10000;
|
|
||||||
entry->end = (entry->depth + 10000) *
|
entry->end = (entry->depth + 10000) *
|
||||||
(amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 -
|
(amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 - 10000;
|
||||||
10000;
|
|
||||||
entry->eadd = (entry->depth + 10000) *
|
entry->eadd = (entry->depth + 10000) *
|
||||||
(entry->po2 / amb_pressure * O2_DENSITY + entry->pn2 / amb_pressure *
|
(entry->po2 / amb_pressure * O2_DENSITY + entry->pn2 / amb_pressure *
|
||||||
N2_DENSITY +
|
N2_DENSITY +
|
||||||
entry->phe / amb_pressure * HE_DENSITY) /
|
entry->phe / amb_pressure * HE_DENSITY) /
|
||||||
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 -
|
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 - 10000;
|
||||||
10000;
|
|
||||||
if (entry->mod < 0)
|
if (entry->mod < 0)
|
||||||
entry->mod = 0;
|
entry->mod = 0;
|
||||||
if (entry->ead < 0)
|
if (entry->ead < 0)
|
||||||
|
@ -1343,17 +1340,14 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
|
||||||
* END just uses N2 */
|
* END just uses N2 */
|
||||||
entry->mod = (prefs.mod_ppO2 / fo2 * 1000 - 1) * 10000;
|
entry->mod = (prefs.mod_ppO2 / fo2 * 1000 - 1) * 10000;
|
||||||
entry->ead = (entry->depth + 10000) *
|
entry->ead = (entry->depth + 10000) *
|
||||||
(entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure -
|
(entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure - 10000;
|
||||||
10000;
|
|
||||||
entry->end = (entry->depth + 10000) *
|
entry->end = (entry->depth + 10000) *
|
||||||
(amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 -
|
(amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 - 10000;
|
||||||
10000;
|
|
||||||
entry->eadd = (entry->depth + 10000) *
|
entry->eadd = (entry->depth + 10000) *
|
||||||
(entry->po2 / amb_pressure * O2_DENSITY + entry->pn2 / amb_pressure *
|
(entry->po2 / amb_pressure * O2_DENSITY + entry->pn2 / amb_pressure *
|
||||||
N2_DENSITY +
|
N2_DENSITY +
|
||||||
entry->phe / amb_pressure * HE_DENSITY) /
|
entry->phe / amb_pressure * HE_DENSITY) /
|
||||||
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 -
|
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 - 10000;
|
||||||
10000;
|
|
||||||
if (entry->mod < 0)
|
if (entry->mod < 0)
|
||||||
entry->mod = 0;
|
entry->mod = 0;
|
||||||
if (entry->ead < 0)
|
if (entry->ead < 0)
|
||||||
|
|
|
@ -120,7 +120,7 @@ void DiveListView::restoreExpandedRows()
|
||||||
{
|
{
|
||||||
setAnimated(false);
|
setAnimated(false);
|
||||||
Q_FOREACH(const int & i, expandedRows)
|
Q_FOREACH(const int & i, expandedRows)
|
||||||
setExpanded(model()->index(i, 0), true);
|
setExpanded(model()->index(i, 0), true);
|
||||||
setAnimated(true);
|
setAnimated(true);
|
||||||
}
|
}
|
||||||
void DiveListView::fixMessyQtModelBehaviour()
|
void DiveListView::fixMessyQtModelBehaviour()
|
||||||
|
|
|
@ -103,8 +103,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
|
||||||
ui->CSV->setValue(VAL);\
|
ui->CSV->setValue(VAL);\
|
||||||
ui->CSV->setEnabled(VAL >= 0);\
|
ui->CSV->setEnabled(VAL >= 0);\
|
||||||
ui->BOX->setChecked(VAL >= 0);\
|
ui->BOX->setChecked(VAL >= 0);\
|
||||||
ui->CSV->blockSignals(false); \
|
ui->CSV->blockSignals(false); })
|
||||||
})
|
|
||||||
void DiveLogImportDialog::on_knownImports_currentIndexChanged(int index)
|
void DiveLogImportDialog::on_knownImports_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (specialCSV.contains(index)) {
|
if (specialCSV.contains(index)) {
|
||||||
|
|
|
@ -109,7 +109,7 @@ QStringList GroupedLineEdit::getBlockStringList()
|
||||||
QStringList retList;
|
QStringList retList;
|
||||||
Private::Block block;
|
Private::Block block;
|
||||||
foreach(block, d->blocks)
|
foreach(block, d->blocks)
|
||||||
retList.append(block.text);
|
retList.append(block.text);
|
||||||
return retList;
|
return retList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -872,7 +872,7 @@ void MainTab::saveTags()
|
||||||
QString tag;
|
QString tag;
|
||||||
taglist_clear(mydive->tag_list);
|
taglist_clear(mydive->tag_list);
|
||||||
foreach(tag, ui.tagWidget->getBlockStringList())
|
foreach(tag, ui.tagWidget->getBlockStringList())
|
||||||
taglist_add_tag(mydive->tag_list, tag.toUtf8().data()););
|
taglist_add_tag(mydive->tag_list, tag.toUtf8().data()););
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainTab::on_tagWidget_textChanged()
|
void MainTab::on_tagWidget_textChanged()
|
||||||
|
|
|
@ -621,7 +621,7 @@ void MainWindow::initialUiSetup()
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TOOLBOX_PREF_BUTTON(pref, setting, button) \
|
#define TOOLBOX_PREF_BUTTON(pref, setting, button) \
|
||||||
prefs.pref = s.value(#setting).toBool(); \
|
prefs.pref = s.value(#setting).toBool(); \
|
||||||
ui.button->setChecked(prefs.pref);
|
ui.button->setChecked(prefs.pref);
|
||||||
|
|
||||||
void MainWindow::readSettings()
|
void MainWindow::readSettings()
|
||||||
|
@ -835,7 +835,7 @@ void MainWindow::removeRecentFile(QStringList failedFiles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (QString file, failedFiles)
|
foreach(QString file, failedFiles)
|
||||||
files.removeAll(file);
|
files.removeAll(file);
|
||||||
|
|
||||||
for (int c = 1; c <= 4; c++) {
|
for (int c = 1; c <= 4; c++) {
|
||||||
|
|
|
@ -238,9 +238,9 @@ void DiveCartesianAxis::updateTicks()
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_FOREACH(DiveTextItem * item, labels)
|
Q_FOREACH(DiveTextItem * item, labels)
|
||||||
item->setVisible(textVisibility);
|
item->setVisible(textVisibility);
|
||||||
Q_FOREACH(DiveLineItem * item, lines)
|
Q_FOREACH(DiveLineItem * item, lines)
|
||||||
item->setVisible(lineVisibility);
|
item->setVisible(lineVisibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveCartesianAxis::animateChangeLine(const QLineF &newLine)
|
void DiveCartesianAxis::animateChangeLine(const QLineF &newLine)
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
my $input = $ARGV[0];
|
my $input = $ARGV[0];
|
||||||
my $source = `clang-format $input`;
|
my $source = `clang-format $input`;
|
||||||
|
# for_each_dive (...) and Q_FOREACH and friends...
|
||||||
$source =~ s/^(.*each.*\(.*\).*)\n\s*{\s*$/$1 {/img;
|
$source =~ s/^(.*each.*\(.*\).*)\n\s*{\s*$/$1 {/img;
|
||||||
|
$source =~ s/(?:\G|^)(\s+[^#\/*].*each.*\(.*\))\n(\s*)([^{}\s])/$1\n\t$2$3/img;
|
||||||
|
|
||||||
$source =~ s/^(\s*struct[^()\n]*)\n\s*{\s*$/$1 {/img;
|
$source =~ s/^(\s*struct[^()\n]*)\n\s*{\s*$/$1 {/img;
|
||||||
$source =~ s/^(\s*static\s+struct[^()\n]*)\n\s*{\s*$/$1 {/img;
|
$source =~ s/^(\s*static\s+struct[^()\n]*)\n\s*{\s*$/$1 {/img;
|
||||||
$source =~ s/^(\s*union[^()\n]*)\n\s*{\s*$/$1 {/img;
|
$source =~ s/^(\s*union[^()\n]*)\n\s*{\s*$/$1 {/img;
|
||||||
|
@ -11,5 +14,8 @@ $source =~ s/^(\s*class.*)\n\s*{\s*$/$1 {/img;
|
||||||
$source =~ s/^(\S*::\S*.*)\n\s*: /$1 : /img;
|
$source =~ s/^(\S*::\S*.*)\n\s*: /$1 : /img;
|
||||||
$source =~ s/(?:\G|^)[ ]{6}/\t/mg;
|
$source =~ s/(?:\G|^)[ ]{6}/\t/mg;
|
||||||
$source =~ s/(?:\G|^)(\t*)[ ]{4}"/$1\t"/mg;
|
$source =~ s/(?:\G|^)(\t*)[ ]{4}"/$1\t"/mg;
|
||||||
|
# don't put line break before the last single term argument of a
|
||||||
|
# calculation
|
||||||
|
$source =~ s/(?:\G|^)(.*[+-])\n\s*(\S*\;)$/$1 $2/mg;
|
||||||
open (DIFF, "| diff -u $input -");
|
open (DIFF, "| diff -u $input -");
|
||||||
print DIFF $source ;
|
print DIFF $source ;
|
||||||
|
|
Loading…
Add table
Reference in a new issue