Remove trailing LF in CSV data.

This commit is contained in:
Serge Vakulenko 2018-09-24 12:37:14 -07:00
parent 72f7e1b972
commit 44e91e8ff5

View File

@ -214,7 +214,7 @@ typedef struct {
receive_tone : 1, // Call Receive Tone: No or yes receive_tone : 1, // Call Receive Tone: No or yes
_unused2 : 2; // 0b11 _unused2 : 2; // 0b11
// Bytes 4-19 // Bytes 4-35
uint16_t name[16]; // Contact Name (Unicode) uint16_t name[16]; // Contact Name (Unicode)
} contact_t; } contact_t;
@ -2442,6 +2442,11 @@ static void uv380_write_csv(radio_device_t *radio, FILE *csv)
continue; continue;
} }
// Strip trailing spaces and newline.
char *e = line + strlen(line) - 1;
while (e >= line && (*e=='\n' || *e=='\r' || *e==' ' || *e=='\t'))
*e-- = 0;
id = strtoul(line, 0, 10); id = strtoul(line, 0, 10);
if (id < 1 || id > 0xffffff) { if (id < 1 || id > 0xffffff) {
fprintf(stderr, "Bad id: %d\n", id); fprintf(stderr, "Bad id: %d\n", id);
@ -2464,8 +2469,8 @@ static void uv380_write_csv(radio_device_t *radio, FILE *csv)
return; return;
} }
*name++ = 0; *name++ = 0;
//printf("%-10d%-10s%s\n", id, callsign, name);
//printf("%-10d%-10s%s", id, callsign, name);
cs = GET_CALLSIGN(mem, nrecords); cs = GET_CALLSIGN(mem, nrecords);
nrecords++; nrecords++;