�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!usr/share/doc/systemd/HACKING000064400000013605152530062600011707 0ustar00HACKING ON SYSTEMD We welcome all contributions to systemd. If you notice a bug or a missing feature, please feel invited to fix it, and submit your work as a github Pull Request (PR): https://github.com/systemd/systemd/pull/new Please make sure to follow our Coding Style when submitting patches. See doc/CODING_STYLE for details. Also have a look at our Contribution Guidelines: https://github.com/systemd/systemd/blob/master/.github/CONTRIBUTING.md When adding new functionality, tests should be added. For shared functionality (in src/basic and src/shared) unit tests should be sufficient. The general policy is to keep tests in matching files underneath src/test, e.g. src/test/test-path-util.c contains tests for any functions in src/basic/path-util.c. If adding a new source file, consider adding a matching test executable. For features at a higher level, tests in src/test/ are very strongly recommended. If that is no possible, integration tests in test/ are encouraged. Please also have a look at our list of code quality tools we have setup for systemd, to ensure our codebase stays in good shape: https://github.com/systemd/systemd/blob/master/doc/CODE_QUALITY.md Please always test your work before submitting a PR. For many of the components of systemd testing is straight-forward as you can simply compile systemd and run the relevant tool from the build directory. For some components (most importantly, systemd/PID1 itself) this is not possible, however. In order to simplify testing for cases like this we provide a set of "mkosi" build files directly in the source tree. "mkosi" is a tool for building clean OS images from an upstream distribution in combination with a fresh build of the project in the local working directory. To make use of this, please acquire "mkosi" from https://github.com/systemd/mkosi first, unless your distribution has packaged it already and you can get it from there. After the tool is installed it is sufficient to type "mkosi" in the systemd project directory to generate a disk image "image.raw" you can boot either in systemd-nspawn or in an UEFI-capable VM: # systemd-nspawn -bi image.raw or: # qemu-system-x86_64 -enable-kvm -m 512 -smp 2 -bios /usr/share/edk2/ovmf/OVMF_CODE.fd -hda image.raw Every time you rerun the "mkosi" command a fresh image is built, incorporating all current changes you made to the project tree. Alternatively, you may install the systemd version from your git check-out directly on top of your host system's directory tree. This mostly works fine, but of course you should know what you are doing as you might make your system unbootable in case of a bug in your changes. Also, you might step into your package manager's territory with this. Be careful! And never forget: most distributions provide very simple and convenient ways to install all development packages necessary to build systemd. For example, on Fedora the following command line should be sufficient to install all of systemd's build dependencies: # dnf builddep systemd Putting this all together, here's a series of commands for preparing a patch for systemd (this example is for Fedora): $ sudo dnf builddep systemd # install build dependencies $ sudo dnf install mkosi # install tool to quickly build images $ git clone https://github.com/systemd/systemd.git $ cd systemd $ vim src/core/main.c # or wherever you'd like to make your changes $ meson build # configure the build $ ninja -C build # build it locally, see if everything compiles fine $ ninja -C build test # run some simple regression tests $ (umask 077; echo 123 > mkosi.rootpw) # set root password used by mkosi $ sudo mkosi # build a test image $ sudo systemd-nspawn -bi image.raw # boot up the test image $ git add -p # interactively put together your patch $ git commit # commit it $ git push REMOTE HEAD:refs/heads/BRANCH # where REMOTE is your "fork" on github # and BRANCH is a branch name. And after that, head over to your repo on github and click "Compare & pull request" Happy hacking! FUZZERS systemd includes fuzzers in src/fuzz that use libFuzzer and are automatically run by OSS-Fuzz (https://github.com/google/oss-fuzz) with sanitizers. To add a fuzz target, create a new src/fuzz/fuzz-foo.c file with a LLVMFuzzerTestOneInput function and add it to the list in src/fuzz/meson.build. Whenever possible, a seed corpus and a dictionary should also be added with new fuzz targets. The dictionary should be named src/fuzz/fuzz-foo.dict and the seed corpus should be built and exported as $OUT/fuzz-foo_seed_corpus.zip in tools/oss-fuzz.sh. The fuzzers can be built locally if you have libFuzzer installed by running tools/oss-fuzz.sh. You should also confirm that the fuzzer runs in the OSS-Fuzz environment by checking out the OSS-Fuzz repo, and then running commands like this: python infra/helper.py build_image systemd python infra/helper.py build_fuzzers --sanitizer memory systemd ../systemd python infra/helper.py run_fuzzer systemd fuzz-foo If you find a bug that impacts the security of systemd, please follow the guidance in .github/CONTRIBUTING.md on how to report a security vulnerability. For more details on building fuzzers and integrating with OSS-Fuzz, visit: https://github.com/google/oss-fuzz/blob/master/docs/new_project_guide.md https://llvm.org/docs/LibFuzzer.html https://github.com/google/fuzzer-test-suite/blob/master/tutorial/libFuzzerTutorial.md https://chromium.googlesource.com/chromium/src/testing/libfuzzer/+/HEAD/efficient_fuzzer.md usr/share/doc/dbus-daemon/HACKING000064400000032500152533627720012425 0ustar00The guidelines in this file are the ideals; it's better to send a not-fully-following-guidelines patch than no patch at all, though. We can always polish it up. Mailing list === The D-Bus mailing list is dbus@lists.freedesktop.org; discussion of patches, etc. should go there. Security === If you find a security vulnerability that is not known to the public, please report it privately to dbus-security@lists.freedesktop.org or by reporting a freedesktop.org bug that is marked as restricted to the "D-BUS security group". Most of D-Bus is security sensitive. Guidelines related to that: - avoid memcpy(), sprintf(), strlen(), snprintf, strlcat(), strstr(), strtok(), or any of this stuff. Use DBusString. If DBusString doesn't have the feature you need, add it to DBusString. There are some exceptions, for example if your strings are just used to index a hash table and you don't do any parsing/modification of them, perhaps DBusString is wasteful and wouldn't help much. But definitely if you're doing any parsing, reallocation, etc. use DBusString. - do not include system headers outside of dbus-memory.c, dbus-sysdeps.c, and other places where they are already included. This gives us one place to audit all external dependencies on features in libc, etc. - do not use libc features that are "complicated" and may contain security holes. For example, you probably shouldn't try to use regcomp() to compile an untrusted regular expression. Regular expressions are just too complicated, and there are many different libc's out there. - we need to design the message bus daemon (and any similar features) to use limited privileges, run in a chroot jail, and so on. http://vsftpd.beasts.org/ has other good security suggestions. Coding Style === - The C library uses GNU coding conventions, with GLib-like extensions (e.g. lining up function arguments). The Qt wrapper uses KDE coding conventions. - Write docs for all non-static functions and structs and so on. try "doxygen Doxyfile" prior to commit and be sure there are no warnings printed. - All external interfaces (network protocols, file formats, etc.) should have documented specifications sufficient to allow an alternative implementation to be written. Our implementation should be strict about specification compliance (should not for example heuristically parse a file and accept not-well-formed data). Avoiding heuristics is also important for security reasons; if it looks funny, ignore it (or exit, or disconnect). Development === D-Bus uses Git as its version control system. The main repository is hosted on freedesktop.org. To clone D-Bus, execute one of the following commands: git clone https://anongit.freedesktop.org/git/dbus/dbus.git git clone git://anongit.freedesktop.org/dbus/dbus git clone ssh://git.freedesktop.org/git/dbus/dbus The last form is the one that allows pushing, but it also requires an SSH account on the server. The other forms allow anonymous checkouts. D-Bus development happens in two branches in parallel: the current stable branch, with an even minor number (like 1.0, 1.2 and 1.4), and the next development branch, with the next odd number. The stable branch is named after the version number itself (dbus-1.2, dbus-1.4), whereas the development branch is simply known as "master". When making a change to D-Bus, do the following: - check out the earliest branch of D-Bus that makes sense to have your change in. If it's a bugfix, it's normally the current stable branch; if it's a feature, it's normally the "master" branch. If you have an important security fix, you may want to apply to older branches too. - for large changes: if you're developing a new, large feature, it's recommended to create a new branch and do your development there. Publish your branch at a suitable place and ask others to help you develop and test it. Once your feature is considered finalised, you may merge it into the "master" branch. - for small changes: . make your change to the source code . execute tests to guarantee that you're not introducing a regression. For that, execute: make check (if possible, add a new test to check the fix you're introducing) . commit your change using "git commit" in the commit message, write a short sentence describing what you did in the first line. Then write a longer description in the next paragraph(s). . repeat the previous steps if necessary to have multiple commits - extract your patches and send to the D-Bus mailing list for review or post them to the D-Bus Bugzilla, attaching them to a bug report. To extract the patches, execute: git format-patch origin/master - once your code has been reviewed, you may push it to the Git server: git push origin my-branch:remote OR git push origin dbus-X.Y OR git push origin master (consult the Git manual to know which command applies) - (Optional) if you've not worked on "master", merge your changes to that branch. If you've worked on an earlier branch than the current stable, merge your changes upwards towards the stable branch, then from there into "master". . execute: git checkout master . ensure that you have the latest "master" from the server, update if you don't . execute: git merge dbus-X.Y . if you have any conflicts, resolve them, git add the conflicted files and then git commit . push the "master" branch to the server as well Executing this merge is recommended, but not necessary for all changes. You should do this step if your bugfix is critical for the development in "master", or if you suspect that conflicts will arise (you're usually the best person to resolve conflicts introduced by your own code), or if it has been too long since the last merge. Making a release === To make a release of D-Bus, do the following: - check out a fresh copy from Git - verify that the libtool versioning/library soname is changed if it needs to be, or not changed if not - update the file NEWS based on the git history - verify that the version number of dbus-specification.xml is changed if it needs to be; if changes have been made, update the release date in that file - update the AUTHORS file with "make update-authors" if necessary - the version number should have major.minor.micro, even if micro is 0, i.e. "1.0.0" and "1.2.0" not "1.0"/"1.2"; the micro version should be even for releases, and odd for intermediate snapshots - "make distcheck" (DO NOT just "make dist" - pass the check!) - if make distcheck fails, fix it. - once distcheck succeeds, "git commit -a". This is the version of the tree that corresponds exactly to the released tarball. - tag the tree with "git tag -s -m 'Released X.Y.Z' dbus-X.Y.Z" where X.Y.Z is the version of the release. If you can't sign then simply created an unsigned annotated tag: "git tag -a -m 'Released X.Y.Z' dbus-X.Y.Z". - bump the version number up in configure.ac (so the micro version is odd), and commit it. Make sure you do this *after* tagging the previous release! The idea is that git has a newer version number than anything released. Similarly, bump the version number of dbus-specification.xml and set the release date to "(not finalized)". - merge the branch you've released to the chronologically-later branch (usually "master"). You'll probably have to fix a merge conflict in configure.ac (the version number). - push your changes and the tag to the central repository with git push origin master dbus-X.Y dbus-X.Y.Z - scp your tarball to freedesktop.org server and copy it to dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/releases/dbus/dbus-X.Y.Z.tar.gz. This should be possible if you're in group "dbus" - Update the online documentation with `make -C doc maintainer-upload-docs`. - update the wiki page http://www.freedesktop.org/Software/dbus by adding the new release under the Download heading. Then, cut the link and changelog for the previous that was there. - update the wiki page http://www.freedesktop.org/Software/DbusReleaseArchive pasting the previous release. Note that bullet points for each of the changelog items must be indented three more spaces to conform to the formatting of the other releases there. - post to dbus@lists.freedesktop.org announcing the release. Making a ".0" stable release === We create a branch for each stable release. The branch name should be dbus-X.Y which is a branch that has releases versioned X.Y.Z; changes on a stable branch should be limited to significant bug fixes. Because we won't make minor changes like keeping up with the latest deprecations on a stable branch, stable branches should turn off the gcc warning for deprecated declarations (e.g. see commit 4ebb275ab7). Be extra-careful not to merge master (or any branch based on master) into a stable branch. To branch: git branch dbus-X.Y and upload the branch tag to the server: git push origin dbus-X.Y To develop in this branch: git checkout dbus-X.Y Environment variables === These are the environment variables that are used by the D-Bus client library DBUS_VERBOSE=1 Turns on printing verbose messages. This only works if D-Bus has been compiled with --enable-verbose-mode DBUS_MALLOC_FAIL_NTH=n Can be set to a number, causing every nth call to dbus_alloc or dbus_realloc to fail. This only works if D-Bus has been compiled with --enable-tests. DBUS_MALLOC_FAIL_GREATER_THAN=n Can be set to a number, causing every call to dbus_alloc or dbus_realloc to fail if the number of bytes to be allocated is greater than the specified number. This only works if D-Bus has been compiled with --enable-tests. DBUS_TEST_MALLOC_FAILURES=n Many of the D-Bus tests will run over and over, once for each malloc involved in the test. Each run will fail a different malloc, plus some number of mallocs following that malloc (because a fair number of bugs only happen if two or more mallocs fail in a row, e.g. error recovery that itself involves malloc). This env variable sets the number of mallocs to fail. Here's why you care: If set to 0, then the malloc checking is skipped, which makes the test suite a heck of a lot faster. Just run with this env variable unset before you commit. Tests === These are the test programs that are built if dbus is compiled using --enable-tests. dbus/test-dbus This is the main unit test program that tests all aspects of the D-Bus client library. dbus/bus-test This it the unit test program for the message bus. test/break-loader A test that tries to break the message loader by passing it randomly created invalid messages. test/name-test/* This is a suite of programs which are run with a temporary session bus. If your test involves multiple processes communicating, your best bet is to add a test in here. "make check" runs all the deterministic test programs (i.e. not break-loader). "make lcov-check" is available if you configure with --enable-compiler-coverage and gives a complete report on test suite coverage. Patches === Please file them at http://bugzilla.freedesktop.org under component dbus, and also post to the mailing list for discussion. The commit rules are: - for fixes that don't affect API or protocol, they can be committed if any one qualified reviewer other than patch author reviews and approves - for fixes that do affect API or protocol, two people in the reviewer group have to review and approve the commit, and posting to the list is definitely mandatory - if there's a live unresolved controversy about a change, don't commit it while the argument is still raging. - at their discretion, members of the reviewer group may also commit branches/patches under these conditions: - the branch does not add or change API, ABI or wire-protocol - the branch solves a known problem and is covered by the regression tests - there are no objections from the rest of the review group within a week of the patches being attached to Bugzilla - the committer gets a positive review on Bugzilla from someone they consider qualified to review the change (e.g. a colleague with D-Bus experience; not necessarily a member of the reviewer group) - regardless of reviews, to commit a patch: - make check must pass - the test suite must be extended to cover the new code as much as reasonably feasible (see Tests above) - the patch has to follow the portability, security, and style guidelines - the patch should as much as reasonable do one thing, not many unrelated changes No reviewer should approve a patch without these attributes, and failure on these points is grounds for reverting the patch. The reviewer group that can approve patches: Havoc Pennington Michael Meeks Alexander Larsson Zack Rusin Joe Shaw Mikael Hallendal Richard Hult Owen Fraser-Green Olivier Andrieu Colin Walters Thiago Macieira John Palmieri Scott James Remnant Will Thompson Simon McVittie David Zeuthen usr/share/doc/pcre2-devel/HACKING000064400000112656152533766200012347 0ustar00Technical Notes about PCRE2 --------------------------- These are very rough technical notes that record potentially useful information about PCRE2 internals. PCRE2 is a library based on the original PCRE library, but with a revised (and incompatible) API. To avoid confusion, the original library is referred to as PCRE1 below. For information about testing PCRE2, see the pcre2test documentation and the comment at the head of the RunTest file. PCRE1 releases were up to 8.3x when PCRE2 was developed, and later bug fix releases remain in the 8.xx series. PCRE2 releases started at 10.00 to avoid confusion with PCRE1. Historical note 1 ----------------- Many years ago I implemented some regular expression functions to an algorithm suggested by Martin Richards. The rather simple patterns were not Unix-like in form, and were quite restricted in what they could do by comparison with Perl. The interesting part about the algorithm was that the amount of space required to hold the compiled form of an expression was known in advance. The code to apply an expression did not operate by backtracking, as the original Henry Spencer code and current PCRE2 and Perl code does, but instead checked all possibilities simultaneously by keeping a list of current states and checking all of them as it advanced through the subject string. In the terminology of Jeffrey Friedl's book, it was a "DFA algorithm", though it was not a traditional Finite State Machine (FSM). When the pattern was all used up, all remaining states were possible matches, and the one matching the longest subset of the subject string was chosen. This did not necessarily maximize the individual wild portions of the pattern, as is expected in Unix and Perl-style regular expressions. Historical note 2 ----------------- By contrast, the code originally written by Henry Spencer (which was subsequently heavily modified for Perl) compiles the expression twice: once in a dummy mode in order to find out how much store will be needed, and then for real. (The Perl version probably doesn't do this any more; I'm talking about the original library.) The execution function operates by backtracking and maximizing (or, optionally, minimizing, in Perl) the amount of the subject that matches individual wild portions of the pattern. This is an "NFA algorithm" in Friedl's terminology. OK, here's the real stuff ------------------------- For the set of functions that formed the original PCRE1 library in 1997 (which are unrelated to those mentioned above), I tried at first to invent an algorithm that used an amount of store bounded by a multiple of the number of characters in the pattern, to save on compiling time. However, because of the greater complexity in Perl regular expressions, I couldn't do this, even though the then current Perl 5.004 patterns were much simpler than those supported nowadays. In any case, a first pass through the pattern is helpful for other reasons. Support for 16-bit and 32-bit data strings ------------------------------------------- The PCRE2 library can be compiled in any combination of 8-bit, 16-bit or 32-bit modes, creating up to three different libraries. In the description that follows, the word "short" is used for a 16-bit data quantity, and the phrase "code unit" is used for a quantity that is a byte in 8-bit mode, a short in 16-bit mode and a 32-bit word in 32-bit mode. The names of PCRE2 functions are given in generic form, without the _8, _16, or _32 suffix. Computing the memory requirement: how it was -------------------------------------------- Up to and including release 6.7, PCRE1 worked by running a very degenerate first pass to calculate a maximum memory requirement, and then a second pass to do the real compile - which might use a bit less than the predicted amount of memory. The idea was that this would turn out faster than the Henry Spencer code because the first pass is degenerate and the second pass can just store stuff straight into memory, which it knows is big enough. Computing the memory requirement: how it is ------------------------------------------- By the time I was working on a potential 6.8 release, the degenerate first pass had become very complicated and hard to maintain. Indeed one of the early things I did for 6.8 was to fix Yet Another Bug in the memory computation. Then I had a flash of inspiration as to how I could run the real compile function in a "fake" mode that enables it to compute how much memory it would need, while in most cases only ever using a small amount of working memory, and without too many tests of the mode that might slow it down. So I refactored the compiling functions to work this way. This got rid of about 600 lines of source and made further maintenance and development easier. As this was such a major change, I never released 6.8, instead upping the number to 7.0 (other quite major changes were also present in the 7.0 release). A side effect of this work was that the previous limit of 200 on the nesting depth of parentheses was removed. However, there was a downside: compiling ran more slowly than before (30% or more, depending on the pattern) because it now did a full analysis of the pattern. My hope was that this would not be a big issue, and in the event, nobody has commented on it. At release 8.34, a limit on the nesting depth of parentheses was re-introduced (default 250, settable at build time) so as to put a limit on the amount of system stack used by the compile function, which uses recursive function calls for nested parenthesized groups. This is a safety feature for environments with small stacks where the patterns are provided by users. Yet another pattern scan ------------------------ History repeated itself for PCRE2 release 10.20. A number of bugs relating to named subpatterns had been discovered by fuzzers. Most of these were related to the handling of forward references when it was not known if the named group was unique. (References to non-unique names use a different opcode and more memory.) The use of duplicate group numbers (the (?| facility) also caused issues. To get around these problems I adopted a new approach by adding a third pass over the pattern (really a "pre-pass"), which did nothing other than identify all the named subpatterns and their corresponding group numbers. This means that the actual compile (both the memory-computing dummy run and the real compile) has full knowledge of group names and numbers throughout. Several dozen lines of messy code were eliminated, though the new pre-pass was not short. In particular, parsing and skipping over [] classes is complicated. While working on 10.22 I realized that I could simplify yet again by moving more of the parsing into the pre-pass, thus avoiding doing it in two places, so after 10.22 was released, the code underwent yet another big refactoring. This is how it is from 10.23 onwards: The function called parse_regex() scans the pattern characters, parsing them into literal data and meta characters. It converts escapes such as \x{123} into literals, handles \Q...\E, and skips over comments and non-significant white space. The result of the scanning is put into a vector of 32-bit unsigned integers. Values less than 0x80000000 are literal data. Higher values represent meta-characters. The top 16-bits of such values identify the meta-character, and these are given names such as META_CAPTURE. The lower 16-bits are available for data, for example, the capturing group number. The only situation in which literal data values greater than 0x7fffffff can appear is when the 32-bit library is running in non-UTF mode. This is handled by having a special meta-character that is followed by the 32-bit data value. The size of the parsed pattern vector, when auto-callouts are not enabled, is bounded by the length of the pattern (with one exception). The code is written so that each item in the pattern uses no more vector elements than the number of code units in the item itself. The exception is the aforementioned large 32-bit number handling. For this reason, 32-bit non-UTF patterns are scanned in advance to check for such values. When auto-callouts are enabled, the generous assumption is made that there will be a callout for each pattern code unit (which of course is only actually true if all code units are literals) plus one at the end. There is a default parsed pattern vector on the system stack, but if this is not big enough, heap memory is used. As before, the actual compiling function is run twice, the first time to determine the amount of memory needed for the final compiled pattern. It now processes the parsed pattern vector, not the pattern itself, although some of the parsed items refer to strings in the pattern - for example, group names. As escapes and comments have already been processed, the code is a bit simpler than before. Most errors can be diagnosed during the parsing scan. For those that cannot (for example, "lookbehind assertion is not fixed length"), the parsed code contains offsets into the pattern so that the actual compiling code can report where errors are. The elements of the parsed pattern vector ----------------------------------------- The word "offset" below means a code unit offset into the pattern. When PCRE2_SIZE (which is usually size_t) is no bigger than uint32_t, an offset is stored in a single parsed pattern element. Otherwise (typically on 64-bit systems) it occupies two elements. The following meta items occupy just one element, with no data: META_ACCEPT (*ACCEPT) META_ASTERISK * META_ASTERISK_PLUS *+ META_ASTERISK_QUERY *? META_ATOMIC (?> start of atomic group META_CIRCUMFLEX ^ metacharacter META_CLASS [ start of non-empty class META_CLASS_EMPTY [] empty class - only with PCRE2_ALLOW_EMPTY_CLASS META_CLASS_EMPTY_NOT [^] negative empty class - ditto META_CLASS_END ] end of non-empty class META_CLASS_NOT [^ start non-empty negative class META_COMMIT (*COMMIT) META_COND_ASSERT (?(?assertion) META_DOLLAR $ metacharacter META_DOT . metacharacter META_END End of pattern (this value is 0x80000000) META_FAIL (*FAIL) META_KET ) closing parenthesis META_LOOKAHEAD (?= start of lookahead META_LOOKAHEADNOT (?! start of negative lookahead META_NOCAPTURE (?: no capture parens META_PLUS + META_PLUS_PLUS ++ META_PLUS_QUERY +? META_PRUNE (*PRUNE) - no argument META_QUERY ? META_QUERY_PLUS ?+ META_QUERY_QUERY ?? META_RANGE_ESCAPED hyphen in class range with at least one escape META_RANGE_LITERAL hyphen in class range defined literally META_SKIP (*SKIP) - no argument META_THEN (*THEN) - no argument The two RANGE values occur only in character classes. They are positioned between two literals that define the start and end of the range. In an EBCDIC evironment it is necessary to know whether either of the range values was specified as an escape. In an ASCII/Unicode environment the distinction is not relevant. The following have data in the lower 16 bits, and may be followed by other data elements: META_ALT | alternation META_BACKREF back reference META_CAPTURE start of capturing group META_ESCAPE non-literal escape sequence META_RECURSE recursion call If the data for META_ALT is non-zero, it is inside a lookbehind, and the data is the length of its branch, for which OP_REVERSE must be generated. META_BACKREF, META_CAPTURE, and META_RECURSE have the capture group number as their data in the lower 16 bits of the element. META_BACKREF is followed by an offset if the back reference group number is 10 or more. The offsets of the first ocurrences of references to groups whose numbers are less than 10 are put in cb->small_ref_offset[] (only the first occurrence is useful). On 64-bit systems this avoids using more than two parsed pattern elements for items such as \3. The offset is used when an error occurs because the reference is to a non-existent group. META_RECURSE is always followed by an offset, for use in error messages. META_ESCAPE has an ESC_xxx value as its data. For ESC_P and ESC_p, the next element contains the 16-bit type and data property values, packed together. ESC_g and ESC_k are used only for named references - numerical ones are turned into META_RECURSE or META_BACKREF as appropriate. ESC_g and ESC_k are followed by a length and an offset into the pattern to specify the name. The following have one data item that follows in the next vector element: META_BIGVALUE Next is a literal >= META_END META_OPTIONS (?i) and friends (data is new option bits) META_POSIX POSIX class item (data identifies the class) META_POSIX_NEG negative POSIX class item (ditto) The following are followed by a length element, then a number of character code values (which should match with the length): META_MARK (*MARK:xxxx) META_COMMIT_ARG )*COMMIT:xxxx) META_PRUNE_ARG (*PRUNE:xxx) META_SKIP_ARG (*SKIP:xxxx) META_THEN_ARG (*THEN:xxxx) The following are followed by a length element, then an offset in the pattern that identifies the name: META_COND_NAME (?() or (?('name') or (?(name) META_COND_RNAME (?(R&name) META_COND_RNUMBER (?(Rdigits) META_RECURSE_BYNAME (?&name) META_BACKREF_BYNAME \k'name' META_COND_RNUMBER is used for names that start with R and continue with digits, because this is an ambiguous case. It could be a back reference to a group with that name, or it could be a recursion test on a numbered group. This one is followed by an offset, for use in error messages, then a number: META_COND_NUMBER (?([+-]digits) The following is followed just by an offset, for use in error messages: META_COND_DEFINE (?(DEFINE) The following are also followed just by an offset, but also the lower 16 bits of the main word contain the length of the first branch of the lookbehind group; this is used when generating OP_REVERSE for that branch. META_LOOKBEHIND (?<= META_LOOKBEHINDNOT (?' and 1 for '>='; the next two are the major and minor numbers: META_COND_VERSION (?(VERSIONx.y) Callouts are converted into one of two items: META_CALLOUT_NUMBER (?C with numerical argument META_CALLOUT_STRING (?C with string argument In both cases, the next two elements contain the offset and length of the next item in the pattern. Then there is either one callout number, or a length and an offset for the string argument. The length includes both delimiters. Traditional matching function ----------------------------- The "traditional", and original, matching function is called pcre2_match(), and it implements an NFA algorithm, similar to the original Henry Spencer algorithm and the way that Perl works. This is not surprising, since it is intended to be as compatible with Perl as possible. This is the function most users of PCRE2 will use most of the time. If PCRE2 is compiled with just-in-time (JIT) support, and studying a compiled pattern with JIT is successful, the JIT code is run instead of the normal pcre2_match() code, but the result is the same. Supplementary matching function ------------------------------- There is also a supplementary matching function called pcre2_dfa_match(). This implements a DFA matching algorithm that searches simultaneously for all possible matches that start at one point in the subject string. (Going back to my roots: see Historical Note 1 above.) This function intreprets the same compiled pattern data as pcre2_match(); however, not all the facilities are available, and those that are do not always work in quite the same way. See the user documentation for details. The algorithm that is used for pcre2_dfa_match() is not a traditional FSM, because it may have a number of states active at one time. More work would be needed at compile time to produce a traditional FSM where only one state is ever active at once. I believe some other regex matchers work this way. JIT support is not available for this kind of matching. Changeable options ------------------ The /i, /m, or /s options (PCRE2_CASELESS, PCRE2_MULTILINE, PCRE2_DOTALL, and others) may be changed in the middle of patterns by items such as (?i). Their processing is handled entirely at compile time by generating different opcodes for the different settings. The runtime functions do not need to keep track of an option's state. PCRE2_DUPNAMES, PCRE2_EXTENDED, PCRE2_EXTENDED_MORE, and PCRE2_NO_AUTO_CAPTURE are tracked and processed during the parsing pre-pass. The others are handled from META_OPTIONS items during the main compile phase. Format of compiled patterns --------------------------- The compiled form of a pattern is a vector of unsigned code units (bytes in 8-bit mode, shorts in 16-bit mode, 32-bit words in 32-bit mode), containing items of variable length. The first code unit in an item contains an opcode, and the length of the item is either implicit in the opcode or contained in the data that follows it. In many cases listed below, LINK_SIZE data values are specified for offsets within the compiled pattern. LINK_SIZE always specifies a number of bytes. The default value for LINK_SIZE is 2, except for the 32-bit library, where it can only be 4. The 8-bit library can be compiled to used 3-byte or 4-byte values, and the 16-bit library can be compiled to use 4-byte values, though this impairs performance. Specifing a LINK_SIZE larger than 2 for these libraries is necessary only when patterns whose compiled length is greater than 65535 code units are going to be processed. When a LINK_SIZE value uses more than one code unit, the most significant unit is first. In this description, we assume the "normal" compilation options. Data values that are counts (e.g. quantifiers) are always two bytes long in 8-bit mode (most significant byte first), and one code unit in 16-bit and 32-bit modes. Opcodes with no following data ------------------------------ These items are all just one unit long: OP_END end of pattern OP_ANY match any one character other than newline OP_ALLANY match any one character, including newline OP_ANYBYTE match any single code unit, even in UTF-8/16 mode OP_SOD match start of data: \A OP_SOM, start of match (subject + offset): \G OP_SET_SOM, set start of match (\K) OP_CIRC ^ (start of data) OP_CIRCM ^ multiline mode (start of data or after newline) OP_NOT_WORD_BOUNDARY \W OP_WORD_BOUNDARY \w OP_NOT_DIGIT \D OP_DIGIT \d OP_NOT_HSPACE \H OP_HSPACE \h OP_NOT_WHITESPACE \S OP_WHITESPACE \s OP_NOT_VSPACE \V OP_VSPACE \v OP_NOT_WORDCHAR \W OP_WORDCHAR \w OP_EODN match end of data or newline at end: \Z OP_EOD match end of data: \z OP_DOLL $ (end of data, or before final newline) OP_DOLLM $ multiline mode (end of data or before newline) OP_EXTUNI match an extended Unicode grapheme cluster OP_ANYNL match any Unicode newline sequence OP_ASSERT_ACCEPT ) OP_ACCEPT ) These are Perl 5.10's "backtracking control OP_COMMIT ) verbs". If OP_ACCEPT is inside capturing OP_FAIL ) parentheses, it may be preceded by one or more OP_PRUNE ) OP_CLOSE, each followed by a number that OP_SKIP ) indicates which parentheses must be closed. OP_THEN ) OP_ASSERT_ACCEPT is used when (*ACCEPT) is encountered within an assertion. This ends the assertion, not the entire pattern match. The assertion (?!) is always optimized to OP_FAIL. OP_ALLANY is used for '.' when PCRE2_DOTALL is set. It is also used for \C in non-UTF modes and in UTF-32 mode (since one code unit still equals one character). Another use is for [^] when empty classes are permitted (PCRE2_ALLOW_EMPTY_CLASS is set). Backtracking control verbs -------------------------- Verbs with no arguments generate opcodes with no following data (as listed in the section above). (*MARK:NAME) generates OP_MARK followed by the mark name, preceded by a length in one code unit, and followed by a binary zero. The name length is limited by the size of the code unit. (*ACCEPT:NAME) and (*FAIL:NAME) are compiled as (*MARK:NAME)(*ACCEPT) and (*MARK:NAME)(*FAIL) respectively. For (*COMMIT:NAME), (*PRUNE:NAME), (*SKIP:NAME), and (*THEN:NAME), the opcodes OP_COMMIT_ARG, OP_PRUNE_ARG, OP_SKIP_ARG, and OP_THEN_ARG are used, with the name following in the same format as for OP_MARK. Matching literal characters --------------------------- The OP_CHAR opcode is followed by a single character that is to be matched casefully. For caseless matching of characters that have at most two case-equivalent code points, OP_CHARI is used. In UTF-8 or UTF-16 modes, the character may be more than one code unit long. In UTF-32 mode, characters are always exactly one code unit long. If there is only one character in a character class, OP_CHAR or OP_CHARI is used for a positive class, and OP_NOT or OP_NOTI for a negative one (that is, for something like [^a]). Caseless matching (positive or negative) of characters that have more than two case-equivalent code points (which is possible only in UTF mode) is handled by compiling a Unicode property item (see below), with the pseudo-property PT_CLIST. The value of this property is an offset in a vector called "ucd_caseless_sets" which identifies the start of a short list of equivalent characters, terminated by the value NOTACHAR (0xffffffff). Repeating single characters --------------------------- The common repeats (*, +, ?), when applied to a single character, use the following opcodes, which come in caseful and caseless versions: Caseful Caseless OP_STAR OP_STARI OP_MINSTAR OP_MINSTARI OP_POSSTAR OP_POSSTARI OP_PLUS OP_PLUSI OP_MINPLUS OP_MINPLUSI OP_POSPLUS OP_POSPLUSI OP_QUERY OP_QUERYI OP_MINQUERY OP_MINQUERYI OP_POSQUERY OP_POSQUERYI Each opcode is followed by the character that is to be repeated. In ASCII or UTF-32 modes, these are two-code-unit items; in UTF-8 or UTF-16 modes, the length is variable. Those with "MIN" in their names are the minimizing versions. Those with "POS" in their names are possessive versions. Other kinds of repeat make use of these opcodes: Caseful Caseless OP_UPTO OP_UPTOI OP_MINUPTO OP_MINUPTOI OP_POSUPTO OP_POSUPTOI OP_EXACT OP_EXACTI Each of these is followed by a count and then the repeated character. The count is two bytes long in 8-bit mode (most significant byte first), or one code unit in 16-bit and 32-bit modes. OP_UPTO matches from 0 to the given number. A repeat with a non-zero minimum and a fixed maximum is coded as an OP_EXACT followed by an OP_UPTO (or OP_MINUPTO or OPT_POSUPTO). Another set of matching repeating opcodes (called OP_NOTSTAR, OP_NOTSTARI, etc.) are used for repeated, negated, single-character classes such as [^a]*. The normal single-character opcodes (OP_STAR, etc.) are used for repeated positive single-character classes. Repeating character types ------------------------- Repeats of things like \d are done exactly as for single characters, except that instead of a character, the opcode for the type (e.g. OP_DIGIT) is stored in the next code unit. The opcodes are: OP_TYPESTAR OP_TYPEMINSTAR OP_TYPEPOSSTAR OP_TYPEPLUS OP_TYPEMINPLUS OP_TYPEPOSPLUS OP_TYPEQUERY OP_TYPEMINQUERY OP_TYPEPOSQUERY OP_TYPEUPTO OP_TYPEMINUPTO OP_TYPEPOSUPTO OP_TYPEEXACT Match by Unicode property ------------------------- OP_PROP and OP_NOTPROP are used for positive and negative matches of a character by testing its Unicode property (the \p and \P escape sequences). Each is followed by two code units that encode the desired property as a type and a value. The types are a set of #defines of the form PT_xxx, and the values are enumerations of the form ucp_xx, defined in the pcre2_ucp.h source file. The value is relevant only for PT_GC (General Category), PT_PC (Particular Category), PT_SC (Script), and the pseudo-property PT_CLIST, which is used to identify a list of case-equivalent characters when there are three or more. Repeats of these items use the OP_TYPESTAR etc. set of opcodes, followed by three code units: OP_PROP or OP_NOTPROP, and then the desired property type and value. Character classes ----------------- If there is only one character in a class, OP_CHAR or OP_CHARI is used for a positive class, and OP_NOT or OP_NOTI for a negative one (that is, for something like [^a]), except when caselessly matching a character that has more than two case-equivalent code points (which can happen only in UTF mode). In this case a Unicode property item is used, as described above in "Matching literal characters". A set of repeating opcodes (called OP_NOTSTAR etc.) are used for repeated, negated, single-character classes. The normal single-character opcodes (OP_STAR, etc.) are used for repeated positive single-character classes. When there is more than one character in a class, and all the code points are less than 256, OP_CLASS is used for a positive class, and OP_NCLASS for a negative one. In either case, the opcode is followed by a 32-byte (16-short, 8-word) bit map containing a 1 bit for every character that is acceptable. The bits are counted from the least significant end of each unit. In caseless mode, bits for both cases are set. The reason for having both OP_CLASS and OP_NCLASS is so that, in UTF-8 and 16-bit and 32-bit modes, subject characters with values greater than 255 can be handled correctly. For OP_CLASS they do not match, whereas for OP_NCLASS they do. For classes containing characters with values greater than 255 or that contain \p or \P, OP_XCLASS is used. It optionally uses a bit map if any acceptable code points are less than 256, followed by a list of pairs (for a range) and/or single characters and/or properties. In caseless mode, all equivalent characters are explicitly listed. OP_XCLASS is followed by a LINK_SIZE value containing the total length of the opcode and its data. This is followed by a code unit containing flag bits: XCL_NOT indicates that this is a negative class, and XCL_MAP indicates that a bit map is present. There follows the bit map, if XCL_MAP is set, and then a sequence of items coded as follows: XCL_END marks the end of the list XCL_SINGLE one character follows XCL_RANGE two characters follow XCL_PROP a Unicode property (type, value) follows XCL_NOTPROP a Unicode property (type, value) follows If a range starts with a code point less than 256 and ends with one greater than 255, it is split into two ranges, with characters less than 256 being indicated in the bit map, and the rest with XCL_RANGE. When XCL_NOT is set, the bit map, if present, contains bits for characters that are allowed (exactly as for OP_NCLASS), but the list of items that follow it specifies characters and properties that are not allowed. Back references --------------- OP_REF (caseful) or OP_REFI (caseless) is followed by a count containing the reference number when the reference is to a unique capturing group (either by number or by name). When named groups are used, there may be more than one group with the same name. In this case, a reference to such a group by name generates OP_DNREF or OP_DNREFI. These are followed by two counts: the index (not the byte offset) in the group name table of the first entry for the required name, followed by the number of groups with the same name. The matching code can then search for the first one that is set. Repeating character classes and back references ----------------------------------------------- Single-character classes are handled specially (see above). This section applies to other classes and also to back references. In both cases, the repeat information follows the base item. The matching code looks at the following opcode to see if it is one of these: OP_CRSTAR OP_CRMINSTAR OP_CRPOSSTAR OP_CRPLUS OP_CRMINPLUS OP_CRPOSPLUS OP_CRQUERY OP_CRMINQUERY OP_CRPOSQUERY OP_CRRANGE OP_CRMINRANGE OP_CRPOSRANGE All but the last three are single-code-unit items, with no data. The range opcodes are followed by the minimum and maximum repeat counts. Brackets and alternation ------------------------ A pair of non-capturing round brackets is wrapped round each expression at compile time, so alternation always happens in the context of brackets. [Note for North Americans: "bracket" to some English speakers, including myself, can be round, square, curly, or pointy. Hence this usage rather than "parentheses".] Non-capturing brackets use the opcode OP_BRA, capturing brackets use OP_CBRA. A bracket opcode is followed by a LINK_SIZE value which gives the offset to the next alternative OP_ALT or, if there aren't any branches, to the terminating opcode. Each OP_ALT is followed by a LINK_SIZE value giving the offset to the next one, or to the final opcode. For capturing brackets, the bracket number is a count that immediately follows the offset. There are several opcodes that mark the end of a subpattern group. OP_KET is used for subpatterns that do not repeat indefinitely, OP_KETRMIN and OP_KETRMAX are used for indefinite repetitions, minimally or maximally respectively, and OP_KETRPOS for possessive repetitions (see below for more details). All four are followed by a LINK_SIZE value giving (as a positive number) the offset back to the matching bracket opcode. If a subpattern is quantified such that it is permitted to match zero times, it is preceded by one of OP_BRAZERO, OP_BRAMINZERO, or OP_SKIPZERO. These are single-unit opcodes that tell the matcher that skipping the following subpattern entirely is a valid match. In the case of the first two, not skipping the pattern is also valid (greedy and non-greedy). The third is used when a pattern has the quantifier {0,0}. It cannot be entirely discarded, because it may be called as a subroutine from elsewhere in the pattern. A subpattern with an indefinite maximum repetition is replicated in the compiled data its minimum number of times (or once with OP_BRAZERO if the minimum is zero), with the final copy terminating with OP_KETRMIN or OP_KETRMAX as appropriate. A subpattern with a bounded maximum repetition is replicated in a nested fashion up to the maximum number of times, with OP_BRAZERO or OP_BRAMINZERO before each replication after the minimum, so that, for example, (abc){2,5} is compiled as (abc)(abc)((abc)((abc)(abc)?)?)?, except that each bracketed group has the same number. When a repeated subpattern has an unbounded upper limit, it is checked to see whether it could match an empty string. If this is the case, the opcode in the final replication is changed to OP_SBRA or OP_SCBRA. This tells the matcher that it needs to check for matching an empty string when it hits OP_KETRMIN or OP_KETRMAX, and if so, to break the loop. Possessive brackets ------------------- When a repeated group (capturing or non-capturing) is marked as possessive by the "+" notation, e.g. (abc)++, different opcodes are used. Their names all have POS on the end, e.g. OP_BRAPOS instead of OP_BRA and OP_SCBRAPOS instead of OP_SCBRA. The end of such a group is marked by OP_KETRPOS. If the minimum repetition is zero, the group is preceded by OP_BRAPOSZERO. Once-only (atomic) groups ------------------------- These are just like other subpatterns, but they start with the opcode OP_ONCE. The check for matching an empty string in an unbounded repeat is handled entirely at runtime, so there is just this one opcode for atomic groups. Assertions ---------- Forward assertions are also just like other subpatterns, but starting with one of the opcodes OP_ASSERT or OP_ASSERT_NOT. Backward assertions use the opcodes OP_ASSERTBACK and OP_ASSERTBACK_NOT, and the first opcode inside the assertion is OP_REVERSE, followed by a count of the number of characters to move back the pointer in the subject string. In ASCII or UTF-32 mode, the count is also the number of code units, but in UTF-8/16 mode each character may occupy more than one code unit. A separate count is present in each alternative of a lookbehind assertion, allowing them to have different (but fixed) lengths. Conditional subpatterns ----------------------- These are like other subpatterns, but they start with the opcode OP_COND, or OP_SCOND for one that might match an empty string in an unbounded repeat. If the condition is a back reference, this is stored at the start of the subpattern using the opcode OP_CREF followed by a count containing the reference number, provided that the reference is to a unique capturing group. If the reference was by name and there is more than one group with that name, OP_DNCREF is used instead. It is followed by two counts: the index in the group names table, and the number of groups with the same name. The allows the matcher to check if any group with the given name is set. If the condition is "in recursion" (coded as "(?(R)"), or "in recursion of group x" (coded as "(?(Rx)"), the group number is stored at the start of the subpattern using the opcode OP_RREF (with a value of RREF_ANY (0xffff) for "the whole pattern") or OP_DNRREF (with data as for OP_DNCREF). For a DEFINE condition, OP_FALSE is used (with no associated data). During compilation, however, a DEFINE condition is coded as OP_DEFINE so that, when the conditional group is complete, there can be a check to ensure that it contains only one top-level branch. Once this has happened, the opcode is changed to OP_FALSE, so the matcher never sees OP_DEFINE. There is a special PCRE2-specific condition of the form (VERSION[>]=x.y), which tests the PCRE2 version number. This compiles into one of the opcodes OP_TRUE or OP_FALSE. If a condition is not a back reference, recursion test, DEFINE, or VERSION, it must start with a parenthesized assertion, whose opcode normally immediately follows OP_COND or OP_SCOND. However, if automatic callouts are enabled, a callout is inserted immediately before the assertion. It is also possible to insert a manual callout at this point. Only assertion conditions may have callouts preceding the condition. A condition that is the negative assertion (?!) is optimized to OP_FAIL in all parts of the pattern, so this is another opcode that may appear as a condition. It is treated the same as OP_FALSE. Recursion --------- Recursion either matches the current pattern, or some subexpression. The opcode OP_RECURSE is followed by a LINK_SIZE value that is the offset to the starting bracket from the start of the whole pattern. OP_RECURSE is also used for "subroutine" calls, even though they are not strictly a recursion. Up till release 10.30 recursions were treated as atomic groups, making them incompatible with Perl (but PCRE had them well before Perl did). From 10.30, backtracking into recursions is supported. Repeated recursions used to be wrapped inside OP_ONCE brackets, which not only forced no backtracking, but also allowed repetition to be handled as for other bracketed groups. From 10.30 onwards, repeated recursions are duplicated for their minimum repetitions, and then wrapped in non-capturing brackets for the remainder. For example, (?1){3} is treated as (?1)(?1)(?1), and (?1){2,4} is treated as (?1)(?1)(?:(?1)){0,2}. Callouts -------- A callout may have either a numerical argument or a string argument. These use OP_CALLOUT or OP_CALLOUT_STR, respectively. In each case these are followed by two LINK_SIZE values giving the offset in the pattern string to the start of the following item, and another count giving the length of this item. These values make it possible for pcre2test to output useful tracing information using callouts. In the case of a numeric callout, after these two values there is a single code unit containing the callout number, in the range 0-255, with 255 being used for callouts that are automatically inserted as a result of the PCRE2_AUTO_CALLOUT option. Thus, this opcode item is of fixed length: [OP_CALLOUT] [PATTERN_OFFSET] [PATTERN_LENGTH] [NUMBER] For callouts with string arguments, OP_CALLOUT_STR has three more data items: a LINK_SIZE value giving the complete length of the entire opcode item, a LINK_SIZE item containing the offset within the pattern string to the start of the string argument, and the string itself, preceded by its starting delimiter and followed by a binary zero. When a callout function is called, a pointer to the actual string is passed, but the delimiter can be accessed as string[-1] if the application needs it. In the 8-bit library, the callout in /X(?C'abc')Y/ is compiled as the following bytes (decimal numbers represent binary values): [OP_CALLOUT_STR] [0] [10] [0] [1] [0] [14] [0] [5] ['] [a] [b] [c] [0] -------- ------- -------- ------- | | | | ------- LINK_SIZE items ------ Opcode table checking --------------------- The last opcode that is defined in pcre2_internal.h is OP_TABLE_LENGTH. This is not a real opcode, but is used to check at compile time that tables indexed by opcode are the correct length, in order to catch updating errors. Philip Hazel 20 July 2018 usr/share/doc/dracut/HACKING000064400000001620152534072230011477 0ustar00Right now, most of the testing is done using a qemu/kvm guest and generating the initramfs on another box but the support is all present to build for the "running" machine. For the former, you can boot the guest using qemu's -kernel and -initrd options. dracut exists and will build an image. It is command-line equivalent to most mkinitrd implementations and should be pretty straight-forward to use. To use, just run dracut with an output file name and, optionally, a kernel version (it defaults to using the current). The appropriate modules will be copied over and things should be good to go. If you'd like to customize the list of modules copied in, edit /etc/dracut.conf and set dracutmodules="foo bar baz" Note that dracut calls functional components in modules.d "modules" while kernel modules are called "drivers". Requirements: * udev * nfs module: nfs daemon and rpc helper * iscsi: iscsi usr/share/doc/guile/HACKING000064400000031057152537216550011341 0ustar00-*-text-*- Guile Hacking Guide Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2008, 2012, 2015 Free software Foundation, Inc. Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the copyright notice and permission notice are preserved, and that the distributor grants the recipient permission for further redistribution as permitted by this notice. Permission is granted to distribute modified versions of this document, or of portions of it, under the above conditions, provided also that they carry prominent notices stating who last changed them, and that any new or changed statements about the activities of the Free Software Foundation are approved by the Foundation. What to Hack ========================================================= You can hack whatever you want, thank GNU. However, to see what others have indicated as their interest (and avoid potential wasteful duplication of effort), see file TODO. Note that the version you find may be out of date; a CVS checkout is recommended: see below for details (see also the files ANON-CVS and SNAPSHOTS). It's also a good idea to join the guile-devel@gnu.org mailing list. See http://www.gnu.org/software/guile/mail/mail.html for more info. Hacking It Yourself ================================================== When Guile is obtained from Git, a few extra steps must be taken before the usual configure, make, make install. You will need to have up-to-date versions of the tools as listed below, correctly installed. Sometimes older or newer versions will work. (See below for versions to avoid.) Then you must run the autogen.sh script, as described below. The same procedure can be used to regenerate the files in released versions of Guile. In that case the headers of the original generated files (e.g., configure, Makefile.in, ltmain.sh) can be used to identify which tool versions may be required. Autoconf --- a system for automatically generating `configure' scripts from templates which list the non-portable features a program would like to use. Available in "ftp://ftp.gnu.org/pub/gnu/autoconf" Automake --- a system for automatically generating Makefiles that conform to the (rather Byzantine) GNU coding standards. The nice thing is that it takes care of hairy targets like 'make dist' and 'make distclean', and automatically generates Makefile dependencies. Automake is available in "ftp://ftp.gnu.org/pub/gnu/automake" libtool --- a system for managing the zillion hairy options needed on various systems to produce shared libraries. Available in "ftp://ftp.gnu.org/pub/gnu/libtool". Version 2.2 (or later) is recommended (for correct AIX support, and correct interaction with the Gnulib module for using libunistring). gettext --- a system for rigging a program so that it can output its messages in the local tongue. Guile presently only exports the gettext functionality to Scheme, it does not use it itself. flex --- a scanner generator. It's probably not essential to have the latest version; Flex 2.5.37 is known to work. One false move and you will be lost in a little maze of automatically generated files, all different. Here is the authoritative list of tool/version/platform tuples that have been known to cause problems, and a short description of the problem. - automake 1.4 adds extraneous rules to the top-level Makefile if you specify specific Makefiles to rebuild on the command line. - automake 1.4-p4 (debian "1:1.4-p4-1.1") all platforms automake "include" facility does not recognize filenames w/ "-". - libtool 1.4 uses acconfig.h, which is deprecated by newest autoconf (which constructs the equivalent through 3rd arg of AC_DEFINE forms). - autoreconf from autoconf prior to 2.59 will run gettextize, which will mess up the Guile tree. - libtool 1.5.26 does not know that it should remove the -R options that the Gnulib libunistring and havelib modules generate (because gcc doesn't actually support -R). - (add here.) Sample GDB Initialization File========================================= Here is a sample .gdbinit posted by Bill Schottstaedt (modified to use `set' instead of `call' in some places): define gp set gdb_print($arg0) print gdb_output end document gp Executes (object->string arg) end define ge call gdb_read($arg0) call gdb_eval(gdb_result) set gdb_print(gdb_result) print gdb_output end document ge Executes (print (eval (read arg))): ge "(+ 1 2)" => 3 end define gh call g_help(scm_str2symbol($arg0), 20) set gdb_print($1) print gdb_output end document gh Prints help string for arg: gh "enved-target" end Bill further writes: so in gdb if you see something useless like: #32 0x081ae8f4 in scm_primitive_load (filename=1112137128) at load.c:129 You can get the file name with gp: (gdb) gp 1112137128 $1 = 0x40853fac "\"/home/bil/test/share/guile/1.5.0/ice-9/session.scm\"" Contributing Your Changes ============================================ - If you have put together a change that meets the coding standards described below, we encourage you to submit it to Guile. Post your patch to guile-devel@gnu.org. - We prefer patches generated using 'git format-patch'. - Provide a description in the commit message, like so: 1-line description of change More extensive discussion of your change. Document why you are changing things. * filename (function name): file specific change comments. - For proper credit, also make sure you update the AUTHORS file (for new files for which you've assigned copyright to the FSF), or the THANKS file (for everything else). Coding standards ===================================================== - As for any part of Project GNU, changes to Guile should follow the GNU coding standards. The standards are available via anonymous FTP from prep.ai.mit.edu, as /pub/gnu/standards/standards.texi and make-stds.texi. - The Guile tree should compile without warnings under the following GCC switches, which are the default in the current configure script: -O2 -Wall -Wpointer-arith -Wmissing-prototypes To make sure of this, you can use the --enable-error-on-warning option to configure. This option will make GCC fail if it hits a warning. Note that the warnings generated vary from one version of GCC to the next, and from one architecture to the next (apparently). To provide a concrete common standard, Guile should compile without warnings from GCC 2.7.2.3 in a Red Hat 5.2 i386 Linux machine. Furthermore, each developer should pursue any additional warnings noted by on their compiler. This means that people using more stringent compilers will have more work to do, and assures that everyone won't switch to the most lenient compiler they can find. :) - If you add code which uses functions or other features that are not entirely portable, please make sure the rest of Guile will still function properly on systems where they are missing. This usually entails adding a test to configure.in, and then adding #ifdefs to your code to disable it if the system's features are missing. - The normal way of removing a function, macro or variable is to mark it as "deprecated", keep it for a while, and remove it in a later release. If a function or macro is marked as "deprecated" it indicates that people shouldn't use it in new programs, and should try to remove it in old. Make sure that an alternative exists unless it is our purpose to remove functionality. Don't deprecate definitions if it is unclear when they will be removed. (This is to ensure that a valid way of implementing some functionality always exists.) When deprecating a definition, always follow this procedure: 1. Mark the definition using #if (SCM_DEBUG_DEPRECATED == 0) ... #endif or, for Scheme code, wrap it using (begin-deprecated ...) 2. Make the deprecated code issue a warning when it is used, by using scm_c_issue_deprecation_warning (in C) or issue-deprecation-warning (in Scheme). 3. Write a comment at the definition explaining how a programmer can manage without the deprecated definition. 4. Add an entry that the definition has been deprecated in NEWS and explain what to do instead. 5. In file TODO, there is a list of releases with reminders about what to do at each release. Add a reminder about the removal of the deprecated defintion at the appropriate release. - Write commit messages for functions written in C using the functions' C names, and write entries for functions written in Scheme using the functions' Scheme names. For example, * foo.c: Moved scm_procedure_documentation from eval.c. is preferred over * foo.c: Moved procedure-documentation from eval.c. Changes like adding this line are special: SCM_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map); Since the change here is about the name itself --- we're adding a new alias for scm_map that guarantees the order in which we process list elements, but we're not changing scm_map at all --- it's appropriate to use the Scheme name in the commit message. - Make sure you have papers from people before integrating their changes or contributions. This is very frustrating, but very important to do right. From maintain.texi, "Information for Maintainers of GNU Software": When incorporating changes from other people, make sure to follow the correct procedures. Doing this ensures that the FSF has the legal right to distribute and defend GNU software. For the sake of registering the copyright on later versions ofthe software you need to keep track of each person who makes significant changes. A change of ten lines or so, or a few such changes, in a large program is not significant. *Before* incorporating significant changes, make sure that the person has signed copyright papers, and that the Free Software Foundation has received them. If you receive contributions you want to use from someone, let me know and I'll take care of the administrivia. Put the contributions aside until we have the necessary papers. Once you accept a contribution, be sure to keep the files AUTHORS and THANKS uptodate. - When you make substantial changes to a file, add the current year to the list of years in the copyright notice at the top of the file. - When you get bug reports or patches from people, be sure to list them in THANKS. - Do not introduce trailing whitespace (and feel free to clean it up opportunistically, that is, if doing so is part of some other change). The goal is to reduce (and over time, eliminate) spurious diffs. For Emacs users: (add-hook 'before-save-hook 'delete-trailing-whitespace) Naming conventions ================================================= We use certain naming conventions to structure the considerable number of global identifiers. All identifiers should be either all lower case or all upper case. Syllables are separated by underscores `_'. All non-static identifiers should start with scm_ or SCM_. Then might follow zero or more syllables giving the category of the identifier. The currently used category identifiers are t - type name c,C - something with a interface suited for C use. This is used to name functions that behave like Scheme primitives but have a more C friendly calling convention. i,I - internal to libguile. It is global, but not considered part of the libguile API. f - a SCM variable pointing to a Scheme function object. F - a bit mask for a flag. m - a macro transformer procedure n,N - a count of something s - a constant C string k - a SCM variable pointing to a keyword. sym - a SCM variable pointing to a symbol. var - a SCM variable pointing to a variable object. The follwing syllables also have a technical meaning: str - this denotes a zero terminated C string mem - a C string with an explicit count See also the file `devel/names.text'. Helpful hints ======================================================== - [From Mikael Djurfeldt] When working on the Guile internals, it is quite often practical to implement a scheme-level procedure which helps you examine the feature you're working on. Examples of such procedures are: pt-size, debug-hand and current-pstate. I've now put #ifdef GUILE_DEBUG around all such procedures, so that they are not compiled into the "normal" Guile library. Please do the same when you add new procedures/C functions for debugging purpose. You can define the GUILE_DEBUG flag by passing --enable-guile-debug to the configure script. Jim Blandy, and others usr/share/doc/shared-mime-info/HACKING000064400000005441152537614540013357 0ustar00Note: latest version of this file is at: http://cgit.freedesktop.org/xdg/shared-mime-info/tree/HACKING A few ground rules for people interested in adding new mime-types. * Mime-types used should be IANA registered mime-types when possible * When old mime-types become registered, the new definition should include an alias for the old mime-type * New entries or modifications should include a test case (see below) * Mime-types/file formats proprietary to one application should only be added to a private .xml file and be bundled with the application itself * Magic offset must be as small as possible. For example, the worst case scenario for ISO images is 32k inside the file. This is too big for a sniff buffer, especially on remote locations. Avoid those. * No commits should be done that break the test suite, or the test suite test in question should be amended, and reason for the changes clearly documented in the commit message Translations ------------ Translations should go through Transifex.net, and the freedesktop.org team: http://www.transifex.net/projects/p/shared-mime-info/ git --- Check it out using: git clone git://anongit.freedesktop.org/xdg/shared-mime-info or if you have a freedesktop account: git clone ssh://git.freedesktop.org/git/xdg/shared-mime-info Web interface is at: http://cgit.freedesktop.org/xdg/shared-mime-info/ Filing bugs ----------- Bugs can be filed at: https://bugs.freedesktop.org/enter_bug.cgi?product=shared-mime-info Bugs for new mime-types should include: - a patch generated against the current git master, with authorship information - one or more test files to be added to the test suite Test suite ---------- You need to have xdgmime checked out [1] and compiled at the same level as shared-mime-info. ../xdgmime/src/test-mime-data will be run against tests/list. The format of the file is: The expected failures is whether matching the file with the mime-type would fail when matched by file, data or name. "x" indicates expected failure, "o" indicates expected success. Trailing "o"s can be omitted. See the top of the tests/list file for syntax details. You can also temporarily print the results of test-mime-data by putting your test files in the staging-tests/ sub-directory. [1]: Repository details at: http://cgit.freedesktop.org/xdg/xdgmime/ Releasing --------- - Run "make update-translations" and "make check-translations" before release - Copy the file to ~hadess/public_html on gabe.freedesktop.org - Update http://www.freedesktop.org/wiki/Software/shared-mime-info Updating the spec on the website -------------------------------- - update http://cgit.freedesktop.org/xdg/xdg-specs/tree/web-export/specs.idx - go to /srv/specifications.freedesktop.org/www on gabe - run ../update.py