Opened 19 years ago

Closed 19 years ago

Last modified 19 years ago

#265 closed bug (fixed)

The value of get_tty_index is not correct.

Reported by: bxi07354@… Owned by: axeld
Priority: normal Milestone: R1
Component: System/Kernel Version:
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

src/add-ons/kernel/drivers/tty/tty.cpp

sample code #include <SupportDefs.h> #include <stdio.h>

int32 get_tty_index_org(const char *name) {

device names follow this form: "pt/%c%x" int8 digit = name[4]; if (digit >= 'a')

digit -= 'a';

else

digit -= '0';

return (name[3] - 'p') * digit;

}

int32 get_tty_index(const char *name) {

device names follow this form: "pt/%c%x" int8 digit = name[4]; if (digit >= 'a')

digit -= 'a'-10;

else

digit -= '0';

return (name[3] - 'p') * 16 + digit;

}

int main(int argc, char argv) {

char name[] = "pt/p0"; for (int i= 'p'; i <= 's'; i++) for (char *h = "0123456789abcdef"; *h; h++) {

name[3] = i; name[4] = *h; printf("%s %d %d\n", name, get_tty_index_org(name),get_tty_index(name));

}

}

result pt/p0 0 0 pt/p1 0 1 pt/p2 0 2 pt/p3 0 3 pt/p4 0 4 pt/p5 0 5 pt/p6 0 6 pt/p7 0 7 pt/p8 0 8 pt/p9 0 9 pt/pa 0 10 pt/pb 0 11 pt/pc 0 12 pt/pd 0 13 pt/pe 0 14 pt/pf 0 15 pt/q0 0 16 pt/q1 1 17 pt/q2 2 18 pt/q3 3 19 pt/q4 4 20 pt/q5 5 21 pt/q6 6 22 pt/q7 7 23 pt/q8 8 24 pt/q9 9 25 pt/qa 0 26 pt/qb 1 27 pt/qc 2 28 pt/qd 3 29 pt/qe 4 30 pt/qf 5 31 pt/hrev0 0 32 pt/hrev1 2 33 pt/hrev2 4 34 pt/hrev3 6 35 pt/hrev4 8 36 pt/hrev5 10 37 pt/hrev6 12 38 pt/hrev7 14 39 pt/hrev8 16 40 pt/hrev9 18 41 pt/ra 0 42 pt/rb 2 43 pt/rc 4 44 pt/rd 6 45 pt/re 8 46 pt/rf 10 47 pt/s0 0 48 pt/s1 3 49 pt/s2 6 50 pt/s3 9 51 pt/s4 12 52 pt/s5 15 53 pt/s6 18 54 pt/s7 21 55 pt/s8 24 56 pt/s9 27 57 pt/sa 0 58 pt/sb 3 59 pt/sc 6 60 pt/sd 9 61 pt/se 12 62 pt/sf 15 63

Change History (4)

comment:1 by axeld, 19 years ago

Status: newclosed

comment:2 by axeld, 19 years ago

Resolution: fixed

comment:3 by axeld, 19 years ago

Fixed in hrev16624, thanks!

comment:4 by bxi07354@…, 19 years ago

thanks

Note: See TracTickets for help on using tickets.