mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Whitespace cleanup for parse-xml.c and save-xml.c
This is looking really good. Done using our whitespace tool. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
42f32671a8
commit
e80a6822d5
2 changed files with 270 additions and 263 deletions
103
parse-xml.c
103
parse-xml.c
|
@ -68,7 +68,7 @@ static void record_dive_to_table(struct dive *dive, struct dive_table *table)
|
|||
table->allocated = allocated;
|
||||
}
|
||||
dives[nr] = fixup_dive(dive);
|
||||
table->nr = nr+1;
|
||||
table->nr = nr + 1;
|
||||
}
|
||||
|
||||
void record_dive(struct dive *dive)
|
||||
|
@ -97,7 +97,8 @@ static int match(const char *pattern, int plen,
|
|||
matchfn_t fn, char *buf, void *data)
|
||||
{
|
||||
switch (name[plen]) {
|
||||
case '\0': case '.':
|
||||
case '\0':
|
||||
case '.':
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -127,11 +128,11 @@ static struct {
|
|||
const char *name;
|
||||
} cur_event;
|
||||
static struct {
|
||||
struct {
|
||||
struct {
|
||||
const char *model;
|
||||
uint32_t deviceid;
|
||||
const char *nickname, *serial_nr, *firmware;
|
||||
} dc;
|
||||
} dc;
|
||||
} cur_settings;
|
||||
static bool in_settings = false;
|
||||
static struct tm cur_tm;
|
||||
|
@ -145,7 +146,7 @@ static int lastcylinderindex, lastsensor;
|
|||
*/
|
||||
static struct divecomputer *get_dc(void)
|
||||
{
|
||||
return cur_dc ? : &cur_dive->dc;
|
||||
return cur_dc ?: &cur_dive->dc;
|
||||
}
|
||||
|
||||
static enum import_source {
|
||||
|
@ -157,11 +158,13 @@ static enum import_source {
|
|||
|
||||
static void divedate(char *buffer, void *_when)
|
||||
{
|
||||
int d,m,y;
|
||||
int hh,mm,ss;
|
||||
int d, m, y;
|
||||
int hh, mm, ss;
|
||||
timestamp_t *when = _when;
|
||||
|
||||
hh = 0; mm = 0; ss = 0;
|
||||
hh = 0;
|
||||
mm = 0;
|
||||
ss = 0;
|
||||
if (sscanf(buffer, "%d.%d.%d %d:%d:%d", &d, &m, &y, &hh, &mm, &ss) >= 3) {
|
||||
/* This is ok, and we got at least the date */
|
||||
} else if (sscanf(buffer, "%d-%d-%d %d:%d:%d", &y, &m, &d, &hh, &mm, &ss) >= 3) {
|
||||
|
@ -171,7 +174,7 @@ static void divedate(char *buffer, void *_when)
|
|||
return;
|
||||
}
|
||||
cur_tm.tm_year = y;
|
||||
cur_tm.tm_mon = m-1;
|
||||
cur_tm.tm_mon = m - 1;
|
||||
cur_tm.tm_mday = d;
|
||||
cur_tm.tm_hour = hh;
|
||||
cur_tm.tm_min = mm;
|
||||
|
@ -182,7 +185,7 @@ static void divedate(char *buffer, void *_when)
|
|||
|
||||
static void divetime(char *buffer, void *_when)
|
||||
{
|
||||
int h,m,s = 0;
|
||||
int h, m, s = 0;
|
||||
timestamp_t *when = _when;
|
||||
|
||||
if (sscanf(buffer, "%d:%d:%d", &h, &m, &s) >= 2) {
|
||||
|
@ -196,14 +199,14 @@ static void divetime(char *buffer, void *_when)
|
|||
/* Libdivecomputer: "2011-03-20 10:22:38" */
|
||||
static void divedatetime(char *buffer, void *_when)
|
||||
{
|
||||
int y,m,d;
|
||||
int hr,min,sec;
|
||||
int y, m, d;
|
||||
int hr, min, sec;
|
||||
timestamp_t *when = _when;
|
||||
|
||||
if (sscanf(buffer, "%d-%d-%d %d:%d:%d",
|
||||
&y, &m, &d, &hr, &min, &sec) == 6) {
|
||||
cur_tm.tm_year = y;
|
||||
cur_tm.tm_mon = m-1;
|
||||
cur_tm.tm_mon = m - 1;
|
||||
cur_tm.tm_mday = d;
|
||||
cur_tm.tm_hour = hr;
|
||||
cur_tm.tm_min = min;
|
||||
|
@ -212,7 +215,10 @@ static void divedatetime(char *buffer, void *_when)
|
|||
}
|
||||
}
|
||||
|
||||
enum ParseState {FINDSTART, FINDEND};
|
||||
enum ParseState {
|
||||
FINDSTART,
|
||||
FINDEND
|
||||
};
|
||||
static void divetags(char *buffer, void *_tags)
|
||||
{
|
||||
struct tag_entry *tags = _tags;
|
||||
|
@ -220,7 +226,7 @@ static void divetags(char *buffer, void *_tags)
|
|||
enum ParseState state = FINDEND;
|
||||
int len = buffer ? strlen(buffer) : 0;
|
||||
|
||||
while(i < len) {
|
||||
while (i < len) {
|
||||
if (buffer[i] == ',') {
|
||||
if (state == FINDSTART) {
|
||||
/* Detect empty tags */
|
||||
|
@ -228,10 +234,10 @@ static void divetags(char *buffer, void *_tags)
|
|||
/* Found end of tag */
|
||||
if (i > 0 && buffer[i - 1] != '\\') {
|
||||
buffer[i] = '\0';
|
||||
state=FINDSTART;
|
||||
taglist_add_tag(tags, buffer+start);
|
||||
state = FINDSTART;
|
||||
taglist_add_tag(tags, buffer + start);
|
||||
} else {
|
||||
state=FINDSTART;
|
||||
state = FINDSTART;
|
||||
}
|
||||
}
|
||||
} else if (buffer[i] == ' ') {
|
||||
|
@ -430,7 +436,7 @@ static void sampletime(char *buffer, void *_time)
|
|||
min = 0;
|
||||
/* fallthrough */
|
||||
case 2:
|
||||
time->seconds = sec + min*60;
|
||||
time->seconds = sec + min * 60;
|
||||
break;
|
||||
default:
|
||||
printf("Strange sample time reading %s\n", buffer);
|
||||
|
@ -442,9 +448,9 @@ static void duration(char *buffer, void *_time)
|
|||
/* DivingLog 5.08 (and maybe other versions) appear to sometimes
|
||||
* store the dive time as 44.00 instead of 44:00;
|
||||
* This attempts to parse this in a fairly robust way */
|
||||
if (!strchr(buffer,':') && strchr(buffer,'.')) {
|
||||
if (!strchr(buffer, ':') && strchr(buffer, '.')) {
|
||||
char *mybuffer = strdup(buffer);
|
||||
char *dot = strchr(mybuffer,'.');
|
||||
char *dot = strchr(mybuffer, '.');
|
||||
*dot = ':';
|
||||
sampletime(mybuffer, _time);
|
||||
free(mybuffer);
|
||||
|
@ -475,7 +481,7 @@ static void percent(char *buffer, void *_fraction)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
printf(translate("gettextFromC","Strange percentage reading %s\n"), buffer);
|
||||
printf(translate("gettextFromC", "Strange percentage reading %s\n"), buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -517,7 +523,7 @@ static void utf8_string(char *buffer, void *_res)
|
|||
while (isspace(*buffer))
|
||||
buffer++;
|
||||
size = strlen(buffer);
|
||||
while (size && isspace(buffer[size-1]))
|
||||
while (size && isspace(buffer[size - 1]))
|
||||
size--;
|
||||
if (!size)
|
||||
return;
|
||||
|
@ -790,8 +796,8 @@ void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int second
|
|||
int he = get_he(&dive->cylinder[idx].gasmix);
|
||||
int value;
|
||||
|
||||
o2 = (o2+5) / 10;
|
||||
he = (he+5) / 10;
|
||||
o2 = (o2 + 5) / 10;
|
||||
he = (he + 5) / 10;
|
||||
value = o2 + (he << 16);
|
||||
|
||||
add_event(dc, seconds, 25, 0, value, "gaschange"); /* SAMPLE_EVENT_GASCHANGE2 */
|
||||
|
@ -891,8 +897,8 @@ static void divinglog_place(char *place, void *_location)
|
|||
country ? ", " : "",
|
||||
country ? country : "");
|
||||
|
||||
p = malloc(len+1);
|
||||
memcpy(p, buffer, len+1);
|
||||
p = malloc(len + 1);
|
||||
memcpy(p, buffer, len + 1);
|
||||
*location = p;
|
||||
|
||||
city = NULL;
|
||||
|
@ -927,7 +933,7 @@ static int divinglog_dive_match(struct dive *dive, const char *name, char *buf)
|
|||
static void uddf_datetime(char *buffer, void *_when)
|
||||
{
|
||||
char c;
|
||||
int y,m,d,hh,mm,ss;
|
||||
int y, m, d, hh, mm, ss;
|
||||
timestamp_t *when = _when;
|
||||
struct tm tm = { 0 };
|
||||
int i;
|
||||
|
@ -962,10 +968,12 @@ success:
|
|||
}
|
||||
|
||||
#define uddf_datedata(name, offset) \
|
||||
static void uddf_##name(char *buffer, void *_when) \
|
||||
{ timestamp_t *when = _when; \
|
||||
static void uddf_##name(char *buffer, void *_when) \
|
||||
{ \
|
||||
timestamp_t *when = _when; \
|
||||
cur_tm.tm_##name = atoi(buffer) + offset; \
|
||||
*when = utc_mktime(&cur_tm); }
|
||||
*when = utc_mktime(&cur_tm); \
|
||||
}
|
||||
|
||||
uddf_datedata(year, 0)
|
||||
uddf_datedata(mon, -1)
|
||||
|
@ -1006,7 +1014,7 @@ static degrees_t parse_degrees(char *buf, char **end)
|
|||
buf++;
|
||||
}
|
||||
while (isdigit(*buf)) {
|
||||
value = 10*value + *buf - '0';
|
||||
value = 10 * value + *buf - '0';
|
||||
buf++;
|
||||
}
|
||||
|
||||
|
@ -1425,7 +1433,7 @@ static const char *nodename(xmlNode *node, char *buf, int len)
|
|||
/* Make sure it's always NUL-terminated */
|
||||
p[--len] = 0;
|
||||
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
const char *name = node->name;
|
||||
char c;
|
||||
while ((c = *name++) != 0) {
|
||||
|
@ -1534,9 +1542,8 @@ static struct nesting {
|
|||
/* Import type recognition */
|
||||
{ "Divinglog", DivingLog_importer },
|
||||
{ "uddf", uddf_importer },
|
||||
|
||||
{ NULL, }
|
||||
};
|
||||
};
|
||||
|
||||
static void traverse(xmlNode *root)
|
||||
{
|
||||
|
@ -1615,8 +1622,8 @@ void parse_xml_buffer(const char *url, const char *buffer, int size,
|
|||
free((char *)res);
|
||||
|
||||
if (!doc) {
|
||||
fprintf(stderr, translate("gettextFromC","Failed to parse '%s'.\n"), url);
|
||||
parser_error(error, translate("gettextFromC","Failed to parse '%s'"), url);
|
||||
fprintf(stderr, translate("gettextFromC", "Failed to parse '%s'.\n"), url);
|
||||
parser_error(error, translate("gettextFromC", "Failed to parse '%s'"), url);
|
||||
return;
|
||||
}
|
||||
reset_all();
|
||||
|
@ -1817,7 +1824,7 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
|
|||
profileBlob = (float *)data[17];
|
||||
tempBlob = (unsigned char *)data[18];
|
||||
pressureBlob = (int *)data[19];
|
||||
for (i=0; interval && i * interval < cur_dive->duration.seconds; i++) {
|
||||
for (i = 0; interval && i * interval < cur_dive->duration.seconds; i++) {
|
||||
sample_start();
|
||||
cur_sample->time.seconds = i * interval;
|
||||
if (profileBlob)
|
||||
|
@ -1828,21 +1835,21 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
|
|||
if (data[18] && data[18][0])
|
||||
cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]);
|
||||
if (data[19] && data[19][0])
|
||||
cur_sample->cylinderpressure.mbar = pressureBlob[i] ;
|
||||
cur_sample->cylinderpressure.mbar = pressureBlob[i];
|
||||
sample_end();
|
||||
}
|
||||
|
||||
snprintf(get_events, sizeof(get_events) - 1, get_events_template, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_events, &dm4_events, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, "%s", translate("gettextFromC","Database query get_events failed.\n"));
|
||||
fprintf(stderr, "%s", translate("gettextFromC", "Database query get_events failed.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
snprintf(get_events, sizeof(get_events) - 1, get_tags_template, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_events, &dm4_tags, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, "%s", translate("gettextFromC","Database query get_tags failed.\n"));
|
||||
fprintf(stderr, "%s", translate("gettextFromC", "Database query get_tags failed.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1876,7 +1883,7 @@ int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buffer, int s
|
|||
retval = sqlite3_exec(handle, get_dives, &dm4_dive, handle, &err);
|
||||
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, translate("gettextFromC","Database query failed '%s'.\n"), url);
|
||||
fprintf(stderr, translate("gettextFromC", "Database query failed '%s'.\n"), url);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1987,21 +1994,21 @@ extern int shearwater_dive(void *param, int columns, char **data, char **column)
|
|||
snprintf(get_buffer, sizeof(get_buffer) - 1, get_cylinder_template, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_buffer, &shearwater_cylinders, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, "%s", translate("gettextFromC","Database query get_cylinders failed.\n"));
|
||||
fprintf(stderr, "%s", translate("gettextFromC", "Database query get_cylinders failed.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
snprintf(get_buffer, sizeof(get_buffer) - 1, get_changes_template, cur_dive->number, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_buffer, &shearwater_changes, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, "%s", translate("gettextFromC","Database query get_changes failed.\n"));
|
||||
fprintf(stderr, "%s", translate("gettextFromC", "Database query get_changes failed.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
snprintf(get_buffer, sizeof(get_buffer) - 1, get_profile_template, cur_dive->number);
|
||||
retval = sqlite3_exec(handle, get_buffer, &shearwater_profile_sample, 0, &err);
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, "%s", translate("gettextFromC","Database query get_profile_sample failed.\n"));
|
||||
fprintf(stderr, "%s", translate("gettextFromC", "Database query get_profile_sample failed.\n"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2023,7 +2030,7 @@ int parse_shearwater_buffer(sqlite3 *handle, const char *url, const char *buffer
|
|||
retval = sqlite3_exec(handle, get_dives, &shearwater_dive, handle, &err);
|
||||
|
||||
if (retval != SQLITE_OK) {
|
||||
fprintf(stderr, translate("gettextFromC","Database query failed '%s'.\n"), url);
|
||||
fprintf(stderr, translate("gettextFromC", "Database query failed '%s'.\n"), url);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2059,7 +2066,7 @@ static struct xslt_files {
|
|||
{ "sensuscsv", "sensuscsv.xslt", NULL },
|
||||
{ "manualcsv", "manualcsv2xml.xslt", NULL },
|
||||
{ NULL, }
|
||||
};
|
||||
};
|
||||
|
||||
static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params, char **error)
|
||||
{
|
||||
|
@ -2092,7 +2099,7 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params, char **err
|
|||
xmlSubstituteEntitiesDefault(1);
|
||||
xslt = get_stylesheet(info->file);
|
||||
if (xslt == NULL) {
|
||||
parser_error(error, translate("gettextFromC","Can't open stylesheet %s"), info->file);
|
||||
parser_error(error, translate("gettextFromC", "Can't open stylesheet %s"), info->file);
|
||||
return doc;
|
||||
}
|
||||
transformed = xsltApplyStylesheet(xslt, doc, params);
|
||||
|
|
62
save-xml.c
62
save-xml.c
|
@ -34,7 +34,8 @@ static void quote(struct membuffer *b, const char *text, int is_attribute)
|
|||
escape = NULL;
|
||||
break;
|
||||
case 1 ... 8:
|
||||
case 11: case 12:
|
||||
case 11:
|
||||
case 12:
|
||||
case 14 ... 31:
|
||||
escape = "?";
|
||||
break;
|
||||
|
@ -77,7 +78,7 @@ static void show_utf8(struct membuffer *b, const char *text, const char *pre, co
|
|||
len = strlen(text);
|
||||
if (!len)
|
||||
return;
|
||||
while (len && isspace(text[len-1]))
|
||||
while (len && isspace(text[len - 1]))
|
||||
len--;
|
||||
/* FIXME! Quoting! */
|
||||
put_string(b, pre);
|
||||
|
@ -163,9 +164,9 @@ static int format_location(char *buffer, degrees_t latitude, degrees_t longitude
|
|||
{
|
||||
int len = sprintf(buffer, "gps='");
|
||||
|
||||
len += format_degrees(buffer+len, latitude);
|
||||
len += format_degrees(buffer + len, latitude);
|
||||
buffer[len++] = ' ';
|
||||
len += format_degrees(buffer+len, longitude);
|
||||
len += format_degrees(buffer + len, longitude);
|
||||
buffer[len++] = '\'';
|
||||
|
||||
return len;
|
||||
|
@ -187,9 +188,9 @@ static void show_location(struct membuffer *b, struct dive *dive)
|
|||
if (latitude.udeg || longitude.udeg) {
|
||||
int len = sprintf(buffer, " <location ");
|
||||
|
||||
len += format_location(buffer+len, latitude, longitude);
|
||||
len += format_location(buffer + len, latitude, longitude);
|
||||
if (!dive->location) {
|
||||
memcpy(buffer+len, "/>\n", 4);
|
||||
memcpy(buffer + len, "/>\n", 4);
|
||||
put_string(b, buffer);
|
||||
return;
|
||||
}
|
||||
|
@ -197,16 +198,16 @@ static void show_location(struct membuffer *b, struct dive *dive)
|
|||
buffer[len] = 0;
|
||||
prefix = buffer;
|
||||
}
|
||||
show_utf8(b, dive->location, prefix,"</location>\n", 0);
|
||||
show_utf8(b, dive->location, prefix, "</location>\n", 0);
|
||||
}
|
||||
|
||||
static void save_overview(struct membuffer *b, struct dive *dive)
|
||||
{
|
||||
show_location(b, dive);
|
||||
show_utf8(b, dive->divemaster, " <divemaster>","</divemaster>\n", 0);
|
||||
show_utf8(b, dive->buddy, " <buddy>","</buddy>\n", 0);
|
||||
show_utf8(b, dive->notes, " <notes>","</notes>\n", 0);
|
||||
show_utf8(b, dive->suit, " <suit>","</suit>\n", 0);
|
||||
show_utf8(b, dive->divemaster, " <divemaster>", "</divemaster>\n", 0);
|
||||
show_utf8(b, dive->buddy, " <buddy>", "</buddy>\n", 0);
|
||||
show_utf8(b, dive->notes, " <notes>", "</notes>\n", 0);
|
||||
show_utf8(b, dive->suit, " <suit>", "</suit>\n", 0);
|
||||
}
|
||||
|
||||
static int nr_cylinders(struct dive *dive)
|
||||
|
@ -214,7 +215,7 @@ static int nr_cylinders(struct dive *dive)
|
|||
int nr;
|
||||
|
||||
for (nr = MAX_CYLINDERS; nr; --nr) {
|
||||
cylinder_t *cylinder = dive->cylinder+nr-1;
|
||||
cylinder_t *cylinder = dive->cylinder + nr - 1;
|
||||
if (!cylinder_nodata(cylinder))
|
||||
break;
|
||||
}
|
||||
|
@ -228,7 +229,7 @@ static void save_cylinder_info(struct membuffer *b, struct dive *dive)
|
|||
nr = nr_cylinders(dive);
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
cylinder_t *cylinder = dive->cylinder+i;
|
||||
cylinder_t *cylinder = dive->cylinder + i;
|
||||
int volume = cylinder->type.size.mliter;
|
||||
const char *description = cylinder->type.description;
|
||||
int o2 = cylinder->gasmix.o2.permille;
|
||||
|
@ -255,7 +256,7 @@ static int nr_weightsystems(struct dive *dive)
|
|||
int nr;
|
||||
|
||||
for (nr = MAX_WEIGHTSYSTEMS; nr; --nr) {
|
||||
weightsystem_t *ws = dive->weightsystem+nr-1;
|
||||
weightsystem_t *ws = dive->weightsystem + nr - 1;
|
||||
if (!weightsystem_none(ws))
|
||||
break;
|
||||
}
|
||||
|
@ -269,7 +270,7 @@ static void save_weightsystem_info(struct membuffer *b, struct dive *dive)
|
|||
nr = nr_weightsystems(dive);
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
weightsystem_t *ws = dive->weightsystem+i;
|
||||
weightsystem_t *ws = dive->weightsystem + i;
|
||||
int grams = ws->weight.grams;
|
||||
const char *description = ws->description;
|
||||
|
||||
|
@ -288,7 +289,7 @@ static void show_index(struct membuffer *b, int value, const char *pre, const ch
|
|||
|
||||
static void save_sample(struct membuffer *b, struct sample *sample, struct sample *old)
|
||||
{
|
||||
put_format(b, " <sample time='%u:%02u min'", FRACTION(sample->time.seconds,60));
|
||||
put_format(b, " <sample time='%u:%02u min'", FRACTION(sample->time.seconds, 60));
|
||||
put_milli(b, " depth='", sample->depth.mm, " m'");
|
||||
put_temperature(b, sample->temperature, " temp='", " C'");
|
||||
put_pressure(b, sample->cylinderpressure, " pressure='", " bar'");
|
||||
|
@ -337,7 +338,7 @@ static void save_sample(struct membuffer *b, struct sample *sample, struct sampl
|
|||
|
||||
static void save_one_event(struct membuffer *b, struct event *ev)
|
||||
{
|
||||
put_format(b, " <event time='%d:%02d min'", FRACTION(ev->time.seconds,60));
|
||||
put_format(b, " <event time='%d:%02d min'", FRACTION(ev->time.seconds, 60));
|
||||
show_index(b, ev->type, "type='", "'");
|
||||
show_index(b, ev->flags, "flags='", "'");
|
||||
show_index(b, ev->value, "value='", "'");
|
||||
|
@ -385,14 +386,14 @@ static void show_date(struct membuffer *b, timestamp_t when)
|
|||
utc_mkdate(when, &tm);
|
||||
|
||||
put_format(b, " date='%04u-%02u-%02u'",
|
||||
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday);
|
||||
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
|
||||
put_format(b, " time='%02u:%02u:%02u'",
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
}
|
||||
|
||||
static void save_samples(struct membuffer *b, int nr, struct sample *s)
|
||||
{
|
||||
struct sample dummy = { };
|
||||
struct sample dummy = {};
|
||||
|
||||
while (--nr >= 0) {
|
||||
save_sample(b, s, &dummy);
|
||||
|
@ -460,7 +461,7 @@ void save_one_dive(struct membuffer *b, struct dive *dive)
|
|||
|
||||
void save_dive(FILE *f, struct dive *dive)
|
||||
{
|
||||
struct membuffer buf = {0};
|
||||
struct membuffer buf = { 0 };
|
||||
|
||||
save_one_dive(&buf, dive);
|
||||
flush_buffer(&buf, f);
|
||||
|
@ -473,9 +474,9 @@ static void save_trip(struct membuffer *b, dive_trip_t *trip)
|
|||
|
||||
put_format(b, "<trip");
|
||||
show_date(b, trip->when);
|
||||
show_utf8(b, trip->location, " location=\'","\'", 1);
|
||||
show_utf8(b, trip->location, " location=\'", "\'", 1);
|
||||
put_format(b, ">\n");
|
||||
show_utf8(b, trip->notes, "<notes>","</notes>\n", 0);
|
||||
show_utf8(b, trip->notes, "<notes>", "</notes>\n", 0);
|
||||
|
||||
/*
|
||||
* Incredibly cheesy: we want to save the dives sorted, and they
|
||||
|
@ -491,7 +492,7 @@ static void save_trip(struct membuffer *b, dive_trip_t *trip)
|
|||
put_format(b, "</trip>\n");
|
||||
}
|
||||
|
||||
static void save_one_device(void *_f, const char * model, uint32_t deviceid,
|
||||
static void save_one_device(void *_f, const char *model, uint32_t deviceid,
|
||||
const char *nickname, const char *serial_nr, const char *firmware)
|
||||
{
|
||||
struct membuffer *b = _f;
|
||||
|
@ -549,10 +550,9 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
|
|||
|
||||
/* save the dives */
|
||||
for_each_dive(i, dive) {
|
||||
|
||||
if (select_only) {
|
||||
|
||||
if(!dive->selected)
|
||||
if (!dive->selected)
|
||||
continue;
|
||||
save_one_dive(b, dive);
|
||||
|
||||
|
@ -587,10 +587,10 @@ static void save_backup(const char *name, const char *ext, const char *new_ext)
|
|||
len -= a;
|
||||
if (len <= 1)
|
||||
return;
|
||||
if (name[len-1] != '.')
|
||||
if (name[len - 1] != '.')
|
||||
return;
|
||||
/* msvc doesn't have strncasecmp, has _strnicmp instead - crazy */
|
||||
if (strncasecmp(name+len, ext, a))
|
||||
if (strncasecmp(name + len, ext, a))
|
||||
return;
|
||||
|
||||
newname = malloc(len + b + 1);
|
||||
|
@ -598,7 +598,7 @@ static void save_backup(const char *name, const char *ext, const char *new_ext)
|
|||
return;
|
||||
|
||||
memcpy(newname, name, len);
|
||||
memcpy(newname+len, new_ext, b+1);
|
||||
memcpy(newname + len, new_ext, b + 1);
|
||||
|
||||
/*
|
||||
* Ignore errors. Maybe we can't create the backup file,
|
||||
|
@ -611,9 +611,9 @@ static void save_backup(const char *name, const char *ext, const char *new_ext)
|
|||
|
||||
void save_dives_logic(const char *filename, const bool select_only)
|
||||
{
|
||||
struct membuffer buf = {0};
|
||||
struct membuffer buf = { 0 };
|
||||
FILE *f;
|
||||
char extension[][5] = {"xml", "ssrf", ""};
|
||||
char extension[][5] = { "xml", "ssrf", "" };
|
||||
int i = 0;
|
||||
int flen = strlen(filename);
|
||||
|
||||
|
@ -638,7 +638,7 @@ void save_dives_logic(const char *filename, const bool select_only)
|
|||
void export_dives_uddf(const char *filename, const bool selected)
|
||||
{
|
||||
FILE *f;
|
||||
struct membuffer buf = {0};
|
||||
struct membuffer buf = { 0 };
|
||||
xmlDoc *doc;
|
||||
xsltStylesheetPtr xslt = NULL;
|
||||
xmlDoc *transformed;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue