]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
- cleaned up const qualifiers in interfaces
authorhavill <havill>
Fri, 3 Jan 2003 20:54:45 +0000 (20:54 +0000)
committerhavill <havill>
Fri, 3 Jan 2003 20:54:45 +0000 (20:54 +0000)
- leave the symbols in the libs (#60400)
- fixed grammar in tutorial (#63496)
- removed fifty button limit (#59027)
- error checking (curcomp exists) for formEvent, newtFormGetCurrent (#59027)

15 files changed:
checkboxtree.c
configure.in
dialogboxes.c
dialogboxes.h
entry.c
form.c
newt.h
newt.spec
snackmodule.c
test.c
testgrid.c
testtree.c
textbox.c
whiptail.c
windows.c

index 488ce92b100d62dd93e59ebbf5bc8c98805aec9e..7d9731df0fe8c7b62151771c067a13fb7335b720 100644 (file)
@@ -756,7 +756,7 @@ void newtCheckboxTreeSetEntryValue(newtComponent co, const void * data, char val
 void newtCheckboxTreeSetCurrent(newtComponent co, void * data) {
     struct CheckboxTree * ct = co->data;
     int * path;
-    int i, j, itemsAfter;
+    int i, j;
     struct items * treeTop, * item;
 
     path = newtCheckboxTreeFindItem(co, data);
index b5992aab2f07b1e9499c537e35411e2d2ad04604..d55ce2f8d51f4035765f28f958ea5e7c6383faf9 100644 (file)
@@ -5,8 +5,8 @@ AC_CONFIG_HEADER(config.h)
 
 VERSION=$(awk '/^%define version/ {print $3}' $srcdir/newt.spec)
 
-VERSION=0.51.2
-SONAME=0.51
+VERSION=0.52.0
+SONAME=0.52
 AC_SUBST(VERSION)
 AC_SUBST(SONAME)
 AC_PROG_CC
index 0ac7727900951d417a8fcfc4db2cc272cdab0e0d..736097d4d6b6ed47447d4da90276c06d701038e7 100644 (file)
@@ -129,9 +129,9 @@ int gauge(const char * text, int height, int width, poptContext optCon, int fd,
 }
 
 int inputBox(const char * text, int height, int width, poptContext optCon, 
-               int flags, char ** result) {
+               int flags, const char ** result) {
     newtComponent form, entry, okay, cancel, answer, tb;
-    char * val;
+    const char * val;
     int rc = DLG_OKAY;
     int top;
 
@@ -157,7 +157,7 @@ int inputBox(const char * text, int height, int width, poptContext optCon,
 }
 
 int listBox(const char * text, int height, int width, poptContext optCon,
-               int flags, char ** result) {
+               int flags, const char ** result) {
     newtComponent form, okay, tb, answer, listBox;
     newtComponent cancel = NULL;
     const char * arg;
@@ -241,7 +241,7 @@ int listBox(const char * text, int height, int width, poptContext optCon,
 }
 
 int checkList(const char * text, int height, int width, poptContext optCon,
-               int useRadio, int flags, char *** selections) {
+               int useRadio, int flags, const char *** selections) {
     newtComponent form, okay, tb, subform, answer;
     newtComponent sb = NULL, cancel = NULL;
     const char * arg;
index 29dab12c731e087da317adbf87d52bbf19e90087..456ab632b4ee8f86631c8dacaed11d4f52d6ea55 100644 (file)
 
 int messageBox(const char * text, int height, int width, int type, int flags);
 int checkList(const char * text, int height, int width, poptContext optCon,
-               int useRadio, int flags, char *** selections);
+               int useRadio, int flags, const char *** selections);
 int listBox(const char * text, int height, int width, poptContext optCon,
-               int flags, char ** result);
+               int flags, const char ** result);
 int inputBox(const char * text, int height, int width, poptContext optCon, 
-               int flags, char ** result);
+               int flags, const char ** result);
 int gauge(const char * text, int height, int width, poptContext optCon, int fd, 
                int flags);
 void useFullButtons(int state);
diff --git a/entry.c b/entry.c
index 7bce7ffb40ef11a2073600f1dcbfabaf827a8d3e..21ab00c01367938f5f0062089a4d039b51dcdf11 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -15,7 +15,7 @@
 struct entry {
     int flags;
     char * buf;
-    char ** resultPtr;
+    const char ** resultPtr;
     int bufAlloced;
     int bufUsed;               /* amount of the buffer that's been used */
     int cursorPosition;        /* cursor *in the string* on on screen */
@@ -61,7 +61,7 @@ void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd) {
 } ;
 
 newtComponent newtEntry(int left, int top, const char * initialValue, int width,
-                       char ** resultPtr, int flags) {
+                       const char ** resultPtr, int flags) {
     newtComponent co;
     struct entry * en;
 
diff --git a/form.c b/form.c
index 5564a748019488b31fc183cb6cb4d8825e2633de..3dd87c3fca5a968aaf32d6fb55b54979e22d04a5 100644 (file)
--- a/form.c
+++ b/form.c
@@ -486,6 +486,7 @@ newtComponent newtForm(newtComponent vertBar, void * help, int flags) {
 newtComponent newtFormGetCurrent(newtComponent co) {
     struct form * form = co->data;
 
+    if (form->currComp == -1) return 0;
     return form->elements[form->currComp].co;
 }
 
@@ -628,7 +629,7 @@ static struct eventResult formEvent(newtComponent co, struct event ev) {
     er.result = ER_IGNORED;
     if (!form->numComps) return er;
 
-    subco = form->elements[form->currComp].co;
+    if (form->currComp == -1) return er;
 
     switch (ev.when) {
       case EV_EARLY:
diff --git a/newt.h b/newt.h
index 6ffb2593913be525b764dd7ae614f7173841c287..f3f8bb298e84da1d487d62c246eb1ee9fea7c4bd 100644 (file)
--- a/newt.h
+++ b/newt.h
@@ -240,7 +240,7 @@ void newtFormAddHotKey(newtComponent co, int key);
 typedef int (*newtEntryFilter)(newtComponent entry, void * data, int ch,
                               int cursor);
 newtComponent newtEntry(int left, int top, const char * initialValue, int width,
-                       char ** resultPtr, int flags);
+                       const char ** resultPtr, int flags);
 void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd);
 void newtEntrySetFilter(newtComponent co, newtEntryFilter filter, void * data);
 char * newtEntryGetValue(newtComponent co);
@@ -356,7 +356,7 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown,
 
 struct newtWinEntry {
     char * text;
-    char ** value;             /* may be initialized to set default */
+    const char ** value;               /* may be initialized to set default */
     int flags;
 };
 
index acaf784dd3abfe940c90c00e4bd3c3dd67f48b6a..2c7f6d826adadb81ef4659b2209479f450412cad 100644 (file)
--- a/newt.spec
+++ b/newt.spec
@@ -2,7 +2,7 @@
 
 Summary: A development library for text mode user interfaces.
 Name: newt
-%define version 0.51.2
+%define version 0.52.0
 Version: %{version}
 Release: 1
 License: LGPL
@@ -44,7 +44,7 @@ newt.
 # gpm support seems to smash the stack w/ we use help in anaconda??
 #./configure --with-gpm-support
 %configure 
-make %{?_smp_mflags} all shared
+make %{?_smp_mflags} all
 chmod 0644 peanuts.py popcorn.py
 
 %install
@@ -81,6 +81,13 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/libnewt.so
 
 %changelog
+* Fri Jan  3 2003 Adrian Havill <havill@redhat.com> 0.52.0-1
+- cleaned up const qualifiers in interfaces
+- leave the symbols in the libs (#60400)
+- fixed grammar in tutorial (#63496)
+- removed fifty button limit (#59027)
+- error checking (curcomp exists) for formEvent, newtFormGetCurrent (#59027)
+
 * Tue Dec 17 2002 Matt Wilson <msw@redhat.com> 0.51.2-1
 - fixed wstrlen() it was calculating wcwidth(first wide char in
   string) * strlen(str) instead of the actual width of the whole
index 14f07847d56e0ecbc5d4d9857bb3ff9038fa7942..cb89f8c8014ff59a4b4f9112b59c02a804dcc78e 100644 (file)
@@ -727,7 +727,8 @@ static snackWidget * entryWidget(PyObject * s, PyObject * args) {
                          &isHidden, &isPassword, &isScrolled, &returnExit)) return NULL;
 
     widget = snackWidgetNew ();
-    widget->co = newtEntry(-1, -1, initial, width, (char **) &widget->apointer, 
+    widget->co = newtEntry(-1, -1, initial, width,
+                           (const char **) &widget->apointer, 
                           (isHidden ? NEWT_FLAG_HIDDEN : 0) |
                           (isPassword ? NEWT_FLAG_PASSWORD : 0) |
                           (returnExit ? NEWT_FLAG_RETURNEXIT : 0) |
diff --git a/test.c b/test.c
index 199b3eb49432325a8549337eff8878adc6f3fd4e..33be2c8e8a5bb7049c3a1530f1d7b70dfbd536ab 100644 (file)
--- a/test.c
+++ b/test.c
@@ -39,7 +39,7 @@ int main(void) {
     newtComponent f, chklist, e1;
     struct callbackInfo cbis[3];
     char results[10];
-    char * enr2, * enr3, * scaleVal;
+    const char * enr2, * enr3, *scaleVal;
     void ** selectedList;
     int i, numsel;
     char buf[20];
@@ -66,7 +66,7 @@ int main(void) {
     b1 = newtButton(3, 1, "Exit");
     b2 = newtButton(18, 1, "Update");
     r1 = newtRadiobutton(20, 10, "Choice 1", 0, NULL);
-    r2 = newtRadiobutton(20, 11, "Chc 2", 1, r1);
+    r2 = newtRadiobutton(20, 11, "Choice 2", 1, r1);
     r3 = newtRadiobutton(20, 12, "Choice 3", 0, r2);
     rsf = newtForm(NULL, NULL, 0);
     newtFormAddComponents(rsf, r1, r2, r3, NULL);
index 3bd7741c7ce3f22745ec074ebbab11a14ccc4f9e..0d3aa85f9278219d4f9fc7c6b0f918d8b49238f6 100644 (file)
@@ -12,7 +12,7 @@ int main(void) {
     char * flowedText;
     int textWidth, textHeight, rc;
     char * menuContents[] = { "One", "Two", "Three", "Four", "Five", NULL };
-    char * entries[10];
+    const char * entries[10];
     struct newtWinEntry autoEntries[] = {
        { "An entry", entries + 0, 0 },
        { "Another entry", entries + 1, 0 },
index 70523d71e622ae99e3dff2a2c631401601f2b3a1..62494b8b98ea369b6c53daf54c29ab97c298cc85 100644 (file)
@@ -11,7 +11,7 @@ int main(void) {
     newtComponent button;
     newtComponent form;
     newtComponent answer;
-    void ** result, **ptr;
+    const void **result, **ptr;
     int numselected, i, j;
     int * list;
     
index 8387185e265d0d2072cc7133d501031850126a93..68742cfef46c3720853f41ef76d467de2c44633c 100644 (file)
--- a/textbox.c
+++ b/textbox.c
@@ -196,7 +196,7 @@ static void doReflow(const char * text, char ** resultPtr, int width,
                text = end;
                if (*text) text++;
            } else {
-               char *spcptr = NULL;
+               const char *spcptr = NULL;
                int spc =0,w2, x;
 
                chptr = text;
index 7a7bda280219db11c2e70a3ac5b28423720d17f9..4aa41b02c026344872014795374bfe8d3f3b6e03 100644 (file)
@@ -48,8 +48,8 @@ int main(int argc, const char ** argv) {
     int flags = 0;
     int defaultNo = 0;
     int separateOutput = 0;
-    char * result;
-    char ** selections, ** next;
+    const char * result;
+    const char ** selections, ** next;
     char * title = NULL;
     char * backtitle = NULL;
     struct poptOption optionsTable[] = {
index 792d3ed761fba120896c634b55d6f11ebbbc3c1c..9f9b8b349ab256c37f8cb9015476c6950f87f2fe 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -131,15 +131,14 @@ int newtWinTernary(char * title, char * button1, char * button2,
     return 0;
 }
 
-/* only supports up to 50 buttons -- shucks! */
 int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown, 
                int flexUp, int maxListHeight, char ** items, int * listItem,
                char * button1, ...) {
     newtComponent textbox, listbox, result, form;
     va_list args;
-    newtComponent buttons[50];
+    newtComponent *buttons = NULL;
     newtGrid grid, buttonBar;
-    int numButtons;
+    size_t totalButtons = 0, numButtons = 0;
     int i, rc;
     int needScroll;
     char * buttonName;
@@ -159,15 +158,16 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown,
 
     newtListboxSetCurrent(listbox, *listItem);
 
-    buttonName = button1, numButtons = 0;
     va_start(args, button1);
-    while (buttonName) {
-       buttons[numButtons] = newtButton(-1, -1, buttonName);
-       numButtons++;
-       buttonName = va_arg(args, char *);
-    }
+    for (buttonName = button1; buttonName; buttonName = va_arg(args, char *)) 
+       ++totalButtons;                                                        
+    va_end(args);                                                             
 
-    va_end(args);
+    buttons = (newtComponent *)alloca(sizeof(newtComponent*)*(totalButtons)); 
+    va_start(args, button1);                                                  
+    for (buttonName = button1; buttonName; buttonName = va_arg(args, char *)) 
+       buttons[numButtons++] = newtButton(-1, -1, buttonName);                
+    va_end(args);                                                             
 
     buttonBar = newtCreateGrid(numButtons, 1);
     for (i = 0; i < numButtons; i++) {
@@ -199,15 +199,14 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown,
     return rc;
 }
 
-/* only supports up to 50 buttons and entries -- shucks! */
 int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown, 
                   int flexUp, int dataWidth, 
                   struct newtWinEntry * items, char * button1, ...) {
-    newtComponent buttons[50], result, form, textw;
+    newtComponent *buttons, result, form, textw;
     newtGrid grid, buttonBar, subgrid;
     int numItems;
     int rc, i;
-    int numButtons;
+    size_t numButtons = 0, totalButtons = 0;
     char * buttonName;
     va_list args;
 
@@ -216,15 +215,17 @@ int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown,
 
     for (numItems = 0; items[numItems].text; numItems++); 
 
-    buttonName = button1, numButtons = 0;
+    buttonName = button1;
     va_start(args, button1);
-    while (buttonName) {
-       buttons[numButtons] = newtButton(-1, -1, buttonName);
-       numButtons++;
-       buttonName = va_arg(args, char *);
-    }
-
-    va_end(args);
+    for (buttonName = button1; buttonName; buttonName = va_arg(args, char *)) 
+       ++totalButtons;                                                        
+    va_end(args);                                                             
+    buttons = (newtComponent *)alloca(sizeof(newtComponent*)*(totalButtons)); 
+    va_start(args, button1);                                                  
+    for (buttonName = button1; buttonName; buttonName = va_arg(args, char *)) 
+       buttons[numButtons++] = newtButton(-1, -1, buttonName);                
+    va_end(args);                                                             
 
     buttonBar = newtCreateGrid(numButtons, 1);
     for (i = 0; i < numButtons; i++) {