This prevents LANG= in an included file from affecting the interpretation
of month and day names in the including file.
Make the internal pre-processor accept white space between the "#" at
the start of the line and the keyword for better compatibility with cpp.
Add support for the cpp keywords #warning and #error.
MFC after: 3 days
Fix one case where #else was not corerctly processed and simplify the
conditions logic.
Fix parsing of day and month names in the locale specified in the calendar
file. The previous version would expect those names to match the locale of
the user.
Mention that comments are now correctly processed and that // is supported
in addition to /* ... */.
MFC after: 3 days
Calendar files that specify LANG=... to specify their character encoding did
also set the date format defined for that locale, resulting in output like:
Nov 4 Gabriel Faure dies from pneumonia in Paris, France, 1924
4 nov. N'oubliez pas les Charles !
After this commit the output is always printed in a consistent format
according to the user's current locale, e.g.:
Nov 4 Gabriel Faure dies from pneumonia in Paris, France, 1924
Nov 4 N'oubliez pas les Charles !
I'll open a review asking for opinions whether this format change should
be merged to -STABLE.
Relnotes: yes
Add line number information to more warning and error messages.
Detect #else and #endif without corresponing #ifdef/#ifndef as error.
Detect missing #endif at end of file and print warning but continue.
Support for #undef has been added to reverse the effect of a prior #define.
It is no error if the argument value has not been defined before.
These changes may cause error aborts on malformed input files (e.g. with
spurious #else or #endif), but no such errors exist in the calendar files
in the FreeBSD base system and the calendar-data port and all tests pass.
More tests will be added in a follow-up commit to detect regressions that
might affect the newly added features.
This commit ends a series of updates that enhance the pre-processor and
make it behave much more like prior versions of the calendar progarm that
called cpp to pre-process the data files.
MFC after: 3 days
Relnotes: yes
The internal pre-processor ignored lines that did not parse a calendar
entries, but did not support multi-line comments in the way the external
cpp did.
The calendar files distributed with the base system (now in a port) do
use comments, though.
Implement comment processing for single-line (//) and multi-line comments
(/* */) with same semantics as in a standard C pre-processor.
All tests pass with this version, but there are no tests that specifically
verify comment processing.
Reported by: jhs@berklix.com (Julian H. Stacey)
MFC after: 3 days
The previous behavior was to support nested #ifdef and #ifndef, but to
return to unconditional parsing after the next #endif, independently of
the number of previously parsed conditions.
E.g. after "#ifdef A / #ifdef B / #endif" the following lines were
unconditially parsed again, independently of A and/or B being defined.
The new behavior is to count the level of false conditions and to only
restart parsing of calendar entries when the corresponding number of
#endif tokens have been seen.
In addition to the above, an #else directive has been added, to toggle
between parsing and ignoring of the following lines.
No validation of the correct use of the condition directives is made.
#endif without prior #define or #ifndef is ignored and #else toggles
between parsing and skipping of entries.
The MFC period has been set to 1 month to allow for a review of the
changes and for a discussion, whether these modifications should not
be merged at all.
No correct input file is parsed differently than before, but if calendar
data files are published that use these new features, those data files
will not parse correctly on prior versions of this program.
MFC after: 1 month
The convention in this program is to parse the line immediately starting
after the token (e.g. #defineA and #ifdefA define respectively look-up "A"),
and this commit restores this behavior instead of skipping an assumed
white-space character following #ifdef.
Reported by: kevans
MFC after: 3 days
There was code to process an #ifndef tokens, but none for #ifdef.
The #ifdef token was mentioned as unsupported in the BUGS section,
but no reason was given and I do not see why it should stay omitted.
Misleading information in The BUGS section of the man-page regarding
the maximum number of #define and #include statements supported has
been removed. These limits might have applied to a prior version of
this program, but do not seem to apply to the current implementation.
I have not tried to test for the existence of the limits, but the
include file processing just recursively calls the parser (without
counting the recursion depth) and the stringlist functions do not
impose a limit on the number of entries.
Reported by: jhs@berklix.com
MFC after: 3 days
Move all the data files for the calendar(1) program, except
calendar.freebsd to the calendar-data package. When a file
can't be found, and /usr/local/share/calendar doesn't exist
provide a helpful hint to install this package.
Reviewed by: se@
Differential Revision: https://reviews.freebsd.org/D26926
Calendar files in LOCALBASE override similarily named ones in the base
system. This could easily be changed if the base system calendars should
have precedence, but it could lead to a violation of POLA since then the
port's files were ignored unless those in base have been deleted.
There was no definition of _PATH_LOCALBASE in paths.h, but verbatim uses
of /usr/local existed for _PATH_DEFPATH. Use _PATH_LOCALBASE here to ease
a consistent modification of this prefix.
Reviewed by: imp, pfg
Differential Revision: https://reviews.freebsd.org/D26882
It does extremely useful things like execute sendmail and spew dubiously
accurate factoids.
From the feedback, it seems like it is an essential utility in a modern unix
and not at all a useless bikeshed. How do those Linux people live without it?
Reverts r358561.
o Do not run any iconv() processing in -a. The locale of root user is not
what is desired by most of the users who receive their calendar mail.
Just assume that users store their calendars in a format that is readable
to them. This fixes regression from r344340.
o fork() and setusercontext(LOGIN_SETALL) for every user. This makes LANG
set inside a calendar file mostly excessive, as we will pick up user's
login class LANG.
o This also executes complex function cal() that parses user owned files
with appropriate user privileges.
Previously it was run with privileges dropped only temporary for execution
of cal(), and fully dropped only before invoking sendmail (see r22473).
Reviewed by: bapt (older version of patch)
calendar(1) can have input in various encoding, specifying
LANG=<locale_name> to enable calendar(1) to determine which one to use.
The problem is the content of the calendar itself is exposed as is making it
unreadable in many cases. For example french calendar which is encoded
ISO8859-1 is rendered badly in a fr_FR.UTF-8 environment.
Using iconv allows to solve this issue.
This will also allow to keep only 1 encoding in base for those files without
breaking user existing setup
Reported by: many
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D19221
Mainly focus on files that use BSD 3-Clause license.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.
Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96
Support includes surrounded by '"' or '<' '>'
Print warnings about bad syntax
Correctly navigate through include directories to find calendar files
Correctly support multiple includes
Tested by: gjb
MFC after: 1 week
Explicitly use GNU cpp for preprocessing.
Remove explicit debugging code.
Change some variable names to be less confusing.
Improve some comments.
Improve indentation.
PR: 162211
168785
MFC after: 2 weeks
In addition to adding `static' where possible:
- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.
- Add ? option to optstring.
- Sort options alphabetically.
- Vertical space.
Tidy up usage() function.
Bring man page in sync with source.
Ensure that debug code is only executed with the -d option.
Submitted by: Christiane Yeardley
- Remove the 3rd clause of the UC Berkeley copyrighted files.
- For the files added copyrighted by me, move the "All rights
reserved" to the next line.
- Repeating events which span multiple years (because of -A, -B or
just the three days before the end of the year).
- Support for lunar events (full moon, new moon) and solar events
(equinox and solstice, chinese new year). Because of this, the
options -U (UTC offset) and -l (longitude) are available to
compensate if reality doesn't match the calculated values.
MFC after: 1 month
Correct long-standing off-by-one error in -W option.
Submitted by: edwin@
Shorten some long lines. These files are still not completely
style(9) compliant.