1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 04:48:06 +01:00
Commit Graph

867 Commits

Author SHA1 Message Date
Christophe CURIS
708bc27e3f WINGs: Added explicit parameter list to function prototypes (Simple cases)
It is dangerous to let the compiler know about a function without
letting him know the arguments because he won't be able to report
invalid calls.

This patch concern the cases where adding the arguments did not
need other code change.
2013-05-12 01:01:20 +01:00
Christophe CURIS
a622197faa Added explicit 'void' to function that takes no argument
This is the correct way to tell that a function takes no
arguments, because an empty parameter list tells the compiler
that it is not yet defined, and is tolerated only for
compatibility with very old C compilers for whom prototypes
were not yet a defined language element.
2013-05-12 01:01:20 +01:00
Christophe CURIS
0e41122680 WINGs: Changed equality comparison on floating point number
The equality comparison (a == b) is known to be a dangerous trap
when floating-point arithmetics are involved. This patch changes
all the cases which try to do this to a safer check.
2013-05-11 00:17:27 +01:00
Christophe CURIS
dcfd7a4b5e WINGs: Changed the minimum internal knob size of WScroller
The original code allowed to have 0.0, but this can generate
division by zero in WScrollView. As a value of 0.0 is not realistic
anyway, use a minimum constant instead.
2013-05-11 00:17:27 +01:00
Christophe CURIS
90d24a1648 Unified usage of the 'inline' attribute for functions
Autoconf provides the necessary stuff to detect if inline keyword
is supported, and to detect special syntaxes, so let's use this
and remove the multiple local definitions, this makes code simpler.
2013-05-11 00:17:27 +01:00
Christophe CURIS
7f6699ffca Changed formula for getting the number of elements in a static array
When using the formula [sizeof(array) / sizeof( x )] to get the number
of element in a static array, it is better to use array[0] for 'x'
instead of the base type of array:
 - in case the base type would change someday;
 - if the compiler were deciding to insert padding somewhere
