Skip to content

Commit

Permalink
Fork from huonw.
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed Jun 16, 2018
1 parent 1acd7f1 commit 76e2743
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 90 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/target
/unicode_names_macros/target
/unicode_names2_macros/target
/Cargo.lock
/unicode_names_macros/Cargo.lock
/unicode_names2_macros/Cargo.lock
/data/UnicodeData.txt
/generator/target
/generator/target
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ script:
travis-cargo test &&
travis-cargo bench &&
travis-cargo doc &&
( cd unicode_names_macros && travis-cargo build && travis-cargo test; ) &&
( cd unicode_names2_macros && travis-cargo build && travis-cargo test; ) &&
( cd generator && travis-cargo build && travis-cargo test; )
after_success:
- travis-cargo doc-upload && travis-cargo coveralls
Expand Down
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]

name = "unicode_names"
name = "unicode_names2"
version = "0.1.7"
authors = ["Huon Wilson <dbau.pp@gmail.com>",
"Kang Seonghoon <public+rust@mearie.org>"]
"Kang Seonghoon <public+rust@mearie.org>",
"Valentin Lorentz <progval+git@progval.net>",]

homepage = "https://github.com/huonw/unicode_names"
repository = "https://github.com/huonw/unicode_names"
homepage = "https://github.com/ProgVal/unicode_names2"
repository = "https://github.com/ProgVal/unicode_names2"
documentation = "http://huonw.github.io/unicode_names/unicode_names/"
license = "MIT/Apache-2.0"
keywords = ["text", "unicode"]
Expand All @@ -30,8 +31,8 @@ default = []
unstable = []
no_std = []

[dev-dependencies.unicode_names_macros]
path = "unicode_names_macros"
[dev-dependencies.unicode_names2_macros]
path = "unicode_names2_macros"
version = "*"

[dev-dependencies]
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# unicode_names
# unicode_names2

