mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Keeping up the fight for whitespace consistency
Sadly, some of the code being fixed is my own... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
46bb02e8fc
commit
43765d2897
2 changed files with 47 additions and 44 deletions
57
dive.c
57
dive.c
|
@ -65,7 +65,7 @@ static int same_event(struct event *a, struct event *b)
|
||||||
return !strcmp(a->name, b->name);
|
return !strcmp(a->name, b->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_event(struct event* event)
|
void remove_event(struct event *event)
|
||||||
{
|
{
|
||||||
struct event **ep = ¤t_dc->events;
|
struct event **ep = ¤t_dc->events;
|
||||||
while (ep && !same_event(*ep, event))
|
while (ep && !same_event(*ep, event))
|
||||||
|
@ -85,7 +85,7 @@ void remove_event(struct event* event)
|
||||||
* have to actually remove the existing event and replace it with a new one.
|
* have to actually remove the existing event and replace it with a new one.
|
||||||
* WARNING, WARNING... this may end up freeing event in case that event is indeed
|
* WARNING, WARNING... this may end up freeing event in case that event is indeed
|
||||||
* WARNING, WARNING... part of this divecomputer on this dive! */
|
* WARNING, WARNING... part of this divecomputer on this dive! */
|
||||||
void update_event_name(struct dive *d, struct event* event, char *name)
|
void update_event_name(struct dive *d, struct event *event, char *name)
|
||||||
{
|
{
|
||||||
if (!d || !event)
|
if (!d || !event)
|
||||||
return;
|
return;
|
||||||
|
@ -190,7 +190,7 @@ double get_volume_units(unsigned int ml, int *frac, const char **units)
|
||||||
|
|
||||||
int units_to_sac(double volume)
|
int units_to_sac(double volume)
|
||||||
{
|
{
|
||||||
if(get_units()->volume == CUFT)
|
if (get_units()->volume == CUFT)
|
||||||
return rint(cuft_to_l(volume) * 1000.0);
|
return rint(cuft_to_l(volume) * 1000.0);
|
||||||
else
|
else
|
||||||
return rint(volume * 1000);
|
return rint(volume * 1000);
|
||||||
|
@ -341,18 +341,21 @@ static void copy_tl(struct tag_entry *st, struct tag_entry *dt)
|
||||||
|
|
||||||
/* Clear everything but the first element;
|
/* Clear everything but the first element;
|
||||||
* this works for taglist, picturelist, even dive computers */
|
* this works for taglist, picturelist, even dive computers */
|
||||||
#define STRUCTURED_LIST_FREE(_type, _start, _free) {\
|
#define STRUCTURED_LIST_FREE(_type, _start, _free) \
|
||||||
|
{ \
|
||||||
_type *_ptr = _start; \
|
_type *_ptr = _start; \
|
||||||
while(_ptr) { \
|
while (_ptr) { \
|
||||||
_type *_next = _ptr->next; \
|
_type *_next = _ptr->next; \
|
||||||
_free(_ptr); \
|
_free(_ptr); \
|
||||||
_ptr = _next; \
|
_ptr = _next; \
|
||||||
}}
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
#define STRUCTURED_LIST_COPY(_type, _first, _dest, _cpy) {\
|
#define STRUCTURED_LIST_COPY(_type, _first, _dest, _cpy) \
|
||||||
|
{ \
|
||||||
_type *_sptr = _first; \
|
_type *_sptr = _first; \
|
||||||
_type **_dptr = &_dest; \
|
_type **_dptr = &_dest; \
|
||||||
while(_sptr) { \
|
while (_sptr) { \
|
||||||
*_dptr = malloc(sizeof(_type)); \
|
*_dptr = malloc(sizeof(_type)); \
|
||||||
_cpy(_sptr, *_dptr); \
|
_cpy(_sptr, *_dptr); \
|
||||||
_sptr = _sptr->next; \
|
_sptr = _sptr->next; \
|
||||||
|
@ -885,7 +888,7 @@ static void fixup_surface_pressure(struct dive *dive)
|
||||||
struct divecomputer *dc;
|
struct divecomputer *dc;
|
||||||
int sum = 0, nr = 0;
|
int sum = 0, nr = 0;
|
||||||
|
|
||||||
for_each_dc(dive, dc) {
|
for_each_dc (dive, dc) {
|
||||||
if (dc->surface_pressure.mbar) {
|
if (dc->surface_pressure.mbar) {
|
||||||
sum += dc->surface_pressure.mbar;
|
sum += dc->surface_pressure.mbar;
|
||||||
nr++;
|
nr++;
|
||||||
|
@ -900,7 +903,7 @@ static void fixup_water_salinity(struct dive *dive)
|
||||||
struct divecomputer *dc;
|
struct divecomputer *dc;
|
||||||
int sum = 0, nr = 0;
|
int sum = 0, nr = 0;
|
||||||
|
|
||||||
for_each_dc(dive, dc) {
|
for_each_dc (dive, dc) {
|
||||||
if (dc->salinity) {
|
if (dc->salinity) {
|
||||||
sum += dc->salinity;
|
sum += dc->salinity;
|
||||||
nr++;
|
nr++;
|
||||||
|
@ -915,7 +918,7 @@ static void fixup_meandepth(struct dive *dive)
|
||||||
struct divecomputer *dc;
|
struct divecomputer *dc;
|
||||||
int sum = 0, nr = 0;
|
int sum = 0, nr = 0;
|
||||||
|
|
||||||
for_each_dc(dive, dc) {
|
for_each_dc (dive, dc) {
|
||||||
if (dc->meandepth.mm) {
|
if (dc->meandepth.mm) {
|
||||||
sum += dc->meandepth.mm;
|
sum += dc->meandepth.mm;
|
||||||
nr++;
|
nr++;
|
||||||
|
@ -930,7 +933,7 @@ static void fixup_duration(struct dive *dive)
|
||||||
struct divecomputer *dc;
|
struct divecomputer *dc;
|
||||||
unsigned int duration = 0;
|
unsigned 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;
|
||||||
|
@ -1181,7 +1184,7 @@ struct dive *fixup_dive(struct dive *dive)
|
||||||
sanitize_cylinder_info(dive);
|
sanitize_cylinder_info(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);
|
||||||
|
@ -1500,7 +1503,6 @@ extern void fill_pressures(struct gas_pressures *pressures, const double amb_pre
|
||||||
pressures->he = get_he(mix) / 1000.0 * amb_pressure;
|
pressures->he = get_he(mix) / 1000.0 * amb_pressure;
|
||||||
pressures->n2 = (1000 - get_o2(mix) - get_he(mix)) / 1000.0 * amb_pressure;
|
pressures->n2 = (1000 - get_o2(mix) - get_he(mix)) / 1000.0 * amb_pressure;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_cylinder_match(cylinder_t *cyl, cylinder_t array[], unsigned int used)
|
static int find_cylinder_match(cylinder_t *cyl, cylinder_t array[], unsigned int used)
|
||||||
|
@ -1570,7 +1572,7 @@ static void dc_cylinder_renumber(struct dive *dive, struct divecomputer *dc, int
|
||||||
static void cylinder_renumber(struct dive *dive, int mapping[])
|
static void cylinder_renumber(struct dive *dive, int mapping[])
|
||||||
{
|
{
|
||||||
struct divecomputer *dc;
|
struct divecomputer *dc;
|
||||||
for_each_dc(dive, dc)
|
for_each_dc (dive, dc)
|
||||||
dc_cylinder_renumber(dive, dc, mapping);
|
dc_cylinder_renumber(dive, dc, mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2246,7 +2248,7 @@ static void join_dive_computers(struct divecomputer *res, struct divecomputer *a
|
||||||
|
|
||||||
static bool tag_seen_before(struct tag_entry *start, struct tag_entry *before)
|
static bool tag_seen_before(struct tag_entry *start, struct tag_entry *before)
|
||||||
{
|
{
|
||||||
while(start && start != before) {
|
while (start && start != before) {
|
||||||
if (same_string(start->tag->name, before->tag->name))
|
if (same_string(start->tag->name, before->tag->name))
|
||||||
return true;
|
return true;
|
||||||
start = start->next;
|
start = start->next;
|
||||||
|
@ -2452,7 +2454,7 @@ struct dive *find_dive_including(timestamp_t when)
|
||||||
/* binary search, anyone? Too lazy for now;
|
/* binary search, anyone? Too lazy for now;
|
||||||
* also we always use the duration from the first divecomputer
|
* also we always use the duration from the first divecomputer
|
||||||
* could this ever be a problem? */
|
* could this ever be a problem? */
|
||||||
for_each_dive(i, dive) {
|
for_each_dive (i, dive) {
|
||||||
if (dive->when <= when && when <= dive->when + dive->duration.seconds)
|
if (dive->when <= when && when <= dive->when + dive->duration.seconds)
|
||||||
return dive;
|
return dive;
|
||||||
}
|
}
|
||||||
|
@ -2471,7 +2473,7 @@ struct dive *find_dive_n_near(timestamp_t when, int n, timestamp_t offset)
|
||||||
int i, j = 0;
|
int i, j = 0;
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
|
|
||||||
for_each_dive(i, dive) {
|
for_each_dive (i, dive) {
|
||||||
if (dive_within_time_range(dive, when, offset))
|
if (dive_within_time_range(dive, when, offset))
|
||||||
if (++j == n)
|
if (++j == n)
|
||||||
return dive;
|
return dive;
|
||||||
|
@ -2484,7 +2486,7 @@ void shift_times(const timestamp_t amount)
|
||||||
int i;
|
int i;
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
|
|
||||||
for_each_dive(i, dive) {
|
for_each_dive (i, dive) {
|
||||||
if (!dive->selected)
|
if (!dive->selected)
|
||||||
continue;
|
continue;
|
||||||
dive->when += amount;
|
dive->when += amount;
|
||||||
|
@ -2496,7 +2498,7 @@ timestamp_t get_times()
|
||||||
int i;
|
int i;
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
|
|
||||||
for_each_dive(i, dive) {
|
for_each_dive (i, dive) {
|
||||||
if (dive->selected)
|
if (dive->selected)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2511,7 +2513,7 @@ void set_save_userid_local(short value)
|
||||||
|
|
||||||
void set_userid(char *rUserId)
|
void set_userid(char *rUserId)
|
||||||
{
|
{
|
||||||
prefs.userid = (char *) malloc(MAX_USERID_SIZE + 1);
|
prefs.userid = (char *)malloc(MAX_USERID_SIZE + 1);
|
||||||
if (prefs.userid && rUserId) {
|
if (prefs.userid && rUserId) {
|
||||||
strncpy(prefs.userid, rUserId, MAX_USERID_SIZE);
|
strncpy(prefs.userid, rUserId, MAX_USERID_SIZE);
|
||||||
prefs.userid[MAX_USERID_SIZE] = 0;
|
prefs.userid[MAX_USERID_SIZE] = 0;
|
||||||
|
@ -2555,7 +2557,7 @@ struct picture *alloc_picture()
|
||||||
|
|
||||||
static bool new_picture_for_dive(struct dive *d, char *filename)
|
static bool new_picture_for_dive(struct dive *d, char *filename)
|
||||||
{
|
{
|
||||||
FOR_EACH_PICTURE(d) {
|
FOR_EACH_PICTURE (d) {
|
||||||
if (same_string(picture->filename, filename))
|
if (same_string(picture->filename, filename))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2589,7 +2591,7 @@ void dive_add_picture(struct dive *d, struct picture *newpic)
|
||||||
{
|
{
|
||||||
struct picture **pic_ptr = &d->picture_list;
|
struct picture **pic_ptr = &d->picture_list;
|
||||||
/* let's keep the list sorted by time */
|
/* let's keep the list sorted by time */
|
||||||
while( *pic_ptr && (*pic_ptr)->offset.seconds < newpic->offset.seconds )
|
while (*pic_ptr && (*pic_ptr)->offset.seconds < newpic->offset.seconds)
|
||||||
pic_ptr = &(*pic_ptr)->next;
|
pic_ptr = &(*pic_ptr)->next;
|
||||||
newpic->next = *pic_ptr;
|
newpic->next = *pic_ptr;
|
||||||
*pic_ptr = newpic;
|
*pic_ptr = newpic;
|
||||||
|
@ -2599,7 +2601,7 @@ void dive_add_picture(struct dive *d, struct picture *newpic)
|
||||||
unsigned int dive_get_picture_count(struct dive *d)
|
unsigned int dive_get_picture_count(struct dive *d)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
FOR_EACH_PICTURE( d )
|
FOR_EACH_PICTURE (d)
|
||||||
i++;
|
i++;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -2612,11 +2614,12 @@ void dive_set_geodata_from_picture(struct dive *d, struct picture *pic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void picture_free( struct picture *p){
|
static void picture_free(struct picture *p)
|
||||||
|
{
|
||||||
if (!p)
|
if (!p)
|
||||||
return;
|
return;
|
||||||
free( p->filename );
|
free(p->filename);
|
||||||
free( p );
|
free(p);
|
||||||
}
|
}
|
||||||
void dive_remove_picture(char *filename)
|
void dive_remove_picture(char *filename)
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,7 +107,7 @@ int evn_allocated;
|
||||||
int evn_used;
|
int evn_used;
|
||||||
|
|
||||||
#if WE_DONT_USE_THIS /* we need to implement event filters in Qt */
|
#if WE_DONT_USE_THIS /* we need to implement event filters in Qt */
|
||||||
int evn_foreach(void (*callback)(const char *, bool *, void *), void *data) {
|
int evn_foreach (void (*callback)(const char *, bool *, void *), void *data) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < evn_used; i++) {
|
for (i = 0; i < evn_used; i++) {
|
||||||
|
@ -786,7 +786,7 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru
|
||||||
double m_value = buehlmann_inertgas_a[j] + entry->ambpressure / buehlmann_inertgas_b[j];
|
double m_value = buehlmann_inertgas_a[j] + entry->ambpressure / buehlmann_inertgas_b[j];
|
||||||
entry->ceilings[j] = deco_allowed_depth(tolerated_by_tissue[j], surface_pressure, dive, 1);
|
entry->ceilings[j] = deco_allowed_depth(tolerated_by_tissue[j], surface_pressure, dive, 1);
|
||||||
entry->percentages[j] = tissue_inertgas_saturation[j] < entry->ambpressure ?
|
entry->percentages[j] = tissue_inertgas_saturation[j] < entry->ambpressure ?
|
||||||
tissue_inertgas_saturation[j] / entry->ambpressure * AMB_PERCENTAGE:
|
tissue_inertgas_saturation[j] / entry->ambpressure * AMB_PERCENTAGE :
|
||||||
AMB_PERCENTAGE + (tissue_inertgas_saturation[j] - entry->ambpressure) / (m_value - entry->ambpressure) * (100.0 - AMB_PERCENTAGE);
|
AMB_PERCENTAGE + (tissue_inertgas_saturation[j] - entry->ambpressure) / (m_value - entry->ambpressure) * (100.0 - AMB_PERCENTAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue