]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/edit_field.c
ncurses 6.0 - patch 20151205
[ncurses.git] / test / edit_field.c
index 7b83bd2ae864e65cbd45905c398ffd8b95c57e66..8c58cd6a6bf5d25ef503ad1bf3e0c34aab68eb78 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2003-2008,2011 Free Software Foundation, Inc.              *
+ * Copyright (c) 2003-2013,2014 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: edit_field.c,v 1.21 2013/06/08 21:38:12 tom Exp $
+ * $Id: edit_field.c,v 1.24 2014/09/05 08:39:52 tom Exp $
  *
  * A wrapper for form_driver() which keeps track of the user's editing changes
  * for each field, and makes the resulting length available as a
@@ -325,17 +325,22 @@ set_buffer_length(FIELD * f, int length)
 void
 init_edit_field(FIELD * f, char *value)
 {
+    char empty[1];
     FieldAttrs *ptr = field_attrs(f);
     if (ptr == 0) {
        int rows, cols, frow, fcol, nrow, nbuf;
 
-       ptr = typeCalloc(FieldAttrs, 1);
+       ptr = typeCalloc(FieldAttrs, (size_t) 1);
        ptr->background = field_back(f);
        if (field_info(f, &rows, &cols, &frow, &fcol, &nrow, &nbuf) == E_OK) {
            ptr->row_count = nrow;
            ptr->row_lengths = typeCalloc(int, (size_t) nrow + 1);
        }
     }
+    if (value == 0) {
+       value = empty;
+       *value = '\0';
+    }
     set_field_userptr(f, (void *) ptr);
     set_field_buffer(f, 0, value);     /* will be formatted */
     set_field_buffer(f, 1, value);     /* will be unformatted */
@@ -384,7 +389,7 @@ edit_field(FORM * form, int *result)
            length = before_off;
            break;
        case REQ_CLR_EOL:
-           if (before_row + 1 == before->rows)
+           if ((int) (before_row + 1) == (int) (before->rows))
                length = before_off;
            break;
        case REQ_CLR_FIELD: