From d78245aba3a899c29c9d1875a48513a0f6f0935d Mon Sep 17 00:00:00 2001 From: havill Date: Fri, 3 Jan 2003 20:54:45 +0000 Subject: [PATCH] - 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) --- checkboxtree.c | 2 +- configure.in | 4 ++-- dialogboxes.c | 8 ++++---- dialogboxes.h | 6 +++--- entry.c | 4 ++-- form.c | 3 ++- newt.h | 4 ++-- newt.spec | 11 +++++++++-- snackmodule.c | 3 ++- test.c | 4 ++-- testgrid.c | 2 +- testtree.c | 2 +- textbox.c | 2 +- whiptail.c | 4 ++-- windows.c | 43 ++++++++++++++++++++++--------------------- 15 files changed, 56 insertions(+), 46 deletions(-) diff --git a/checkboxtree.c b/checkboxtree.c index 488ce92..7d9731d 100644 --- a/checkboxtree.c +++ b/checkboxtree.c @@ -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); diff --git a/configure.in b/configure.in index b5992aa..d55ce2f 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/dialogboxes.c b/dialogboxes.c index 0ac7727..736097d 100644 --- a/dialogboxes.c +++ b/dialogboxes.c @@ -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; diff --git a/dialogboxes.h b/dialogboxes.h index 29dab12..456ab63 100644 --- a/dialogboxes.h +++ b/dialogboxes.h @@ -18,11 +18,11 @@ 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 7bce7ff..21ab00c 100644 --- 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 5564a74..3dd87c3 100644 --- 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 6ffb259..f3f8bb2 100644 --- 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; }; diff --git a/newt.spec b/newt.spec index acaf784..2c7f6d8 100644 --- 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 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 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 diff --git a/snackmodule.c b/snackmodule.c index 14f0784..cb89f8c 100644 --- a/snackmodule.c +++ b/snackmodule.c @@ -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 199b3eb..33be2c8 100644 --- 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); diff --git a/testgrid.c b/testgrid.c index 3bd7741..0d3aa85 100644 --- a/testgrid.c +++ b/testgrid.c @@ -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 }, diff --git a/testtree.c b/testtree.c index 70523d7..62494b8 100644 --- a/testtree.c +++ b/testtree.c @@ -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; diff --git a/textbox.c b/textbox.c index 8387185..68742cf 100644 --- 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; diff --git a/whiptail.c b/whiptail.c index 7a7bda2..4aa41b0 100644 --- a/whiptail.c +++ b/whiptail.c @@ -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[] = { diff --git a/windows.c b/windows.c index 792d3ed..9f9b8b3 100644 --- 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++) { -- 2.47.2