Selaa lähdekoodia

[readline] Add init_editstring() wrapper function

Standardise on using init_editstring() to initialise an embedded
editable string, to match the coding style used by other embedded
objects.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 vuotta sitten
vanhempi
commit
6a6dd5c452
3 muutettua tiedostoa jossa 15 lisäystä ja 4 poistoa
  1. 1
    2
      src/hci/mucurses/widgets/editbox.c
  2. 1
    2
      src/hci/readline.c
  3. 13
    0
      src/include/ipxe/editstring.h

+ 1
- 2
src/hci/mucurses/widgets/editbox.c Näytä tiedosto

46
 		    WINDOW *win, unsigned int row, unsigned int col,
46
 		    WINDOW *win, unsigned int row, unsigned int col,
47
 		    unsigned int width, unsigned int flags ) {
47
 		    unsigned int width, unsigned int flags ) {
48
 	memset ( box, 0, sizeof ( *box ) );
48
 	memset ( box, 0, sizeof ( *box ) );
49
-	box->string.buf = buf;
50
-	box->string.len = len;
49
+	init_editstring ( &box->string, buf, len );
51
 	box->string.cursor = strlen ( buf );
50
 	box->string.cursor = strlen ( buf );
52
 	box->win = ( win ? win : stdscr );
51
 	box->win = ( win ? win : stdscr );
53
 	box->row = row;
52
 	box->row = row;

+ 1
- 2
src/hci/readline.c Näytä tiedosto

93
 		printf ( "%s", prompt );
93
 		printf ( "%s", prompt );
94
 
94
 
95
 	memset ( &string, 0, sizeof ( string ) );
95
 	memset ( &string, 0, sizeof ( string ) );
96
-	string.buf = buf;
97
-	string.len = sizeof ( buf );
96
+	init_editstring ( &string, buf, sizeof ( buf ) );
98
 	buf[0] = '\0';
97
 	buf[0] = '\0';
99
 
98
 
100
 	while ( 1 ) {
99
 	while ( 1 ) {

+ 13
- 0
src/include/ipxe/editstring.h Näytä tiedosto

28
 	unsigned int mod_end;
28
 	unsigned int mod_end;
29
 };
29
 };
30
 
30
 
31
+/**
32
+ * Initialise editable string
33
+ *
34
+ * @v string		Editable string
35
+ * @v buf		Buffer for string
36
+ * @v len		Length of buffer
37
+ */
38
+static inline void init_editstring ( struct edit_string *string, char *buf,
39
+				     size_t len ) {
40
+	string->buf = buf;
41
+	string->len = len;
42
+}
43
+
31
 extern int edit_string ( struct edit_string *string, int key ) __nonnull;
44
 extern int edit_string ( struct edit_string *string, int key ) __nonnull;
32
 
45
 
33
 #endif /* _IPXE_EDITSTRING_H */
46
 #endif /* _IPXE_EDITSTRING_H */

Loading…
Peruuta
Tallenna