mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Another small tweak to whitespace tool
clang-format doesn't appear to reindent multi line #define statements correctly - so this hopefully will clean those up. The included whitespace corrections to the code should stay in place when using the updated tool. This includes cleaning up some multi-line comments that were messed up the last time around as well as a few other minor changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
13a2f14be0
commit
1b103c5c69
9 changed files with 69 additions and 54 deletions
2
dive.c
2
dive.c
|
@ -1084,7 +1084,7 @@ static char *merge_text(const char *a, const char *b)
|
|||
|
||||
#define SORT(a, b, field) \
|
||||
if (a->field != b->field) \
|
||||
return a->field < b->field ? -1 : 1
|
||||
return a->field < b->field ? -1 : 1
|
||||
|
||||
static int sort_event(struct event *a, struct event *b)
|
||||
{
|
||||
|
|
22
dive.h
22
dive.h
|
@ -10,16 +10,16 @@
|
|||
|
||||
/* Windows has no MIN/MAX macros - so let's just roll our own */
|
||||
#define MIN(x, y) ({ \
|
||||
typeof(x) _min1 = (x); \
|
||||
typeof(y) _min2 = (y); \
|
||||
(void) (&_min1 == &_min2); \
|
||||
_min1 < _min2 ? _min1 : _min2; })
|
||||
typeof(x) _min1 = (x); \
|
||||
typeof(y) _min2 = (y); \
|
||||
(void) (&_min1 == &_min2); \
|
||||
_min1 < _min2 ? _min1 : _min2; })
|
||||
|
||||
#define MAX(x, y) ({ \
|
||||
typeof(x) _max1 = (x); \
|
||||
typeof(y) _max2 = (y); \
|
||||
(void) (&_max1 == &_max2); \
|
||||
_max1 > _max2 ? _max1 : _max2; })
|
||||
typeof(x) _max1 = (x); \
|
||||
typeof(y) _max2 = (y); \
|
||||
(void) (&_max1 == &_max2); \
|
||||
_max1 > _max2 ? _max1 : _max2; })
|
||||
|
||||
#define IS_FP_SAME(_a, _b) (fabs((_a) - (_b)) < 0.000001 * MAX(fabs(_a), fabs(_b)))
|
||||
|
||||
|
@ -620,13 +620,13 @@ static inline struct divecomputer *get_dive_dc(struct dive *dive, int nr)
|
|||
* it local to the for-loop, but that would make us requires C99.
|
||||
*/
|
||||
#define for_each_dive(_i, _x) \
|
||||
for ((_i) = 0; ((_x) = get_dive(_i)) != NULL; (_i)++)
|
||||
for ((_i) = 0; ((_x) = get_dive(_i)) != NULL; (_i)++)
|
||||
|
||||
#define for_each_dc(_dive, _dc) \
|
||||
for (_dc = &_dive->dc; _dc; _dc = _dc->next)
|
||||
for (_dc = &_dive->dc; _dc; _dc = _dc->next)
|
||||
|
||||
#define for_each_gps_location(_i, _x) \
|
||||
for ((_i) = 0; ((_x) = get_gps_location(_i, &gps_location_table)) != NULL; (_i)++)
|
||||
for ((_i) = 0; ((_x) = get_gps_location(_i, &gps_location_table)) != NULL; (_i)++)
|
||||
|
||||
static inline struct dive *get_dive_by_diveid(uint32_t diveid, uint32_t deviceid)
|
||||
{
|
||||
|
|
|
@ -183,9 +183,9 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
|||
sample = dc->samples ? dc->sample + dc->samples - 1 : NULL;
|
||||
|
||||
/*
|
||||
* Ok, sanity check.
|
||||
* If first sample is not a DC_SAMPLE_TIME, Allocate a sample for us
|
||||
*/
|
||||
* Ok, sanity check.
|
||||
* If first sample is not a DC_SAMPLE_TIME, Allocate a sample for us
|
||||
*/
|
||||
if (sample == NULL && type != DC_SAMPLE_TIME)
|
||||
sample = prepare_sample(dc);
|
||||
|
||||
|
|
|
@ -534,7 +534,7 @@ static void utf8_string(char *buffer, void *_res)
|
|||
}
|
||||
|
||||
#define MATCH(pattern, fn, dest) \
|
||||
match(pattern, strlen(pattern), name, fn, buf, dest)
|
||||
match(pattern, strlen(pattern), name, fn, buf, dest)
|
||||
|
||||
static void get_index(char *buffer, void *_i)
|
||||
{
|
||||
|
|
|
@ -105,8 +105,8 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* Constructs a KMessageWidget with the specified parent.
|
||||
*/
|
||||
* Constructs a KMessageWidget with the specified parent.
|
||||
*/
|
||||
explicit KMessageWidget(QWidget *parent = 0);
|
||||
|
||||
explicit KMessageWidget(const QString &text, QWidget *parent = 0);
|
||||
|
@ -132,9 +132,9 @@ public:
|
|||
int heightForWidth(int width) const;
|
||||
|
||||
/**
|
||||
* The icon shown on the left of the text. By default, no icon is shown.
|
||||
* @since 4.11
|
||||
*/
|
||||
* The icon shown on the left of the text. By default, no icon is shown.
|
||||
* @since 4.11
|
||||
*/
|
||||
QIcon icon() const;
|
||||
|
||||
public
|
||||
|
@ -148,40 +148,40 @@ Q_SLOTS:
|
|||
void setMessageType(KMessageWidget::MessageType type);
|
||||
|
||||
/**
|
||||
* Show the widget using an animation, unless
|
||||
* KGlobalSettings::graphicsEffectLevel() does not allow simple effects.
|
||||
*/
|
||||
* Show the widget using an animation, unless
|
||||
* KGlobalSettings::graphicsEffectLevel() does not allow simple effects.
|
||||
*/
|
||||
void animatedShow();
|
||||
|
||||
/**
|
||||
* Hide the widget using an animation, unless
|
||||
* KGlobalSettings::graphicsEffectLevel() does not allow simple effects.
|
||||
*/
|
||||
* Hide the widget using an animation, unless
|
||||
* KGlobalSettings::graphicsEffectLevel() does not allow simple effects.
|
||||
*/
|
||||
void animatedHide();
|
||||
|
||||
/**
|
||||
* Define an icon to be shown on the left of the text
|
||||
* @since 4.11
|
||||
*/
|
||||
* Define an icon to be shown on the left of the text
|
||||
* @since 4.11
|
||||
*/
|
||||
void setIcon(const QIcon &icon);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted when the user clicks a link in the text label.
|
||||
* The URL referred to by the href anchor is passed in contents.
|
||||
* @param contents text of the href anchor
|
||||
* @see QLabel::linkActivated()
|
||||
* @since 4.10
|
||||
*/
|
||||
* This signal is emitted when the user clicks a link in the text label.
|
||||
* The URL referred to by the href anchor is passed in contents.
|
||||
* @param contents text of the href anchor
|
||||
* @see QLabel::linkActivated()
|
||||
* @since 4.10
|
||||
*/
|
||||
void linkActivated(const QString &contents);
|
||||
|
||||
/**
|
||||
* This signal is emitted when the user hovers over a link in the text label.
|
||||
* The URL referred to by the href anchor is passed in contents.
|
||||
* @param contents text of the href anchor
|
||||
* @see QLabel::linkHovered()
|
||||
* @since 4.11
|
||||
*/
|
||||
* This signal is emitted when the user hovers over a link in the text label.
|
||||
* The URL referred to by the href anchor is passed in contents.
|
||||
* @param contents text of the href anchor
|
||||
* @see QLabel::linkHovered()
|
||||
* @since 4.11
|
||||
*/
|
||||
void linkHovered(const QString &contents);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -191,7 +191,7 @@ void CylindersModel::passInData(const QModelIndex &index, const QVariant &value)
|
|||
|
||||
/* Has the string value changed */
|
||||
#define CHANGED() \
|
||||
(vString = value.toString()) != data(index, role).toString()
|
||||
(vString = value.toString()) != data(index, role).toString()
|
||||
|
||||
bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
|
@ -934,8 +934,7 @@ bool TreeItem::setData(const QModelIndex &index, const QVariant &value, int role
|
|||
return false;
|
||||
}
|
||||
|
||||
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent)
|
||||
const
|
||||
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
|
|
@ -114,7 +114,7 @@ int PrintLayout::estimateTotalDives() const
|
|||
* p is the padding between elements
|
||||
*/
|
||||
#define ESTIMATE_DIVE_DIM(S, n, p) \
|
||||
((S) - ((n) - 1) * (p)) / (n);
|
||||
((S) - ((n) - 1) * (p)) / (n);
|
||||
|
||||
void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
|
||||
{
|
||||
|
|
|
@ -11,9 +11,25 @@ $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*static\s+union[^()\n]*)\n\s*{\s*$/$1 {/img;
|
||||
$source =~ s/^(\s*class.*)\n\s*{\s*$/$1 {/img;
|
||||
# colon goes at the end of a line
|
||||
$source =~ s/^(\S*::\S*.*)\n\s*: /$1 : /img;
|
||||
# odd indentations from flang-format:
|
||||
# six spaces or four spaces after tabs (for continuation strings)
|
||||
$source =~ s/(?:\G|^)[ ]{6}/\t/mg;
|
||||
$source =~ s/(?:\G|^)(\t*)[ ]{4}"/$1\t"/mg;
|
||||
# the next ones are rather awkward
|
||||
# they capture multi line #define and #if definded statements
|
||||
# that clang-format messes up (where does that 4 space indentation come
|
||||
# from?
|
||||
# I couldn't figure out how to make it apply to an arbitrary number of
|
||||
# intermediate lines, so I hardcoded 0 through 5 lines between the #define
|
||||
# or #id defined statements and the end of the multi line statement
|
||||
$source =~ s/^(#(?:if |)define.*)\n +([^*].*)$/$1\n\t$2/mg;
|
||||
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){1})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){2})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){3})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){4})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){5})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||
# don't put line break before the last single term argument of a
|
||||
# calculation
|
||||
$source =~ s/(?:\G|^)(.*[+-])\n\s*(\S*\;)$/$1 $2/mg;
|
||||
|
|
16
sha1.c
16
sha1.c
|
@ -79,10 +79,10 @@
|
|||
*/
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__) || \
|
||||
defined(_M_IX86) || defined(_M_X64) || \
|
||||
defined(__ppc__) || defined(__ppc64__) || \
|
||||
defined(__powerpc__) || defined(__powerpc64__) || \
|
||||
defined(__s390__) || defined(__s390x__)
|
||||
defined(_M_IX86) || defined(_M_X64) || \
|
||||
defined(__ppc__) || defined(__ppc64__) || \
|
||||
defined(__powerpc__) || defined(__powerpc64__) || \
|
||||
defined(__s390__) || defined(__s390x__)
|
||||
|
||||
#define get_be32(p) ntohl(*(unsigned int *)(p))
|
||||
#define put_be32(p, v) \
|
||||
|
@ -93,10 +93,10 @@
|
|||
#else
|
||||
|
||||
#define get_be32(p) ( \
|
||||
(*((unsigned char *)(p) + 0) << 24) | \
|
||||
(*((unsigned char *)(p) + 1) << 16) | \
|
||||
(*((unsigned char *)(p) + 2) << 8) | \
|
||||
(*((unsigned char *)(p) + 3) << 0))
|
||||
(*((unsigned char *)(p) + 0) << 24) | \
|
||||
(*((unsigned char *)(p) + 1) << 16) | \
|
||||
(*((unsigned char *)(p) + 2) << 8) | \
|
||||
(*((unsigned char *)(p) + 3) << 0))
|
||||
#define put_be32(p, v) \
|
||||
do { \
|
||||
unsigned int __v = (v); \
|
||||
|
|
Loading…
Add table
Reference in a new issue