@@ -44,12 +44,9 @@ static int load_terminfo() {
44
44
}
45
45
46
46
/* Converts termcap data type to capname */
47
- static char * capname (int i ) {
48
-
49
- char * names [] = {"bold" , "snrmq" , "ssubm" , "ssupm" , "smul" , "sitm" , "sgr0" };
50
-
51
- return names [i ];
52
- }
47
+ static char * capnames [] = {
48
+ "bold" , "snrmq" , "ssubm" , "ssupm" , "smul" , "sitm" , "sgr0"
49
+ };
53
50
54
51
#endif /* NCURSES support? */
55
52
@@ -77,16 +74,17 @@ value caml_tgetstr(value id) {
77
74
in. */
78
75
#ifdef NCURSES
79
76
if (load_terminfo () == 0 ) {
80
- char * name = capname ( Int_val (id )) ;
77
+ char * name = capnames [ Int_val (id )] ;
81
78
termdata = tigetstr (name );
82
79
}
83
80
#endif /* NCURSES */
84
81
85
82
/* Note that tigetstr will return either 0 or -1 on error. */
86
83
if (termdata == NULL || termdata == (char * )(-1 )) {
87
- result = caml_copy_string ( "" );
84
+ result = Val_int ( 0 ); /* None */
88
85
} else {
89
- result = caml_copy_string (termdata );
86
+ result = caml_alloc_small (1 , 0 ); /* Some string */
87
+ Field (result , 0 ) = caml_copy_string (termdata );
90
88
/* apparently we're not supposed to free termdata here */
91
89
/* TEMP: I cannot find specs on this! */
92
90
//free(termdata);
0 commit comments