[![Build Status](https://travis-ci.org/huonw/unicode_names.png)](https://travis-ci.org/huonw/unicode_names) [![Coverage Status](https://coveralls.io/repos/huonw/unicode_names/badge.svg)](https://coveralls.io/r/huonw/unicode_names)
[![Build Status](https://travis-ci.org/huonw/unicode_names2.png)](https://travis-ci.org/huonw/unicode_names2) [![Coverage Status](https://coveralls.io/repos/huonw/unicode_names2/badge.svg)](https://coveralls.io/r/huonw/unicode_names2)

Time and memory efficiently mapping characters to and from their
Unicode 7.0 names, at runtime and compile-time.

```rust
extern crate unicode_names;
extern crate unicode_names2;

fn main() {
println!("☃ is called {}", unicode_names::name('☃')); // SNOWMAN
println!("{} is happy", unicode_names::character("white smiling face")); //
println!("☃ is called {}", unicode_names2::name('☃')); // SNOWMAN
println!("{} is happy", unicode_names2::character("white smiling face")); //
// (NB. case insensitivity)
}
```
Expand Down
20 changes: 0 additions & 20 deletions deploy-docs.sh

This file was deleted.

4 changes: 2 additions & 2 deletions examples/count.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate unicode_names;
extern crate unicode_names2;
use std::char;

// Count how many code points have names in the standard.
Expand All @@ -14,7 +14,7 @@ use std::char;
fn main() {
let number = (0u32..0x10FFFF)
.filter(|x| {
char::from_u32(*x).map_or(false, |c| unicode_names::name(c).is_some())
char::from_u32(*x).map_or(false, |c| unicode_names2::name(c).is_some())
})
.count();

Expand Down
2 changes: 1 addition & 1 deletion generator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]

name = "unicode_names_generator"
name = "unicode_names2_generator"
version = "0.0.1"
authors = ["Huon Wilson <dbau.pp@gmail.com>"]

Expand Down
40 changes: 20 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
//! name)`).
//!
//! ```rust
//! extern crate unicode_names;
//! extern crate unicode_names2;
//!
//! fn main() {
//! println!("☃ is called {:?}", unicode_names::name('☃')); // SNOWMAN
//! println!("{:?} is happy", unicode_names::character("white smiling face")); // ☺
//! println!("☃ is called {:?}", unicode_names2::name('☃')); // SNOWMAN
//! println!("{:?} is happy", unicode_names2::character("white smiling face")); // ☺
//! // (NB. case insensitivity)
//! }
//! ```
//!
//! [**Source**](https://github.com/huonw/unicode_names).
//! [**Source**](https://github.com/huonw/unicode_names2).
//!
//! # Macros
//!
//! The associated `unicode_names_macros` crate provides two macros
//! The associated `unicode_names2_macros` crate provides two macros
//! for converting at compile-time, giving named literals similar to
//! Python's `"\N{...}"`.
//!
Expand All @@ -35,8 +35,8 @@
//!
//! ```rust
//! #![feature(plugin)]
//! #![plugin(unicode_names_macros)]
//! # extern crate unicode_names; // pointless, just avoid extern crate being inserted
//! #![plugin(unicode_names2_macros)]
//! # extern crate unicode_names2; // pointless, just avoid extern crate being inserted
//!
//! fn main() {
//! let x: char = named_char!("snowman");
Expand All @@ -54,8 +54,8 @@
//!
//! ```toml
//! [dependencies]
//! unicode_names = "0.1"
//! unicode_names_macros = "0.1"
//! unicode_names2 = "0.1"
//! unicode_names2_macros = "0.1"
//! ```
#![cfg_attr(feature = "no_std", feature(no_std, core))]
Expand Down Expand Up @@ -219,17 +219,17 @@ impl fmt::Display for Name {
///
/// ```rust
/// # #![allow(unstable)]
/// assert_eq!(unicode_names::name('a').map(|n| n.to_string()),
/// assert_eq!(unicode_names2::name('a').map(|n| n.to_string()),
/// Some("LATIN SMALL LETTER A".to_string()));
/// assert_eq!(unicode_names::name('\u{2605}').map(|n| n.to_string()),
/// assert_eq!(unicode_names2::name('\u{2605}').map(|n| n.to_string()),
/// Some("BLACK STAR".to_string()));
/// assert_eq!(unicode_names::name('☃').map(|n| n.to_string()),
/// assert_eq!(unicode_names2::name('☃').map(|n| n.to_string()),
/// Some("SNOWMAN".to_string()));
///
/// // control code
/// assert!(unicode_names::name('\x00').is_none());
/// assert!(unicode_names2::name('\x00').is_none());
/// // unassigned
/// assert!(unicode_names::name('\u{10FFFF}').is_none());
/// assert!(unicode_names2::name('\u{10FFFF}').is_none());
/// ```
pub fn name(c: char) -> Option<Name> {
let cc = c as usize;
Expand Down Expand Up @@ -302,13 +302,13 @@ fn split(hash: u64) -> (u32, u32, u32) {
/// # Example
///
/// ```rust
/// assert_eq!(unicode_names::character("LATIN SMALL LETTER A"), Some('a'));
/// assert_eq!(unicode_names::character("latin SMALL letter A"), Some('a'));
/// assert_eq!(unicode_names::character("latin small letter a"), Some('a'));
/// assert_eq!(unicode_names::character("BLACK STAR"), Some('★'));
/// assert_eq!(unicode_names::character("SNOWMAN"), Some('☃'));
/// assert_eq!(unicode_names2::character("LATIN SMALL LETTER A"), Some('a'));
/// assert_eq!(unicode_names2::character("latin SMALL letter A"), Some('a'));
/// assert_eq!(unicode_names2::character("latin small letter a"), Some('a'));
/// assert_eq!(unicode_names2::character("BLACK STAR"), Some('★'));
/// assert_eq!(unicode_names2::character("SNOWMAN"), Some('☃'));
///
/// assert_eq!(unicode_names::character("nonsense"), None);
/// assert_eq!(unicode_names2::character("nonsense"), None);
/// ```
pub fn character(name: &str) -> Option<char> {
// + 1 so that we properly handle the case when `name` has a
Expand Down
28 changes: 28 additions & 0 deletions unicode_names2_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]

name = "unicode_names2_macros"
version = "0.1.5"
authors = ["Huon Wilson <dbau.pp@gmail.com>",
"Valentin Lorentz <progval+git@progval.net>"]

homepage = "https://github.com/ProgVal/unicode_names2"
repository = "https://github.com/ProgVal/unicode_names2"
documentation = "http://huonw.github.io/unicode_names/unicode_names/"
license = "MIT/Apache-2.0"
keywords = ["text", "unicode", "plugin"]
description = "Support macros for `unicode_names2`."

[features]
unstable = []

[dependencies]
regex = "0.1.8"
regex_macros = "0.1.2"

[dependencies.unicode_names2]
path = ".."
version = "0.1"

[lib]
name = "unicode_names2_macros"
plugin = true
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern crate rustc;

extern crate regex;

extern crate unicode_names;
extern crate unicode_names2;

use syntax::ast;
use syntax::codemap;
Expand All @@ -30,7 +30,7 @@ fn named_char(cx: &mut ExtCtxt, sp: codemap::Span,
tts: &[ast::TokenTree]) -> Box<MacResult+'static> {
match base::get_single_str_from_tts(cx, sp, tts, "named_char") {
None => {}
Some(name) => match unicode_names::character(&name) {
Some(name) => match unicode_names2::character(&name) {
None => cx.span_err(sp, &format!("`{}` does not name a character", name)),

// everything worked!
Expand All @@ -55,7 +55,7 @@ fn named(cx: &mut ExtCtxt, sp: codemap::Span, tts: &[ast::TokenTree]) -> Box<Mac
cx.span_err(sp, &format!("unclosed escape in `named!`: {}", full));
} else {
let name = c.at(1).unwrap();
match unicode_names::character(name) {
match unicode_names2::character(name) {
Some(c) => return c.to_string(),
None => {
cx.span_err(sp, &format!("`{}` does not name a character", name));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(plugin)]
#![plugin(unicode_names_macros)]
#![plugin(unicode_names2_macros)]

#[test]
fn named_char() {
Expand Down
27 changes: 0 additions & 27 deletions unicode_names_macros/Cargo.toml

This file was deleted.

0 comments on commit 76e2743

Please sign in to comment.