mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Lexer: Migrated ispunct to Lexer::isPunctuation
This commit is contained in:
parent
3cbb2bb20f
commit
39fb45447b
6 changed files with 11 additions and 40 deletions
|
@ -31,7 +31,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <Nibbler.h>
|
#include <Nibbler.h>
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <Variant.h>
|
#include <Variant.h>
|
||||||
|
|
|
@ -299,8 +299,14 @@ bool Lexer::isBoundary (int left, int right)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Lexer::isPunctuation (int c)
|
bool Lexer::isPunctuation (int c)
|
||||||
{
|
{
|
||||||
return c != '@' &&
|
return isprint (c) &&
|
||||||
ispunct (c);
|
c != ' ' &&
|
||||||
|
c != '@' &&
|
||||||
|
c != '#' &&
|
||||||
|
c != '$' &&
|
||||||
|
c != '_' &&
|
||||||
|
! isDigit (c) &&
|
||||||
|
! isAlpha (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <Lexer.h>
|
#include <Lexer.h>
|
||||||
|
@ -1037,7 +1036,7 @@ bool Nibbler::getWord (std::string& result)
|
||||||
if (i < _length)
|
if (i < _length)
|
||||||
{
|
{
|
||||||
while (!Lexer::isDigit (_input[i]) &&
|
while (!Lexer::isDigit (_input[i]) &&
|
||||||
!isPunctuation (_input[i]) &&
|
!Lexer::isPunctuation (_input[i]) &&
|
||||||
!Lexer::isWhitespace (_input[i]))
|
!Lexer::isWhitespace (_input[i]))
|
||||||
{
|
{
|
||||||
++i;
|
++i;
|
||||||
|
@ -1228,21 +1227,6 @@ bool Nibbler::depleted ()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Override of ispunct, that considers #, $, _ and @ not to be punctuation.
|
|
||||||
//
|
|
||||||
// ispunct: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
|
|
||||||
// Punctuation: ! " % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ ` { | } ~
|
|
||||||
// delta: # $ @
|
|
||||||
//
|
|
||||||
bool Nibbler::isPunctuation (char c)
|
|
||||||
{
|
|
||||||
if (c == '@' || c == '#' || c == '$' || c == '_')
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return ispunct (c);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Nibbler::dump ()
|
std::string Nibbler::dump ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,7 +110,6 @@ public:
|
||||||
|
|
||||||
bool depleted ();
|
bool depleted ();
|
||||||
|
|
||||||
static bool isPunctuation (char);
|
|
||||||
std::string dump ();
|
std::string dump ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
16
src/text.cpp
16
src/text.cpp
|
@ -32,7 +32,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Lexer.h>
|
#include <Lexer.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -479,21 +478,6 @@ bool nontrivial (const std::string& input)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Override of ispunct, that considers #, $ and @ not to be punctuation.
|
|
||||||
//
|
|
||||||
// ispunct: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
|
|
||||||
// Punctuation: ! " % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ ` { | } ~
|
|
||||||
// delta: # $ @
|
|
||||||
//
|
|
||||||
bool isPunctuation (char c)
|
|
||||||
{
|
|
||||||
if (c == '@' || c == '#' || c == '$')
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return ispunct (c);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool compare (
|
bool compare (
|
||||||
const std::string& left,
|
const std::string& left,
|
||||||
|
|
|
@ -50,7 +50,6 @@ const std::string str_replace (std::string&, const std::string&, const std::stri
|
||||||
const std::string str_replace (const std::string&, const std::string&, const std::string&);
|
const std::string str_replace (const std::string&, const std::string&, const std::string&);
|
||||||
const char* optionalBlankLine ();
|
const char* optionalBlankLine ();
|
||||||
bool nontrivial (const std::string&);
|
bool nontrivial (const std::string&);
|
||||||
bool isPunctuation (char);
|
|
||||||
bool compare (const std::string&, const std::string&, bool sensitive = true);
|
bool compare (const std::string&, const std::string&, bool sensitive = true);
|
||||||
bool closeEnough (const std::string&, const std::string&, unsigned int minLength = 0);
|
bool closeEnough (const std::string&, const std::string&, unsigned int minLength = 0);
|
||||||
std::string::size_type find (const std::string&, const std::string&, bool sensitive = true);
|
std::string::size_type find (const std::string&, const std::string&, bool sensitive = true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue