NULL terminate string bulk list
[nedit-bw.git] / remove-cast-warnings.patch
blob8ee72ba45b26a92d6a2f330ef8a278429273fd61
1 Subject: remove more cast warnings
3 ---
5 source/file.c | 2 +-
6 source/highlight.c | 2 +-
7 source/macro.c | 12 ++++++------
8 source/preferences.c | 21 +++++++++++----------
9 source/userCmds.c | 10 +++++-----
10 util/prefFile.c | 4 ++--
11 6 files changed, 26 insertions(+), 25 deletions(-)
13 diff --quilt old/source/preferences.c new/source/preferences.c
14 --- old/source/preferences.c
15 +++ new/source/preferences.c
16 @@ -2282,9 +2282,8 @@ void SetLanguageMode(WindowInfo *window,
18 Widget menu;
19 WidgetList items;
20 - int n;
21 - Cardinal nItems;
22 - void *userData;
23 + Cardinal nItems, n;
24 + XtPointer userData;
26 /* Do mode-specific actions */
27 reapplyLanguageMode(window, mode, forceNewDefaults);
28 @@ -2293,9 +2292,9 @@ void SetLanguageMode(WindowInfo *window,
29 if (IsTopDocument(window)) {
30 XtVaGetValues(window->langModeCascade, XmNsubMenuId, &menu, NULL);
31 XtVaGetValues(menu, XmNchildren, &items, XmNnumChildren, &nItems, NULL);
32 - for (n=0; n<(int)nItems; n++) {
33 + for (n=0; n<nItems; n++) {
34 XtVaGetValues(items[n], XmNuserData, &userData, NULL);
35 - XmToggleButtonSetState(items[n], (int)userData == mode, False);
36 + XmToggleButtonSetState(items[n], userData == (XtPointer)(long)mode, False);
40 @@ -5147,7 +5146,7 @@ static void updateLanguageModeSubmenu(Wi
41 xmToggleButtonGadgetClass, menu,
42 XmNlabelString, s1=XmStringCreateSimple(LanguageModes[i]->name),
43 XmNmarginHeight, 0,
44 - XmNuserData, (void *)i,
45 + XmNuserData, (XtPointer)(long)i,
46 XmNset, window->languageMode==i, NULL);
47 XmStringFree(s1);
48 XtAddCallback(btn, XmNvalueChangedCallback, setLangModeCB, window);
49 @@ -5159,23 +5158,25 @@ static void setLangModeCB(Widget w, XtPo
51 WindowInfo *window = WidgetToWindow(MENU_WIDGET(w));
52 char *params[1];
53 - void *mode;
54 + int mode;
55 + XtPointer userData;
57 if (!XmToggleButtonGetState(w))
58 return;
60 /* get name of language mode stored in userData field of menu item */
61 - XtVaGetValues(w, XmNuserData, &mode, NULL);
62 + XtVaGetValues(w, XmNuserData, &userData, NULL);
63 + mode = (int)(long)userData;
65 /* If the mode didn't change, do nothing */
66 - if (window->languageMode == (int)mode)
67 + if (window->languageMode == mode)
68 return;
70 /* redo syntax highlighting word delimiters, etc. */
72 reapplyLanguageMode(window, (int)mode, False);
74 - params[0] = (((int)mode) == PLAIN_LANGUAGE_MODE) ? "" : LanguageModes[(int)mode]->name;
75 + params[0] = (mode == PLAIN_LANGUAGE_MODE) ? "" : LanguageModes[mode]->name;
76 XtCallActionProc(window->textArea, "set_language_mode", NULL, params, 1);
79 diff --quilt old/source/userCmds.c new/source/userCmds.c
80 --- old/source/userCmds.c
81 +++ new/source/userCmds.c
82 @@ -1111,13 +1111,13 @@ static void dimSelDepItemsInMenu(Widget
83 XtVaGetValues(menuPane, XmNchildren, &items, XmNnumChildren, &nItems, NULL);
84 for (n=0; n<(int)nItems; n++) {
85 XtVaGetValues(items[n], XmNuserData, &userData, NULL);
86 - if (userData != (XtPointer)PERMANENT_MENU_ITEM) {
87 + if (userData != PERMANENT_MENU_ITEM) {
88 if (XtClass(items[n]) == xmCascadeButtonWidgetClass) {
89 XtVaGetValues(items[n], XmNsubMenuId, &subMenu, NULL);
90 dimSelDepItemsInMenu(subMenu, menuList, nMenuItems, sensitive);
91 } else {
92 - index = (int)userData - 10;
93 - if (index <0 || index >= nMenuItems)
94 + index = (int)(long)userData - 10;
95 + if (index < 0 || index >= nMenuItems)
96 return;
97 if (menuList[index]->input == FROM_SELECTION)
98 XtSetSensitive(items[n], sensitive);
99 @@ -1928,7 +1928,7 @@ static Widget createUserMenuItem(Widget
100 XmNlabelString, st1,
101 XmNacceleratorText, st2,
102 XmNmnemonic, f->mnemonic,
103 - XmNuserData, (XtPointer)(index+10), NULL);
104 + XmNuserData, (XtPointer)(long)(index + 10), NULL);
105 XtAddCallback(btn, XmNactivateCallback, cbRtn, cbArg);
106 XmStringFree(st1);
107 XmStringFree(st2);
108 @@ -1979,7 +1979,7 @@ static void deleteMenuItems(Widget menuP
109 /* delete all of the widgets not marked as PERMANENT_MENU_ITEM */
110 for (n=0; n<(int)nItems; n++) {
111 XtVaGetValues(items[n], XmNuserData, &userData, NULL);
112 - if (userData != (XtPointer)PERMANENT_MENU_ITEM) {
113 + if (userData != PERMANENT_MENU_ITEM) {
114 if (XtClass(items[n]) == xmCascadeButtonWidgetClass) {
115 XtVaGetValues(items[n], XmNsubMenuId, &subMenuID, NULL);
117 diff --quilt old/source/file.c new/source/file.c
118 --- old/source/file.c
119 +++ new/source/file.c
120 @@ -1919,7 +1919,7 @@ static void setFormatCB(Widget w, XtPoin
121 if (XmToggleButtonGetState(w)) {
122 XtPointer userData;
123 XtVaGetValues(w, XmNuserData, &userData, NULL);
124 - *(int*) clientData = (int) userData;
125 + *(int*) clientData = (int)(long) userData;
129 diff --quilt old/source/macro.c new/source/macro.c
130 --- old/source/macro.c
131 +++ new/source/macro.c
132 @@ -2847,7 +2847,7 @@ static int dialogMS(WindowInfo *window,
133 readStringArg(argList[i], &btnLabel, btnStorage, errMsg);
134 btn = XtVaCreateManagedWidget("mdBtn", xmPushButtonWidgetClass, dialog,
135 XmNlabelString, s1=XmStringCreateSimple(btnLabel),
136 - XmNuserData, (XtPointer)(i+1), NULL);
137 + XmNuserData, (XtPointer)(long)(i + 1), NULL);
138 XtAddCallback(btn, XmNactivateCallback, dialogBtnCB, window);
139 XmStringFree(s1);
141 @@ -2888,7 +2888,7 @@ static void dialogBtnCB(Widget w, XtPoin
142 return; /* shouldn't happen */
143 if (XtClass(w) == xmPushButtonWidgetClass) {
144 XtVaGetValues(w, XmNuserData, &userData, NULL);
145 - retVal.val.n = (int)userData;
146 + retVal.val.n = (int)(long)userData;
147 } else
148 retVal.val.n = 1;
149 retVal.tag = INT_TAG;
150 @@ -3024,7 +3024,7 @@ static int stringDialogMS(WindowInfo *wi
151 readStringArg(argList[i], &btnLabel, btnStorage, errMsg);
152 btn = XtVaCreateManagedWidget("mdBtn", xmPushButtonWidgetClass, dialog,
153 XmNlabelString, s1=XmStringCreateSimple(btnLabel),
154 - XmNuserData, (XtPointer)(i+1), NULL);
155 + XmNuserData, (XtPointer)(long)(i + 1), NULL);
156 XtAddCallback(btn, XmNactivateCallback, stringDialogBtnCB, window);
157 XmStringFree(s1);
159 @@ -3078,7 +3078,7 @@ static void stringDialogBtnCB(Widget w,
160 returned in w. */
161 if (XtClass(w) == xmPushButtonWidgetClass) {
162 XtVaGetValues(w, XmNuserData, &userData, NULL);
163 - btnNum = (int)userData;
164 + btnNum = (int)(long)userData;
165 } else
166 btnNum = 1;
168 @@ -3603,7 +3603,7 @@ static int listDialogMS(WindowInfo *wind
169 readStringArg(argList[i], &btnLabel, btnStorage, errMsg);
170 btn = XtVaCreateManagedWidget("mdBtn", xmPushButtonWidgetClass, dialog,
171 XmNlabelString, s1=XmStringCreateSimple(btnLabel),
172 - XmNuserData, (XtPointer)(i+1), NULL);
173 + XmNuserData, (XtPointer)(long)(i + 1), NULL);
174 XtAddCallback(btn, XmNactivateCallback, listDialogBtnCB, window);
175 XmStringFree(s1);
177 @@ -3683,7 +3683,7 @@ static void listDialogBtnCB(Widget w, Xt
178 returned in w. */
179 if (XtClass(w) == xmPushButtonWidgetClass) {
180 XtVaGetValues(w, XmNuserData, &userData, NULL);
181 - btnNum = (int)userData;
182 + btnNum = (int)(long)userData;
183 } else
184 btnNum = 1;
186 diff --quilt old/util/prefFile.c new/util/prefFile.c
187 --- old/util/prefFile.c
188 +++ new/util/prefFile.c
189 @@ -353,9 +353,9 @@ static int stringToPref(const char *stri
190 *(int *)rsrcDescrip->valueAddr = 0;
191 return False;
192 case PREF_STRING:
193 - if ((int)strlen(string) >= (int)rsrcDescrip->arg)
194 + if (strlen(string) >= (size_t)rsrcDescrip->arg)
195 return False;
196 - strncpy(rsrcDescrip->valueAddr, string, (int)rsrcDescrip->arg);
197 + strncpy(rsrcDescrip->valueAddr, string, (size_t)rsrcDescrip->arg);
198 return True;
199 case PREF_ALLOC_STRING:
200 *(char **)rsrcDescrip->valueAddr = XtMalloc(strlen(string) + 1);
201 diff --quilt old/source/highlight.c new/source/highlight.c
202 --- old/source/highlight.c
203 +++ new/source/highlight.c
204 @@ -512,7 +512,7 @@ void* GetHighlightInfo(WindowInfo *windo
205 if (!pattern) {
206 return NULL;
208 - return (void*)pattern->userStyleIndex;
209 + return (void*)(long)pattern->userStyleIndex;