Skip to content

Commit

Permalink
remove some unused code. (GPSBabel#976)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteven4 authored Jan 8, 2023
1 parent cfe18de commit 70b6418
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 70 deletions.
61 changes: 0 additions & 61 deletions gbser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,67 +44,6 @@ int gbser_set_speed(void* handle, unsigned speed)
return gbser_set_port(handle, speed, 8, 0, 1);
}

static int parity_letter(char c)
{
switch (c) {
case 'N':
case 'n':
return 0;
case 'O':
case 'o':
return 1;
case 'E':
case 'e':
return 2;
default:
return -1;
}
}

/* Set the serial port up by parsing the supplied parameter string.
* Valid parameter strings look like '4800,8,N,1'. Parsing is case-
* insensitive, spaces are allowed around the commas and omitted
* trailing fields will default to '8', 'N' and '1'
*/
int gbser_setup(void* handle, const char* spec)
{
unsigned arg[] = { 4800, 8, 0, 1 };

for (unsigned int ap = 0; ap < sizeof(arg) / sizeof(arg[0]); ap++) {
unsigned t = 0;
int pl;
while (isspace(*spec)) {
spec++;
}
/* Allow 'N', 'O' or 'E' as the parity spec */
if (ap == 2 && (pl = parity_letter(*spec), pl >= 0)) {
t = pl;
spec++;
} else {
if (!isdigit(*spec)) {
break;
}
while (isdigit(*spec)) {
t = t * 10 + *spec++ - '0';
}
}
arg[ap] = t;
while (isspace(*spec)) {
spec++;
}
if (*spec != ',') {
break;
}
spec++;
}

if (*spec != '\0') {
return gbser_ERROR;
}

return gbser_set_port(handle, arg[0], arg[1], arg[2], arg[3]);
}

/* Return true if there are characters available on the serial port
*/
int gbser_avail(void* handle)
Expand Down
7 changes: 0 additions & 7 deletions gbser.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ int gbser_set_port(void* handle, unsigned speed,
unsigned parity,
unsigned stop);

/* Set the serial port up by parsing the supplied parameter string.
* Valid parameter strings look like '4800,8,N,1'. Parsing is case-
* insensitive, spaces are allowed around the commas and omitted
* trailing fields will default to '8', 'N' and '1'
*/
int gbser_setup(void* handle, const char* spec);

/* Return true if there are characters available on the serial port
*/
int gbser_avail(void* handle);
Expand Down
2 changes: 1 addition & 1 deletion gbser_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
#define BUFSIZE 512

void gbser_db(int l, const char* msg, ...);
int gbser_fill_buffer(void* h, unsigned want, unsigned* ms);
int gbser_fill_buffer(void* handle, unsigned want, unsigned* ms);
unsigned gbser_read_buffer(void* handle, void** buf, unsigned* len);
#endif // GBSER_PRIVATE_H_
2 changes: 1 addition & 1 deletion gbser_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int set_rx_timeout(gbser_handle* h, DWORD timeout)
*
* Worse still, Win98 and ME fail the open if you rename com1 to be \\.\\com1:
*
* It returns a pointer to a staticly allocated buffer and is therefore not
* It returns a pointer to a statically allocated buffer and is therefore not
* thread safe. The buffer pointed to remains valid only until the next
* call to this function.
*/
Expand Down

0 comments on commit 70b6418

Please sign in to comment.