Skip to content

Commit

Permalink
update workflows and stability. (#6)
Browse files Browse the repository at this point in the history
* fix workflows.

* Specify anonymous namespace explicitly.
  • Loading branch information
dojyorin authored Nov 9, 2023
1 parent c7f0531 commit ce33558
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 23 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "test",
"on": {
"push": {
"branches": [
"dev"
"branches-ignore": [
"master"
],
"paths-ignore": [
".git*",
Expand All @@ -13,8 +13,7 @@
},
"pull_request": {
"branches": [
"master",
"dev"
"master"
],
"paths-ignore": [
".git*",
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
name: test
on:
push:
branches:
- dev
branches-ignore:
- master
paths-ignore:
- .git*
- '**.md'
- '*.properties'
pull_request:
branches:
- master
- dev
paths-ignore:
- .git*
- '**.md'
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/to_yaml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -eu

cd ${0%/*}

for _v in $(find ./ -maxdepth 1 -type f -name '*.json'); do
yq -I 4 -o y ${_v} | head -c -1 > ${_v%.*}.yaml
done; unset _v
6 changes: 0 additions & 6 deletions .github/workflows_json/to_yaml.sh

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# **Arduino Percent**
![actions:test](https://github.com/dojyorin/arduino_percent/actions/workflows/test.yaml/badge.svg)
![actions:release](https://github.com/dojyorin/arduino_percent/actions/workflows/release.yaml/badge.svg)
![shields:license](https://img.shields.io/github/license/dojyorin/arduino_percent)
![shields:release](https://img.shields.io/github/release/dojyorin/arduino_percent)

Convert between URL-unsafe string and percent encoded string.
Easily convert to percent encoded string.
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=percent_encode
author=dojyorin
version=2.0.1
version=2.0.2
architectures=*
includes=arduino_percent.hpp
sentence=Convert between URL-unsafe string and percent encoded string.
Expand Down
18 changes: 9 additions & 9 deletions src/percent.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include "./arduino_percent.hpp"

namespace{
constexpr char symbols[] = "0123456789ABCDEF";
constexpr char unreserved[] = "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
constexpr char CODE[] = "0123456789ABCDEF";
constexpr char UNRESERVED[] = "-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

uint8_t indexOf(char search){
if('`' < search){
search -= ' ';
}

for(uint8_t i = 0; i < 16; i++){
if(symbols[i] == search){
if(::CODE[i] == search){
return i;
}
}
Expand All @@ -19,7 +19,7 @@ namespace{
}

bool isUnreserved(char search){
for(const auto &v: unreserved){
for(const auto &v: ::UNRESERVED){
if(v == search){
return true;
}
Expand All @@ -31,13 +31,13 @@ namespace{

void percent::encode(const char* input, char* output){
while(*input != '\0'){
if(isUnreserved(*input)){
if(::isUnreserved(*input)){
*output++ = *input;
}
else{
*output++ = '%';
*output++ = symbols[*input >> 0x04];
*output++ = symbols[*input & 0x0F];
*output++ = ::CODE[*input >> 0x04];
*output++ = ::CODE[*input & 0x0F];
}

input++;
Expand All @@ -50,7 +50,7 @@ size_t percent::encodeLength(const char* input){
size_t length = 0;

while(*input != '\0'){
length += isUnreserved(*input++) ? 1 : 3;
length += ::isUnreserved(*input++) ? 1 : 3;
}

return length + 1;
Expand All @@ -59,7 +59,7 @@ size_t percent::encodeLength(const char* input){
void percent::decode(const char* input, char* output){
while(*input != '\0'){
if(*input == '%'){
*output++ = (indexOf(*++input) << 4) + indexOf(*++input);
*output++ = (::indexOf(*++input) << 4) + ::indexOf(*++input);
}
else{
*output++ = *input;
Expand Down

0 comments on commit ce33558

Please sign in to comment.