diff options
author | Matthieu Herrb <matthieu.herrb@laas.fr> | 2005-02-21 21:08:27 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu.herrb@laas.fr> | 2005-02-21 21:08:27 +0000 |
commit | 85eb751e4e1683af6cee3ee9dce29f74911a639d (patch) | |
tree | b40f699ee646462a8f223b919ba68dda1d8fc371 /src/ResConfig.c | |
parent | 94150cb72d9d641c64325cd70323d93b9a3701a5 (diff) |
Convert lib/Xt to ANSI C (Thomas Dickey). Fixes for a few valgrind warningsXORG-6_8_99_3XORG-6_8_99_2XORG-6_8_99_1
(Thomas Dickey).
Diffstat (limited to 'src/ResConfig.c')
-rw-r--r-- | src/ResConfig.c | 274 |
1 files changed, 137 insertions, 137 deletions
diff --git a/src/ResConfig.c b/src/ResConfig.c index 59aa204..7182e64 100644 --- a/src/ResConfig.c +++ b/src/ResConfig.c @@ -41,9 +41,9 @@ all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE IBM CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +THE IBM CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, +BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the IBM Corporation shall @@ -67,9 +67,9 @@ Corporation. #define MAX_BUFFER 512 -static void _search_child(); -static void _set_and_search(); -static int _locate_children(); +static void _search_child(Widget, char *, char *, char *, char *, char, char *); +static void _set_and_search(Widget, char *, char *, char *, char *, char , char *); +static int _locate_children(Widget, Widget **); #if defined(sun) && !defined(SVR4) # define Strtoul(a,b,c) (unsigned long)strtol(a,b,c) @@ -81,7 +81,7 @@ static int _locate_children(); /* * NAME: _set_resource_values * - * FUNCTION: + * FUNCTION: * This function sets the value on the widget. It must first determine * if the last part is a valid resource for that widget. (eg. * labelString is a valid resource for label but not for bulletin board) @@ -103,11 +103,11 @@ static int _locate_children(); * ERRORS: none */ static void -_set_resource_values (w, resource, value, last_part) - Widget w; - char *resource; - char *value; - char *last_part; +_set_resource_values ( + Widget w, + char *resource, + char *value, + char *last_part) { XrmDatabase db = NULL; char *resource_name = NULL; @@ -119,18 +119,18 @@ _set_resource_values (w, resource, value, last_part) char *temp; XtResourceList resources_return = NULL; Cardinal num_resources_return = 0; - int res_index; + Cardinal res_index; Boolean found_resource = False; Display *dpy; XrmDatabase tmp_db; - + if (!XtIsWidget (w)) dpy = XtDisplay (w->core.parent); else dpy = XtDisplay (w); tmp_db = XtDatabase(dpy); - /* + /* * get a list of all the valid resources for this widget */ XtGetResourceList (w->core.widget_class, @@ -156,7 +156,7 @@ _set_resource_values (w, resource, value, last_part) * then exit this function */ if (!found_resource - || !resources_return[res_index].resource_name + || !resources_return[res_index].resource_name || !resources_return[res_index].resource_class) { XtFree ((char *) resources_return); return; @@ -169,12 +169,12 @@ _set_resource_values (w, resource, value, last_part) * .App.XmPushButton.Foreground */ while (cur != NULL) { - /* + /* * create resource name string */ if (resource_name) { temp = XtMalloc (sizeof(char) * - (2 + strlen(cur->core.name) + (2 + strlen(cur->core.name) + strlen(resource_name))); sprintf (temp, ".%s%s", cur->core.name, resource_name); XtFree (resource_name); @@ -188,23 +188,23 @@ _set_resource_values (w, resource, value, last_part) } resource_name = temp; - /* + /* * create resource class string */ if ((XtIsTopLevelShell (cur)) && (XtParent (cur) == NULL)) { - ApplicationShellWidget top = + ApplicationShellWidget top = (ApplicationShellWidget) (cur); if (resource_class) { temp = XtMalloc (sizeof(char) * (2 + strlen(top->application.class) + strlen(resource_class))); - sprintf (temp, ".%s%s", + sprintf (temp, ".%s%s", top->application.class, resource_class); } else { temp = XtMalloc (sizeof(char) * (2 + strlen(top->application.class))); - sprintf (temp, ".%s", + sprintf (temp, ".%s", top->application.class); } } else { @@ -213,7 +213,7 @@ _set_resource_values (w, resource, value, last_part) (2 + strlen( cur->core.widget_class->core_class.class_name) + strlen(resource_class))); - sprintf (temp, ".%s%s", + sprintf (temp, ".%s%s", cur->core.widget_class->core_class.class_name, resource_class); } else { @@ -225,7 +225,7 @@ _set_resource_values (w, resource, value, last_part) } } if (resource_class != NULL) - XtFree (resource_class); + XtFree (resource_class); resource_class = temp; cur = XtParent(cur); @@ -258,26 +258,26 @@ _set_resource_values (w, resource, value, last_part) fprintf (stderr, "resource_class = %s\n", resource_class); #endif - /* + /* * put the resource and its value in a resource database and * then query it back out again using the specific name and - * class resource strings that were built above. This is + * class resource strings that were built above. This is * necessary to maintain a precedence similar to the .Xdefaults * file */ XrmPutStringResource (&db, resource, value); XrmMergeDatabases (db, &tmp_db); - XrmGetResource (tmp_db, resource_name, resource_class, + XrmGetResource (tmp_db, resource_name, resource_class, &return_type, &return_value); - if (return_type) + if (return_type) resource_value = XtNewString (return_value.addr); else resource_value = XtNewString (value); #ifdef DEBUG - fprintf (stderr, + fprintf (stderr, "Apply:\n\twidget = %s\n\tlast_part = %s\n\tvalue = %s\n", - (w->core.name == NULL) ? "NULL" : w->core.name, + (w->core.name == NULL) ? "NULL" : w->core.name, resources_return[res_index].resource_name, resource_value); #endif @@ -286,14 +286,14 @@ _set_resource_values (w, resource, value, last_part) * type String the the same type as the resource (last_part). * Then set the value. */ - XtVaSetValues (w, + XtVaSetValues (w, XtVaTypedArg, resources_return[res_index].resource_name, - XtRString, resource_value, + XtRString, resource_value, strlen (resource_value) + 1, NULL); XtFree ((char *) resources_return); - XtFree (resource_name); + XtFree (resource_name); XtFree (resource_class); XtFree (resource_value); } @@ -301,7 +301,7 @@ _set_resource_values (w, resource, value, last_part) /* * NAME: _apply_values_to_children * - * FUNCTION: + * FUNCTION: * Once the resource string matches the value must be applied to * all children if applicable. (eg. App*Form.background must apply * background to all children of the Form widget) @@ -311,7 +311,7 @@ _set_resource_values (w, resource, value, last_part) * remainder the part of the resource string left over * resource the resource string to be matched * value the value to be set - * last_token the last * or . before the final resoruce part + * last_token the last * or . before the final resoruce part * last_part the last resource part (e.g. *background) * * RETURN VALUES: void @@ -319,13 +319,13 @@ _set_resource_values (w, resource, value, last_part) * ERRORS: none */ static void -_apply_values_to_children (w, remainder, resource, value, last_token, last_part) - Widget w; - char *remainder; - char *resource; - char *value; - char last_token; - char *last_part; +_apply_values_to_children ( + Widget w, + char *remainder, + char *resource, + char *value, + char last_token, + char *last_part) { int i; int num_children; @@ -340,19 +340,19 @@ _apply_values_to_children (w, remainder, resource, value, last_token, last_part) #ifdef DEBUG if (XtIsWidget (children[i]) && XtIsWidget (w)) - fprintf (stderr, "searching child %s of parent %s\n", + fprintf (stderr, "searching child %s of parent %s\n", children[i]->core.name, w->core.name); else fprintf (stderr,"searching child (NULL) of parent %s\n", w->core.name); - if (!XtIsWidget (children[i])) + if (!XtIsWidget (children[i])) fprintf (stderr, "children[%d] is NOT a widget\n", i); if (!XtIsWidget (w)) fprintf (stderr, "w is NOT a widget\n"); #endif _set_resource_values (children[i], resource, value, last_part); - _apply_values_to_children (children[i], remainder, + _apply_values_to_children (children[i], remainder, resource, value, last_token, last_part); } @@ -362,8 +362,8 @@ _apply_values_to_children (w, remainder, resource, value, last_token, last_part) /* * NAME: _search_child * - * FUNCTION: - * descends through each child of the tree + * FUNCTION: + * descends through each child of the tree * * PARAMETERS: * w the widget whose children are to be searched @@ -371,7 +371,7 @@ _apply_values_to_children (w, remainder, resource, value, last_token, last_part) * remainder the remaining part of the resource string * resource the resource string to be matched * value the value to be applied - * last_token the last * or . before the final resoruce part + * last_token the last * or . before the final resoruce part * last_part the last resource part (e.g. *background) * * RETURN VALUES: none @@ -379,14 +379,14 @@ _apply_values_to_children (w, remainder, resource, value, last_token, last_part) * ERRORS: none */ static void -_search_child (w, indx, remainder, resource, value, last_token, last_part) - Widget w; - char *indx; - char *remainder; - char *resource; - char *value; - char last_token; - char *last_part; +_search_child ( + Widget w, + char *indx, + char *remainder, + char *resource, + char *value, + char last_token, + char *last_part) { int i; int num_children; @@ -397,7 +397,7 @@ _search_child (w, indx, remainder, resource, value, last_token, last_part) */ num_children = _locate_children (w, &children); for (i=0; i<num_children; i++) { - _set_and_search (children[i], indx, remainder, resource, + _set_and_search (children[i], indx, remainder, resource, value, last_token, last_part); } @@ -407,16 +407,16 @@ _search_child (w, indx, remainder, resource, value, last_token, last_part) /* * NAME: _get_part * - * FUNCTION: - * This routine will return the token and following part of the resource - * when given the current index it will update the index accordingly + * FUNCTION: + * This routine will return the token and following part of the resource + * when given the current index it will update the index accordingly * * PARAMETERS: * remainder the part of the resource string left over * indx the index into the resource string * part the parsed off part of the resource string * - * RETURN VALUES: + * RETURN VALUES: * char the token (* or . or ?) preceding the resource part * indx the index into the resource string * part the parsed off part of the resource string @@ -425,23 +425,23 @@ _search_child (w, indx, remainder, resource, value, last_token, last_part) */ /* ARGSUSED */ static char -_get_part (remainder, indx, part) - char *remainder; - char **indx; - char **part; +_get_part ( + char *remainder, + char **indx, + char **part) { char buffer[MAX_BUFFER]; - char *buf_ptr; + char *buf_ptr; char token = **indx; int i = 0; - /* + /* * copy the remainder part into the buffer */ buf_ptr = buffer; (*indx)++; /* get rid of the token */ while (**indx && (**indx != '.') && (**indx != '*')) { - *buf_ptr++ = *(*indx)++; + *buf_ptr++ = *(*indx)++; if (++i >= MAX_BUFFER - 1) break; } @@ -458,22 +458,22 @@ _get_part (remainder, indx, part) /* * NAME: _match_resource_to_widget * - * FUNCTION: + * FUNCTION: * This function matches the resource part to the widget name or class * * PARAMETERS: * w the widget to match * part the parsed off part of the resource string * - * RETURN VALUES: + * RETURN VALUES: * Boolean true if a match occurs * * ERRORS: none */ static Boolean -_match_resource_to_widget (w, part) - Widget w; - char *part; +_match_resource_to_widget ( + Widget w, + char *part) { /* * Match any widget at this level if the ? is used @@ -506,7 +506,7 @@ _match_resource_to_widget (w, part) /* * NAME: _set_and_search * - * FUNCTION: + * FUNCTION: * The algorithm to search the widget tree and apply a resource string * * PARAMETERS: @@ -515,7 +515,7 @@ _match_resource_to_widget (w, part) * remainder the part of the resource string left over * resource the resource string to be matched * value the value to be set - * last_token the last * or . before the final resoruce part + * last_token the last * or . before the final resoruce part * last_part the last resource part (e.g. *background) * * RETURN VALUES: none @@ -527,19 +527,19 @@ _match_resource_to_widget (w, part) * if (resource segment and current widget match) * if '.' * if at end of resource string - * set values ( .=over all children + * set values ( .=over all children * *=this widget only) * else - * descend the widget tree + * descend the widget tree * and parse off resource segment * exit the loop * if '*' * if at end of resource string - * set values ( .=over all children + * set values ( .=over all children * *=this widget only) * descend and parse * else - * if '.' + * if '.' * continue looping * if '*' * descend but don't parse @@ -550,14 +550,14 @@ _match_resource_to_widget (w, part) * set on a resource against the rules of the resource database manager */ static void -_set_and_search (w, indx, remainder, resource, value, last_token, last_part) - Widget w; - char *indx; - char *remainder; - char *resource; - char *value; - char last_token; - char *last_part; +_set_and_search ( + Widget w, + char *indx, + char *remainder, + char *resource, + char *value, + char last_token, + char *last_part) { char *part; char *local_index = indx; @@ -566,18 +566,18 @@ _set_and_search (w, indx, remainder, resource, value, last_token, last_part) /* * parse off one part, return token and the new index */ - token = _get_part (remainder, &local_index, &part); + token = _get_part (remainder, &local_index, &part); if (_match_resource_to_widget (w, part)) { if (token == '.') { if (local_index == NULL) { if (last_token == '.') { - _set_resource_values (w, resource, + _set_resource_values (w, resource, value, last_part); } else if (last_token == '*') { - _set_resource_values (w, resource, + _set_resource_values (w, resource, value, last_part); - _apply_values_to_children (w, + _apply_values_to_children (w, remainder, resource, value, last_token, last_part); } @@ -585,16 +585,16 @@ _set_and_search (w, indx, remainder, resource, value, last_token, last_part) _search_child (w, local_index, remainder, resource, value, last_token, last_part); return; - } + } if (token == '*') { if (local_index == NULL) { if (last_token == '.') { - _set_resource_values (w, resource, + _set_resource_values (w, resource, value, last_part); } else if (last_token == '*') { - _set_resource_values (w, resource, + _set_resource_values (w, resource, value, last_part); - _apply_values_to_children ( w, + _apply_values_to_children ( w, remainder, resource, value, last_token, last_part); } @@ -608,7 +608,7 @@ _set_and_search (w, indx, remainder, resource, value, last_token, last_part) if (token == '*') { _search_child (w, indx, remainder, resource, value, last_token, last_part); - } + } } XtFree (part); @@ -617,7 +617,7 @@ _set_and_search (w, indx, remainder, resource, value, last_token, last_part) /* * NAME: _get_last_part * - * FUNCTION: + * FUNCTION: * This routine will parse off the last segment of a resource string * and its token and return them. the remainder of resource is also * returned. strcoll is used to guarantee no problems with @@ -627,7 +627,7 @@ _set_and_search (w, indx, remainder, resource, value, last_token, last_part) * remainder the part of the resource string left over * part the parsed off part of the resource string * - * RETURN VALUES: + * RETURN VALUES: * char the token (* or . or ?) preceding the resource part * remainder the part of the resource string left over * part the parsed off part of the resource string @@ -635,9 +635,9 @@ _set_and_search (w, indx, remainder, resource, value, last_token, last_part) * ERRORS: none */ static char -_get_last_part (remainder, part) - char *remainder; - char **part; +_get_last_part ( + char *remainder, + char **part) { char *loose, *tight; @@ -665,11 +665,11 @@ _get_last_part (remainder, part) /* * NAME: _search_widget_tree * - * FUNCTION: + * FUNCTION: * This function tries to match a resource string to the widgets * it applies to. The functions it invokes to do this then set * the value for that resource to each widget. - * + * * The resource string has to be parsed into the following format: * resource = App*Form*button1.background * remainder = *Form*button1 @@ -692,10 +692,10 @@ _get_last_part (remainder, part) * ERRORS: none */ static void -_search_widget_tree (w, resource, value) - Widget w; - char *resource; - char *value; +_search_widget_tree ( + Widget w, + char *resource, + char *value) { Widget parent = w; char *last_part; @@ -718,7 +718,7 @@ _search_widget_tree (w, resource, value) else fprintf (stderr, "widget = NULL parent = NULL\n"); #endif - + /* * parse off the Class name that was prepended to this string in * a customizing tool @@ -735,8 +735,8 @@ _search_widget_tree (w, resource, value) remainder = XtNewString (tight); else if ((tight == NULL) || (loose_len > tight_len)) remainder = XtNewString (loose); - - /* + + /* * Parse last segment off of resource string, (eg. background, font, * etc.) */ @@ -747,7 +747,7 @@ _search_widget_tree (w, resource, value) if (strcmp (remainder, "") == 0) { _set_resource_values (w, resource, value, last_part); if (last_token == '*') - _apply_values_to_children (parent, remainder, resource, + _apply_values_to_children (parent, remainder, resource, value, last_token, last_part); /* * all other resource strings are recursively applied to the widget tree. @@ -761,10 +761,10 @@ _search_widget_tree (w, resource, value) remainder = copy; } indx = remainder; - _set_and_search (parent, indx, remainder, resource, value, + _set_and_search (parent, indx, remainder, resource, value, last_token, last_part); } - + XtFree (remainder); XtFree (last_part); } @@ -772,7 +772,7 @@ _search_widget_tree (w, resource, value) /* * NAME: _locate_children * - * FUNCTION: + * FUNCTION: * returns a list of all of a widget's children * * PARAMETERS: @@ -781,23 +781,23 @@ _search_widget_tree (w, resource, value) * normal flag for normal children * popup flag for popup children * - * RETURN VALUES: + * RETURN VALUES: * int the number of children * children the list of children found * * ERRORS: none */ static int -_locate_children (parent, children) - Widget parent; - Widget **children; +_locate_children ( + Widget parent, + Widget **children) { CompositeWidget comp = (CompositeWidget) parent; - int i; + Cardinal i; int num_children = 0; int current = 0; - /* + /* * count the number of children */ if (XtIsWidget (parent)) @@ -809,7 +809,7 @@ _locate_children (parent, children) return (0); } - *children = (Widget *) + *children = (Widget *) XtMalloc ((Cardinal) sizeof(Widget) * num_children); if (XtIsComposite (parent)) { @@ -833,7 +833,7 @@ _locate_children (parent, children) /* * NAME: dump_widget_tree * - * FUNCTION: + * FUNCTION: * recursively printout entire widget tree * * PARAMETERS: @@ -845,9 +845,9 @@ _locate_children (parent, children) * ERRORS: none */ static void -dump_widget_tree (w, indent) - Widget w; - int indent; +dump_widget_tree ( + Widget w, + int indent) { int i,j; int num_children; @@ -857,10 +857,10 @@ dump_widget_tree (w, indent) * Recursively search through the children */ num_children = _locate_children (w, &children); - indent += 2; + indent += 2; for (i=0; i<num_children; i++) { if (children[i] != NULL) { - for (j=0; j<indent; j++) + for (j=0; j<indent; j++) fprintf (stderr, " "); if (XtIsWidget (children[i])) { fprintf (stderr, "(%s)\t",children[i]->core.name); @@ -882,10 +882,10 @@ dump_widget_tree (w, indent) /* * NAME: _XtResourceConfiguationEH * - * FUNCTION: + * FUNCTION: * This function is the event handler for the on-the-fly communication - * with a resource customization tool. This event handler must be - * registered for the toplevel shell of each app. This is best done + * with a resource customization tool. This event handler must be + * registered for the toplevel shell of each app. This is best done * in the _XtCreatePopupShell and _XtAppCreateShell functions in Xt's * Create.c source file. * @@ -910,10 +910,10 @@ dump_widget_tree (w, indent) */ /* ARGSUSED */ void -_XtResourceConfigurationEH (w, client_data, event) - Widget w; - XtPointer client_data; - XEvent *event; +_XtResourceConfigurationEH ( + Widget w, + XtPointer client_data, + XEvent *event) { Atom actual_type; int actual_format; @@ -956,7 +956,7 @@ _XtResourceConfigurationEH (w, client_data, event) else fprintf (stderr, "NULL name\n"); dump_widget_tree(w, indent); - + fprintf (stderr, "answer ping\n"); #endif } @@ -965,7 +965,7 @@ _XtResourceConfigurationEH (w, client_data, event) * This event handler ignores any property notify events that * are not RCM_INIT or RCM_DATA */ - if (event->xproperty.atom != pd->rcm_data) + if (event->xproperty.atom != pd->rcm_data) return; /* @@ -979,7 +979,7 @@ _XtResourceConfigurationEH (w, client_data, event) pd->rcm_data, 0L, 8192L, TRUE, XA_STRING, &actual_type, &actual_format, &nitems, &leftover, - &data ) == Success && actual_type == XA_STRING + &data ) == Success && actual_type == XA_STRING && actual_format == 8) { /* * data format is: |