K7UWWCIPZOMECGOTQWGWDDE764B4GD5DETC5TO3NYDBKIWNZ2Y3QC
use std::{
cell::{Ref, RefCell, RefMut},
collections::{hash_map::Entry, HashMap},
fs::File,
io::{self, Read},
path::{Path, PathBuf},
};
use crate::span::Span;
/// Keeps track of all the source code being preprocessed. This not only includes files and text
/// provided by the user but also any source files included when processing `#include` directives.
#[derive(Default)]
pub(crate) struct SourceMap {
inner: RefCell<SourceMapInner>,
}
#[derive(Default)]
struct SourceMapInner {
buffer: Vec<u8>,
map: HashMap<PathBuf, Span>,
}
impl SourceMap {
/// Get the string representation of a region.
///
/// As the value returned by this method is of type [`Ref`], it must be dropped before doing
/// any write operation on the [`SourceMap`].
pub(crate) fn get_bytes(&self, span: Span) -> Ref<'_, [u8]> {
Ref::map(self.inner.borrow(), |inner| &inner.buffer[span.lo..span.hi])
}
/// Read a file, store its contents in the [`SourceMap`] and return the [`Span`] for the
/// contents of the file.
///
/// If the path of the file has already been seen by this method, the file is not read again.
pub(crate) fn read_file<P: AsRef<Path>>(&self, path: &P) -> io::Result<Span> {
let (mut map, mut buffer) = RefMut::map_split(self.inner.borrow_mut(), |inner| {
(&mut inner.map, &mut inner.buffer)
});
match map.entry(path.as_ref().to_owned()) {
Entry::Occupied(entry) => Ok(*entry.get()),
Entry::Vacant(entry) => {
let lo = buffer.len();
let hi = lo + File::open(path)?.read_to_end(&mut buffer)?;
let span = Span { lo, hi };
entry.insert(span);
Ok(span)
}
}
}
/// Store a sequence of bytes in the [`SourceMap`] and return the [`Span`] for it.
///
/// The returned [`Span`] is not associated to any file path.
pub(crate) fn store_bytes(&self, bytes: &[u8]) -> Span {
let buffer = &mut self.inner.borrow_mut().buffer;
let lo = buffer.len();
buffer.extend_from_slice(bytes);
let hi = buffer.len();
Span { lo, hi }
}
/// Find the file path to which a [`Span`] belongs. Return `None` if the [`Span`] does not
/// belong to any file.
pub(crate) fn find_file(&self, target: Span) -> Option<PathBuf> {
for (path, span) in &self.inner.borrow().map {
if span.lo <= target.lo && span.hi >= target.hi {
return Some(path.clone());
}
}
None
}
}
mod source_map;
pub(crate) use source_map::SourceMap;
/// A region of code. The position of a span is *not* guaranteed to be relative to the start of the
/// file that includes the region. The methods inside [`SourceMap`] can be used to extract the
/// string representation of this region.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct Span {
pub(crate) lo: usize,
pub(crate) hi: usize,
}
//! A preprocessing library for the C programming language.
//!
//! This library was written trying to follow the ISO/IEC 9899:2018 standard, also known as C17.
//! Because of this, the documentation contains references to specific senctions of this document
//! whose most recent free draft can be found
//! [here](https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
mod buffer;
mod lexer;
mod span;
use std::{path::Path, io};
use span::SourceMap;
pub fn preprocess(source: &[u8]) {
let map = SourceMap::default();
map.tokenize_bytes(source);
}
pub fn preprocess_file<P: AsRef<Path>>(path: &P) -> io::Result<()> {
let map = SourceMap::default();
map.tokenize_file(path)?;
Ok(())
}
use crate::span::Span;
/// A preprocessing token, as defined in the section 6.4 of C17.
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct Token {
pub(crate) kind: TokenKind,
pub(crate) span: Span,
}
/// The differen kinds of preprocessing tokens. The description for each kind can be found at the
/// section 6.4 of C17 using the identifier shown in the documentation of each variant of this
/// `enum`.
///
/// We include sequences of white-space characters and new-line characters as tokens even though
/// they are not represented as preprocessing tokens in C17. This is done because new-line
/// characters are important delimiters to parse preprocessing directives (An example of this can
/// be found in the syntax definition in 6.10) and the presence of white-space characters changes
/// the semantics of some preprocessing directives (This can be infered from section 6.10.3, as an
/// example, `#define FOO()` is a function-like macro and `#define FOO ()` is an object-like macro).
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub(crate) enum TokenKind {
// A `header-name`.
Header,
// An `identifier`.
Ident,
// A `pp-number`.
Number,
// A `character-constant`.
Char,
// A `string-literal`.
Str,
// A `punctuator`.
Punct,
// Any non-white-space character that cannot be one of the above.
Any,
// A sequence of white-space characters possibly including comments.
Space,
// A single new-line character.
Newline,
}
use crate::{buffer::TokenBuffer, lexer::TokenKind, span::Span};
use super::{Lexer, Reject, Token};
fn single_token(
bytes: &[u8],
f: impl Fn(Lexer<'_>) -> super::Result<'_, Token>,
) -> super::Result<'_, Token> {
f(Lexer {
rest: bytes,
offset: 0,
})
}
#[track_caller]
fn tokenize_one(bytes: &[u8], kind: TokenKind, f: impl Fn(Lexer<'_>) -> super::Result<'_, Token>) {
let (rest, token) = single_token(bytes, f).unwrap();
let expected_token = Token {
kind,
span: Span {
lo: 0,
hi: bytes.len(),
},
};
println!("Parsed token was: {:?}", token);
assert!(rest.is_empty(), "Remainder: {:?}", String::from_utf8_lossy(rest.rest));
assert_eq!(expected_token, token);
}
#[test]
fn ident_alphabetic() {
tokenize_one(b"hello", TokenKind::Ident, super::ident);
}
#[test]
#[should_panic]
fn ident_empty() {
tokenize_one(b"", TokenKind::Ident, super::ident);
}
#[test]
#[should_panic]
fn ident_starts_with_digit() {
tokenize_one(b"12345seven", TokenKind::Ident, super::ident);
}
#[test]
fn ident_alphanumeric() {
tokenize_one(b"e1m1", TokenKind::Ident, super::ident);
}
#[test]
fn ident_surrounded_by_underscore() {
tokenize_one(b"_foo_", TokenKind::Ident, super::ident);
}
#[test]
fn ident_snake_case() {
tokenize_one(b"sneaky_snake", TokenKind::Ident, super::ident);
}
#[test]
fn ident_camel_case() {
tokenize_one(b"CamellyCamel", TokenKind::Ident, super::ident);
}
#[test]
fn ident_mixed_case() {
tokenize_one(b"sneaky_Camel", TokenKind::Ident, super::ident);
}
#[test]
fn number_digits() {
tokenize_one(b"42", TokenKind::Number, super::number);
}
#[test]
fn number_begins_with_dot() {
tokenize_one(b".42", TokenKind::Number, super::number);
}
#[test]
fn number_ends_with_dot() {
tokenize_one(b"42.", TokenKind::Number, super::number);
}
#[test]
fn number_surrounded_by_dots() {
tokenize_one(b".42.", TokenKind::Number, super::number);
}
#[test]
fn number_with_exponent() {
tokenize_one(b"42e+", TokenKind::Number, super::number);
}
#[test]
fn number_with_ident() {
tokenize_one(b"42HELLO_10", TokenKind::Number, super::number);
}
#[test]
fn number_no_sign() {
tokenize_one(b".1e", TokenKind::Number, super::number);
}
#[test]
#[should_panic]
fn number_with_sign_no_exponent() {
tokenize_one(b"1+", TokenKind::Number, super::number);
}
#[test]
#[should_panic]
fn number_empty() {
tokenize_one(b"", TokenKind::Number, super::number);
}
#[test]
#[should_panic]
fn number_ident_nondigit() {
tokenize_one(b"e", TokenKind::Number, super::number);
}
//! All functions related to lexing.
//!
//! This code is heavily inspired by the
//! [`proc_macro2::parse`](https://github.com/dtolnay/proc-macro2/blob/a3fbb7de911db5964dcec00b009ec4a4d5868af5/src/parse.rs)
//! module.
mod token;
#[cfg(test)]
mod tests;
use std::path::Path;
pub(crate) use token::{Token, TokenKind};
use crate::{
buffer::TokenBuffer,
span::{SourceMap, Span},
};
impl SourceMap {
/// Read a file and tokenize it.
pub(crate) fn tokenize_file<P: AsRef<Path>>(&self, path: &P) -> std::io::Result<TokenBuffer> {
let span = self.read_file(path)?;
Ok(self.tokenize_region(span))
}
/// Read a sequence of bytes and tokenize it.
pub(crate) fn tokenize_bytes(&self, source: &[u8]) -> TokenBuffer {
let span = self.store_bytes(source);
self.tokenize_region(span)
}
/// Tokenize a region.
///
/// Panic if the region contains invalid tokens.
fn tokenize_region(&self, span: Span) -> TokenBuffer {
let rest = &*self.get_bytes(span);
let mut lexer = Lexer {
rest,
offset: span.lo,
};
let mut buffer = TokenBuffer::default();
while !lexer.is_empty() {
match lexer.next_token() {
Ok((rest, token)) => {
buffer.push(token);
lexer = rest;
}
Err(Reject) => {
let span = lexer.get_span(lexer.len());
let rest = &*self.get_bytes(span);
let rest_short = String::from_utf8_lossy(rest.get(..80).unwrap_or(rest));
if let Some(path) = self.find_file(span) {
panic!(
"Invalid token at {}:{} \"{}\"",
path.display(),
lexer.offset,
rest_short
);
} else {
panic!("Invalid token in input \"{}\"", rest_short);
}
}
}
}
buffer
}
}
type Result<'a, T> = std::result::Result<(Lexer<'a>, T), Reject>;
#[cfg_attr(test, derive(Debug))]
struct Reject;
macro_rules! must_match {
($($tokens:tt)*) => {
if !matches!($($tokens)*) {
return Err(Reject);
}
};
}
#[derive(Clone, Copy)]
struct Lexer<'a> {
/// The remaining region to be tokenized.
rest: &'a [u8],
/// The start of `rest`, relative to the start of the region being tokenized.
offset: usize,
}
impl<'a> Lexer<'a> {
fn next_token(self) -> Result<'a, Token> {
let (rest, token) = if let Ok((rest, ident)) = ident(self) {
(rest, ident)
} else if let Ok((rest, number)) = number(self) {
(rest, number)
} else {
return Err(Reject);
};
Ok((rest, token))
}
/// Move this lexer to the desired index.
///
/// Panic if the index is out of bounds.
fn advance(self, index: usize) -> Self {
let (head, rest) = self.rest.split_at(index);
Self {
offset: self.offset + head.len(),
rest,
}
}
/// Return a new span that starts at the current offset and has `len` length.
fn get_span(&self, len: usize) -> Span {
Span {
lo: self.offset,
hi: self.offset + len,
}
}
/// Get the length of the remaining text region.
fn len(&self) -> usize {
self.rest.len()
}
/// Return an iterator over the remaining bytes.
fn bytes(&self) -> impl Iterator<Item = u8> + '_ {
self.rest.iter().copied()
}
/// Return an iterator over the remaining bytes and their positions.
fn byte_indices(&self) -> impl Iterator<Item = (usize, u8)> + '_ {
self.bytes().enumerate()
}
/// Check if the remaining text starts with `tag` and consume it if it does.
fn parse_bytes(self, tag: &[u8]) -> std::result::Result<Self, Reject> {
if self.rest.starts_with(tag) {
Ok(self.advance(tag.len()))
} else {
Err(Reject)
}
}
/// Check if the next remaining byte matches `pattern` and consume it if it does.
fn parse_byte(self, pattern: impl BytePattern) -> std::result::Result<Self, Reject> {
if self
.rest
.first()
.map(|byte| pattern.matches(*byte))
.unwrap_or_default()
{
Ok(self.advance(1))
} else {
Err(Reject)
}
}
fn is_empty(&self) -> bool {
self.rest.is_empty()
}
}
trait BytePattern {
fn matches(self, byte: u8) -> bool;
}
impl BytePattern for u8 {
fn matches(self, byte: u8) -> bool {
byte == self
}
}
impl<F: Fn(u8) -> bool> BytePattern for F {
fn matches(self, byte: u8) -> bool {
(self)(byte)
}
}
/// Produce a `header-name` as defined in section 6.4.7 of C17.
fn header(input: Lexer<'_>) -> Result<'_, Token> {
todo!()
}
/// Produce a `"q-char-sequence"` as defined in section 6.4.7 of C17.
fn q_header(input: Lexer<'_>) -> Result<'_, Token> {
// It has to start with a `"`.
let rest = input.parse_byte(b'"')?;
let mut bytes = rest.bytes().enumerate().peekable();
// Now we try to parse a `q-char-sequence`.
while let Some((i, byte)) = bytes.next() {
match byte {
// new-line characters are not valid `q-char`s
// FIXME: what about `\r`?
b'\n' => {}
// if we find `’`, `\` , `/`, `//` , or `/*`, the behavior is undefined. We will
// reject.
b'\'' | b'\\' => {}
b'/' if matches!(bytes.peek(), Some(&(_, b'/' | b'*'))) => {}
// if we find `"` then we are done
b'"' => {
let len = i + 2;
return Ok((
input.advance(len),
Token {
kind: TokenKind::Header,
span: input.get_span(len),
},
));
}
// any other character is a valid `q-char`
_ => continue,
}
break;
}
return Err(Reject);
}
/// Produce an `identifier` as defined in section 6.4.2 of C17.
fn ident(input: Lexer<'_>) -> Result<'_, Token> {
let mut chars = input.byte_indices();
// The first char of an `identifier` must be an `identifier-nondigit`.
must_match!(chars.next(), Some((_, c)) if is_ident_nondigit(c));
// This is the length of the `identifier`.
let mut len = input.len();
for (i, ch) in chars {
// A valid `identifier` can be followed by either an `identifier-nondigit` or a `digit`.
// Otherwise, this character does not belong to the `identifier` and its position is the
// same as the length of the `identifier`.
if !(is_ident_nondigit(ch) || ch.is_ascii_digit()) {
len = i;
break;
}
}
Ok((
input.advance(len),
Token {
kind: TokenKind::Ident,
span: input.get_span(len),
},
))
}
/// Check if `byte` is an `identifier-nondigit` as defined in section 6.4.2 of C17.
fn is_ident_nondigit(byte: u8) -> bool {
byte == b'_' || byte.is_ascii_alphabetic()
}
/// Produce a `pp-number` as defined in section 6.4.8 of C17.
fn number(input: Lexer<'_>) -> Result<'_, Token> {
// A `pp-number` optionally starts with `.`
let (rest, prefix_len) = input
.parse_byte(b'.')
.map(|rest| (rest, 1))
.unwrap_or((input, 0));
let mut bytes = rest.byte_indices().peekable();
// The next character must be a `digit`.
must_match!(bytes.next(), Some((_, c)) if c.is_ascii_digit());
// This is the length of the `pp-number`.
let mut len = input.len();
while let Some((i, byte)) = bytes.next() {
// A valid `pp-number` can be followed by a `.`, a `digit`, an `identifier-nondigit`, or it
// can also be followed by `e`, `E`, `p` or `P` immediately followed by a `sign`.
match byte {
// We do exponents first because the exponents are `identifier-nondigit`s.
b'e' | b'E' | b'p' | b'P' if matches!(bytes.peek(), Some((_, b'+' | b'-'))) => {
bytes.next().unwrap();
continue;
}
byte if byte == b'.' || byte.is_ascii_digit() || is_ident_nondigit(byte) => {
continue;
}
_ => {}
}
// Otherwise, this character does not belong to the `number` and its position is the same
// as the length of the `number`.
len = i + prefix_len;
break;
}
Ok((
input.advance(len),
Token {
kind: TokenKind::Number,
span: input.get_span(len),
},
))
}
use std::{borrow::Borrow, ops::Deref};
use crate::lexer::Token;
/// A buffer of [`Token`]s.
#[derive(Default)]
pub(crate) struct TokenBuffer {
rest: Vec<Token>,
}
impl TokenBuffer {
/// Push a [`Token`] into the buffer.
pub(crate) fn push(&mut self, token: Token) {
self.rest.push(token)
}
}
impl Deref for TokenBuffer {
type Target = TokenSlice;
fn deref(&self) -> &Self::Target {
let ptr = self.rest.as_slice() as *const [Token] as *const TokenSlice;
// SAFETY: This pointer is valid because `TokenSlice` and `Token` have the same layout.
unsafe { &*ptr }
}
}
impl Borrow<TokenSlice> for TokenBuffer {
fn borrow(&self) -> &TokenSlice {
self
}
}
/// A slice of [`Token`]s.
#[repr(transparent)]
pub(crate) struct TokenSlice {
rest: [Token],
}
impl ToOwned for TokenSlice {
type Owned = TokenBuffer;
fn to_owned(&self) -> Self::Owned {
TokenBuffer {
rest: self.rest.to_owned(),
}
}
}
MIT License
Copyright (c) 2023 Christian Poveda Ruiz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "beheader"
version = "0.1.0"