2013-05-11 00:17:27 +01:00
Christophe CURIS
7c98f7cfc4 Added proper legal notice at beginning of header files
Some header were missing the notice; used git blame to find the
original date and author (without guarantee.
2013-05-10 19:37:47 +01:00
Christophe CURIS
1a8316d4c9 WINGs: Updated NEWS file about the API changes in the libraries 2013-05-09 18:08:36 +01:00
Christophe CURIS
52b8aabccc WINGs: Fixed incorrect return type for internal function
The function did return a boolean actually as would be expectable
from such function, but its prototype did not use the proper type.
2013-05-09 18:08:12 +01:00
Christophe CURIS
05a3eadd65 WINGs: Fixed incorrect allocation size, missing room for '\0' 2013-05-09 18:08:12 +01:00
Christophe CURIS
a4395c5764 WPrefs.app: Added const attribute to local string
Now that the WINGs functions are const-correct, it is possible to
set the attribute on the strings to help the compiler.
2013-05-09 16:56:28 +01:00
Christophe CURIS
fb3d9e65a6 WINGs: Added 'static' attribute to local functions in wcolorpanel
These 4 functions are local to the file so we make this official.
2013-05-09 16:56:28 +01:00
Christophe CURIS
28e6bde782 WINGs: Added 'const' attribute to 'WMCreatePropListFromDescription'
To be able to do this in a clean way, it was necessary to add the
attribute also in PLData's ptr field, which is actually right
because none of the function changes its content.

The function that fills it from a file/pipe however needed small
changes to respect the const-ness of the field.
2013-05-09 16:56:28 +01:00
Christophe CURIS
75a0beffeb WINGs: Added 'const' attribute to functions in dragdestination, wtext
This makes both the API and local function const-correct on their
input parameters.
2013-05-09 16:56:28 +01:00
Christophe CURIS
72108875aa WINGs: Added 'const' attribute to functions in wpanel, wpopupbutton, wtabview
This makes both the API and local function const-correct on their
input parameters.
2013-05-09 16:56:28 +01:00
Christophe CURIS
6616323088 WINGs: Added 'const' attribute to functions in wballoon, wmenuitem, wmisc, wtextfield
This makes both the API and local function const-correct on their
input parameters.
2013-05-09 16:56:28 +01:00
Christophe CURIS
a1119f8dd3 WINGs: Added 'const' attribute to functions in wbrowser, wcolorpanel, wfilepanel and wfontpanel
This makes both the API and local function const-correct on their
input parameters.
2013-05-09 16:56:28 +01:00
Christophe CURIS
c89e8df33f WINGs: Added 'const' attribute to functions in wbutton, wframe, wlabel, wlist, wwindow
This makes both the API and local function const-correct on their
input parameters.
2013-05-09 16:56:28 +01:00
Christophe CURIS
e7c8ac76ea WINGs: Added 'const' attribute to functions in wapplication, wappresource, wcolor, wfont, wpixmap
This makes both the API and local function const-correct on their
input parameters.
2013-05-09 16:56:28 +01:00
Christophe CURIS
033e3eaa54 WUtil: Rewrote 'wusergnusteppath' to be more efficient
The first optimisation is to compute only once the path, and then
always re-use the value which did not change anyway.
The second optimisation is to avoid a lot of excessive function
calls, including alloc+free that are not necessary and participate
in memory fragmentation.
2013-05-04 16:25:44 +01:00
Christophe CURIS
a18fd7cd69 Fixed const correctness in functions using 'wusergnusteppath'
The change introduced in previous commit for const correctness has
a small impact on WindowMaker's code, this patch fixes all the new
warnings.
2013-05-04 16:25:44 +01:00
Christophe CURIS
cd1c55d63c WUtil: Changed declaration of 'wusergnusteppath' to return a CONST string
According to the way its value is being used everywhere, that is
what would be expected, so let's make it official.

Please note that this may introduce warnings on user code using
this function ("...discard const...") but that's an opportunity
for them to check that their code is not doing anything wrong.
2013-05-04 16:25:44 +01:00
Christophe CURIS
fd02f5f083 WUtil: Fixed risky code for de-escaping of strings
The internal function 'unescapestr' is used to transform strings which
may contain escape sequences (\x) into their plain representation.

There are a few cases where the function can misbehave (typically parse
after the end of string, thus writing past the end of the reserved
result area) which can be a source of problem later. The new code
should be safer.
2013-05-04 16:25:44 +01:00
Christophe CURIS
f386e34d29 WUtil: Fixed wrong type recast
The previous syntax used an explicit cast to remove the CONST
attribute, but the right way is to keep the attribute and store
the result in a variable which is defined properly.
2013-05-04 16:25:44 +01:00
Christophe CURIS
32ecd4ee58 WUtil: Avoid unnecessary strdup + free
It is not good for memory fragmentation to duplicate a string and
then free the original; changed code to only keep originaly allocated
string.
2013-05-04 16:25:44 +01:00
Christophe CURIS
98e3c7e347 WUtil: Added comment about values returned by API functions
This is mainly to be consistent with what's done in the rest of
the file, but it is better to have it there that nowhere at all
anyway...
2013-05-04 16:25:44 +01:00
Christophe CURIS
74c17bffae WUtil: Added 'const' attribute to all remaining functions where applicable
This makes the WUtil API as much const-correct as possible for
the arguments being given to its functions.

This does not make it totally correct as it does not changes the
const-ness on returned values because the goal of this patch is
to make no visible change to existing program that would use this
library.
2013-05-04 16:16:19 +01:00
Christophe CURIS
d40fa69b92 WUtil: Added 'const' attribute to the filename on WM(Read|Write)PropList*
Note that the argument is also stored as-is in the PLData structure
but only for debugging purpose (warning display to user), hence the
choice to not duplicate it. As a side effect, it was 'const'-ified
too to reflect that.
2013-05-04 16:16:18 +01:00
Christophe CURIS
ea9d3e643f WUtil: Added 'const' attribute to parameters for file related API
As a side note, in 'wfindfileinlist' the first argument should be:
  const char * const *path_list

However, due to limited support for const in plain C, that would
introduce warnings in user code. For compatibility issues, this
was not implemented.
2013-05-04 16:16:18 +01:00
Christophe CURIS
bbf84eb0e8 WUtil: Added 'const' attribute on non-modified arguments to functions
A number of functions do not actually modify the strings given as
parameter, but only read or duplicate it. In this case it is a good
practice to mark that parameter as pointer-to-const to let the
compiler known about it, to be able to perform appropriate
optimisations.
2013-05-04 16:16:18 +01:00
Iain Patterson
25b5ca2566 Compiler food.
WMMergePLDictionaries() and WMSubtractPLDictionaries() are declared to
return WMPropList * but are set to call the wassertr macro when their
arguments do not pass a sanity check.  The wassertr macro eventually
calls return with no return value, triggering a compiler warning if
-Wreturn-type is used.

Change wassertr to wassertrv and force a return of NULL in the error
case.
2013-04-16 00:47:10 +01:00
Andreas Bierfert
cc69d2aae3 WINGS: New function WMReadPropListFromPipe
This functions reads a proplist from a pipe instead of a file (like
WMReadPropListFromFile does). It uses a call to popen to open the desired
command, reads data into a buffer till EOF and passes the data to getPropList
for parsing.

v2: code cleanup
2013-02-10 11:22:54 +00:00
Rodolfo García Peñas (kix)
b9caaa8729 WINGs: New function W_setconf_doubleClickDelay
The new function W_setconf_doubleClickDelay() sets the value for
WPreferences.W_setconf_doubleClickDelay(), therefore the private
data of WPreferences struct is not used.

This call is used at defaults.c to set the doubleClickDelay().
2013-01-12 14:45:29 +00:00
Rodolfo García Peñas (kix)
cba94da2cf WINGs: Functions to read the Mouse Wheel conf
These new functions:

unsigned W_getconf_mouseWheelUp(void);
unsigned W_getconf_mouseWheelDown(void);

returns the WINGs configuration for the Mouse Wheel Up and Down
values.
2013-01-12 14:45:29 +00:00
Andreas Bierfert
085224973a Fix incorrect FSF address 2013-01-07 21:19:40 +00:00
Kamil Rytarowski
0706471a10 Fix build with automake-1.13 and modernize .am files.
The following macro: AM_CONFIG_HEADER is deprecated and replaced with AC_CONFIG_HEADERS. INCLUDES is an old version of AM_CPPLAGS.
2013-01-03 23:27:31 +00:00
Carlos R. Mafra
18437e0309 WINGs: Enable cursor blinking in text fields
This code was commented out but enabling it leads to no issues AFAICS
and improves the usability of WINGs applications.

The motivation for this patch comes from the need of distinguishing
where the cursor is in the WINGs-based application which handles the
database of my comics collection.

This changes the behavior in all parts of wmaker where there is
a text field entry, e.g. in the settings panel of dockapps. There should
be no issues with a blinking cursor in such cases though...
2012-12-22 20:15:47 +00:00
Christophe CURIS
27d55b3e33 Added option to 'configure' to control debug information for compilation
As reported by Amadeusz Sławiński, there were a number of debug-only
information printed by the menu parser, which had no reason to be
in a user package.

This patch removes all the hard-coded DEBUG definitions pointed
by Amadeusz and adds a new (standard-like) option '--enable-debug'
to the configure script, which activates debug stuff for the devs.
The default behaviour is now to not have them.
As a side effect, the option also disable optimisation, which are
generally annoying when trying to run a debugger.
2012-11-16 08:06:19 +00:00
Christophe CURIS
5a3cab3cef Changed handling of quoted strings in the menu parser for consistency
As reported by Amadeusz Sławiński, the support for (d)quoted string
in the menu file was not exactly the same as in previous versions
of WindowMaker, so we had a regression which is not acceptable.

This patch propose a consistent handling for (d)quoted text instead
of the previous on-the-title-only code; now all (d)quoted strings
are still kept as-is (as expected) but the (d)quotes are always
removed.
As a side note, it also improve the support for \escaped character
to work correctly as mentioned in the example of the default menu.

Note: This reverts b2e7620868 which
was an incomplete solution to the problem.
2012-11-15 12:37:16 +00:00
Carlos R. Mafra
141b046c33 Remove last QUIET hack from Makefiles
They somehow were missed in 5c8eb580b3 ("configure:
Remove --disable-verbose-compile hack")
2012-11-12 22:44:33 +00:00
Rodolfo García Peñas (kix)
5fe4160025 menuparser.c code clean
This patch do this changes:

1. Change (add/remove) blank lines
2. Join some if's in only one
3. Change c++ comments to c comments (// -> /* */)
4. Add / remove curly brackets if needed
5. Change spaces (add/remove) & set correct indentation
2012-07-28 18:39:40 +01:00
Christophe CURIS
b2e7620868 Menu parser: remove d-quotes around title of entry
When a menu entry contains a space, it is necessary to enclose it
in simple or double quotes; these were not removed and so would
appear in the menu.
2012-07-19 11:23:29 +01:00
Christophe CURIS
9ad278ddf8 Menu parser: added boundary checks in the path-gen for #include file search
When generating the full path+name of file to search for a file
being #included, it was generated in a buffer that's supposedly
large enough (MAXLINE > 2*PATH_MAX). However, this limit has a few
issues (PATH_MAX seem to be able to be bigger, and worse: we can't
be sure we're given longer args).

The code was rewrote to natively include boundary checks so we're
sure we won't overflow the buffer. A few strncpy have been removed
because in this case they tend to make things harder to write.
2012-07-19 11:23:29 +01:00
Christophe CURIS
ac52d4de65 Menu parser: fix possible infinite loop when loading menu file
When a #include is used, the file is searched in many places; when
the file was searched in the ':'-separated list of path it could
led to infinite loop if the list contained more than one path and
that the file was not found in the first path, the ':' separator
was not properly passed over.
2012-07-19 11:23:29 +01:00
Rodolfo García Peñas (kix)
fae81bf518 Format string bug in WMenuParserError
There is a format string (FS) bug in the function WMenuParserError.

It is the tipical FS bug, like printf(a) instead of printf("%s", a);

See http://en.wikipedia.org/wiki/Uncontrolled_format_string for more info.
2012-07-16 22:45:25 +01:00
Christophe CURIS
4658f4f9a1 Remove dependency to CPP: add support for conditional directives
It is now possible to use #ifdef/#ifndef to exclude some part of the
file. The implementation uses a stack to track conditionals so it is
possible to use nested constructs.
2012-07-14 20:22:20 +02:00
Christophe CURIS
9b792369cb Remove dependency to CPP: added pre-defined macros
A number of macros are pre-defined by WindowMaker for CPP in the
function 'MakeCPPArgs', they are now available in the internal
parser too. CPP also had some predefined macros, a subset of them
have been added.
The definition have been split in two parts:
 - the macro that are dependant on WindowMaker parameters are
defined by WindowMaker (src/rootmenu.c)
 - those that are independant, which can be defined by the parser
itself (WINGs/menuparser_macros.c)
2012-07-14 20:22:20 +02:00
Christophe CURIS
aaa4517df7 Remove dependency to CPP: support for #define macros
This adds support for defining new macros, with or without parameters, which
when found afterwards in the text are replaced by their definition.
The complex analysis for arguments replacement is done at macro definition
time, so it is done only once and the macro expansion will be fast.
The macro-related functions have been placed in their own file because it is
quite a complex task and we do not want filesize to explode, it is always
better to keep things human-sized.
2012-07-14 20:22:20 +02:00
Christophe CURIS
88a82ab8df Remove dependency to CPP: support for #include directive
The parser is prepared to handle '#' directives, starting with file
inclusion. The search path for the file are taken from what was
actually given to CPP. There is an arbitrary limit to the inclusion
nesting, which is actually not a design limitation but a security
to avoid infinite include loops.
2012-07-14 20:22:20 +02:00
Christophe CURIS
ed9482b626 Remove dependency to CPP: new parser that handles comments
Wrote a new parsing code that is able to skip over comments.
Note that because CPP is still active, you will not see any
effect unless you disable CPP pre-processing.
2012-07-14 20:22:20 +02:00