static int tbaudrate(char *rate) { const SPEEDS *sp; int found = FALSE; /* The baudrate number can be preceded by a 'B', which is ignored. */ if (*rate == 'B') ++rate; for (sp = speeds; sp->string; ++sp) { if (!CaselessCmp(rate, sp->string)) { found = TRUE; break; } } if (!found) err("unknown baud rate %s", rate); return (sp->speed); }
static int tbaudrate(char *rate) { const SPEEDS *sp = 0; size_t n; /* The baudrate number can be preceded by a 'B', which is ignored. */ if (*rate == 'B') ++rate; for (n = 0; n < SIZEOF(speeds); ++n) { if (n > 0 && (speeds[n].speed <= speeds[n - 1].speed)) { /* if the speeds are not increasing, likely a numeric overflow */ break; } if (!CaselessCmp(rate, speeds[n].string)) { sp = speeds + n; break; } } if (sp == 0) err("unknown baud rate %s", rate); return (sp->speed); }