"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/idx.h" between
bison-3.8.1.tar.xz and bison-3.8.2.tar.xz

About: Bison is a general-purpose parser generator.

idx.h  (bison-3.8.1.tar.xz):idx.h  (bison-3.8.2.tar.xz)
skipping to change at line 59 skipping to change at line 59
The best way to get rid of such surprises is to use signed types The best way to get rid of such surprises is to use signed types
for numerical integer values, and use unsigned types only for for numerical integer values, and use unsigned types only for
bit masks and enums. bit masks and enums.
Why not use 'size_t' directly? Why not use 'size_t' directly?
* Because 'size_t' is an unsigned type, and a signed type is better. * Because 'size_t' is an unsigned type, and a signed type is better.
See above. See above.
Why not use 'ssize_t'?
* 'ptrdiff_t' is more portable; it is standardized by ISO C
whereas 'ssize_t' is standardized only by POSIX.
* 'ssize_t' is not required to be as wide as 'size_t', and some
now-obsolete POSIX platforms had 'size_t' wider than 'ssize_t'.
* Conversely, some now-obsolete platforms had 'ptrdiff_t' wider
than 'size_t', which can be a win and conforms to POSIX.
Won't this cause a problem with objects larger than PTRDIFF_MAX?
* Typical modern or large platforms do not allocate such objects,
so this is not much of a problem in practice; for example, you
can safely write 'idx_t len = strlen (s);'. To port to older
small platforms where allocations larger than PTRDIFF_MAX could
in theory be a problem, you can use Gnulib's ialloc module, or
functions like ximalloc in Gnulib's xalloc module.
Why not use 'ptrdiff_t' directly? Why not use 'ptrdiff_t' directly?
* Maintainability: When reading and modifying code, it helps to know that * Maintainability: When reading and modifying code, it helps to know that
a certain variable cannot have negative values. For example, when you a certain variable cannot have negative values. For example, when you
have a loop have a loop
int n = ...; int n = ...;
for (int i = 0; i < n; i++) ... for (int i = 0; i < n; i++) ...
or or
 End of changes. 1 change blocks. 
0 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)