]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[readline] Add init_editstring() wrapper function
authorMichael Brown <mcb30@ipxe.org>
Tue, 29 Mar 2011 15:34:07 +0000 (16:34 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 30 Mar 2011 16:12:10 +0000 (17:12 +0100)
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>
src/hci/mucurses/widgets/editbox.c
src/hci/readline.c
src/include/ipxe/editstring.h

index 40e22d629dcd591564802d3471ee62457a2efc56..5d2ba56cc9cc7ec93ef95b5d5bbff6eac91aad36 100644 (file)
@@ -46,8 +46,7 @@ void init_editbox ( struct edit_box *box, char *buf, size_t len,
                    WINDOW *win, unsigned int row, unsigned int col,
                    unsigned int width, unsigned int flags ) {
        memset ( box, 0, sizeof ( *box ) );
-       box->string.buf = buf;
-       box->string.len = len;
+       init_editstring ( &box->string, buf, len );
        box->string.cursor = strlen ( buf );
        box->win = ( win ? win : stdscr );
        box->row = row;
index e76d2d09aaae7ce3d3003299928467360ec6ea51..666ebf0c46b4ff864b59408ebc3d6e81e1633e33 100644 (file)
@@ -93,8 +93,7 @@ char * readline ( const char *prompt ) {
                printf ( "%s", prompt );
 
        memset ( &string, 0, sizeof ( string ) );
-       string.buf = buf;
-       string.len = sizeof ( buf );
+       init_editstring ( &string, buf, sizeof ( buf ) );
        buf[0] = '\0';
 
        while ( 1 ) {
index 5c1a18bea1f45857e069a73405267f8de60228d3..26cb434cfda1ff1fccca24902c0d499fe6c1ef36 100644 (file)
@@ -28,6 +28,19 @@ struct edit_string {
        unsigned int mod_end;
 };
 
+/**
+ * Initialise editable string
+ *
+ * @v string           Editable string
+ * @v buf              Buffer for string
+ * @v len              Length of buffer
+ */
+static inline void init_editstring ( struct edit_string *string, char *buf,
+                                    size_t len ) {
+       string->buf = buf;
+       string->len = len;
+}
+
 extern int edit_string ( struct edit_string *string, int key ) __nonnull;
 
 #endif /* _IPXE_EDITSTRING_H */