mirror of
https://github.com/neovim/neovim.git
synced 2024-12-26 14:11:15 -07:00
Merge pull request #1479 from Pyrohh/fix_comments_and_use_stdbool
{farsi.c,arabic.c}: Fix comments and use stdbool
This commit is contained in:
commit
0fcb867981
@ -96,7 +96,6 @@
|
||||
// i -> initial
|
||||
// m -> medial
|
||||
// f -> final
|
||||
//
|
||||
#define a_s_FATHATAN 0xfe70
|
||||
#define a_m_TATWEEL_FATHATAN 0xfe71
|
||||
#define a_s_DAMMATAN 0xfe72
|
||||
@ -246,7 +245,8 @@
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "arabic.c.generated.h"
|
||||
#endif
|
||||
// Returns True if c is an ISO-8859-6 shaped ARABIC letter (user entered).
|
||||
|
||||
// Returns true if c is an ISO-8859-6 shaped ARABIC letter (user entered).
|
||||
static bool A_is_a(int cur_c)
|
||||
{
|
||||
switch (cur_c) {
|
||||
@ -293,7 +293,7 @@ static bool A_is_a(int cur_c)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns True if c is an Isolated Form-B ARABIC letter
|
||||
// Returns true if c is an Isolated Form-B ARABIC letter
|
||||
static bool A_is_s(int cur_c)
|
||||
{
|
||||
switch (cur_c) {
|
||||
@ -339,7 +339,7 @@ static bool A_is_s(int cur_c)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns True if c is a Final shape of an ARABIC letter
|
||||
// Returns true if c is a Final shape of an ARABIC letter
|
||||
static bool A_is_f(int cur_c)
|
||||
{
|
||||
switch (cur_c) {
|
||||
@ -1259,12 +1259,11 @@ static int chg_c_f2m(int cur_c)
|
||||
tempc = a_m_YEH;
|
||||
break;
|
||||
|
||||
/* NOTE: these encodings are multi-positional, no ?
|
||||
case a_f_LAM_ALEF_MADDA_ABOVE:
|
||||
case a_f_LAM_ALEF_HAMZA_ABOVE:
|
||||
case a_f_LAM_ALEF_HAMZA_BELOW:
|
||||
case a_f_LAM_ALEF:
|
||||
*/
|
||||
// NOTE: these encodings are multi-positional, no ?
|
||||
// case a_f_LAM_ALEF_MADDA_ABOVE:
|
||||
// case a_f_LAM_ALEF_HAMZA_ABOVE:
|
||||
// case a_f_LAM_ALEF_HAMZA_BELOW:
|
||||
// case a_f_LAM_ALEF:
|
||||
default:
|
||||
tempc = 0;
|
||||
}
|
||||
@ -1272,9 +1271,7 @@ static int chg_c_f2m(int cur_c)
|
||||
return tempc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Change shape - from Combination (2 char) to an Isolated
|
||||
*/
|
||||
// Change shape - from Combination (2 char) to an Isolated.
|
||||
static int chg_c_laa2i(int hid_c)
|
||||
{
|
||||
int tempc;
|
||||
@ -1303,9 +1300,7 @@ static int chg_c_laa2i(int hid_c)
|
||||
return tempc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Change shape - from Combination-Isolated to Final
|
||||
*/
|
||||
// Change shape - from Combination-Isolated to Final.
|
||||
static int chg_c_laa2f(int hid_c)
|
||||
{
|
||||
int tempc;
|
||||
@ -1334,9 +1329,7 @@ static int chg_c_laa2f(int hid_c)
|
||||
return tempc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do "half-shaping" on character "c". Return zero if no shaping.
|
||||
*/
|
||||
// Do "half-shaping" on character "c". Return zero if no shaping.
|
||||
static int half_shape(int c)
|
||||
{
|
||||
if (A_is_a(c)) {
|
||||
@ -1349,27 +1342,25 @@ static int half_shape(int c)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do Arabic shaping on character "c". Returns the shaped character.
|
||||
* out: "ccp" points to the first byte of the character to be shaped.
|
||||
* in/out: "c1p" points to the first composing char for "c".
|
||||
* in: "prev_c" is the previous character (not shaped)
|
||||
* in: "prev_c1" is the first composing char for the previous char
|
||||
* (not shaped)
|
||||
* in: "next_c" is the next character (not shaped).
|
||||
*/
|
||||
// Do Arabic shaping on character "c". Returns the shaped character.
|
||||
// out: "ccp" points to the first byte of the character to be shaped.
|
||||
// in/out: "c1p" points to the first composing char for "c".
|
||||
// in: "prev_c" is the previous character (not shaped)
|
||||
// in: "prev_c1" is the first composing char for the previous char
|
||||
// (not shaped)
|
||||
// in: "next_c" is the next character (not shaped).
|
||||
int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1,
|
||||
int next_c)
|
||||
{
|
||||
/* Deal only with Arabic character, pass back all others */
|
||||
// Deal only with Arabic character, pass back all others
|
||||
if (!A_is_ok(c)) {
|
||||
return c;
|
||||
}
|
||||
|
||||
/* half-shape current and previous character */
|
||||
// half-shape current and previous character
|
||||
int shape_c = half_shape(prev_c);
|
||||
|
||||
/* Save away current character */
|
||||
// Save away current character
|
||||
int curr_c = c;
|
||||
|
||||
int curr_laa = A_firstc_laa(c, *c1p);
|
||||
@ -1383,7 +1374,7 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1,
|
||||
curr_c = chg_c_laa2i(curr_laa);
|
||||
}
|
||||
|
||||
/* Remove the composing character */
|
||||
// Remove the composing character
|
||||
*c1p = 0;
|
||||
} else if (!A_is_valid(prev_c) && A_is_valid(next_c)) {
|
||||
curr_c = chg_c_a2i(c);
|
||||
@ -1397,8 +1388,8 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1,
|
||||
curr_c = chg_c_a2s(c);
|
||||
}
|
||||
|
||||
/* Sanity check -- curr_c should, in the future, never be 0.
|
||||
* We should, in the future, insert a fatal error here. */
|
||||
// Sanity check -- curr_c should, in the future, never be 0.
|
||||
// We should, in the future, insert a fatal error here.
|
||||
if (curr_c == NUL) {
|
||||
curr_c = c;
|
||||
}
|
||||
@ -1406,12 +1397,12 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1,
|
||||
if ((curr_c != c) && (ccp != NULL)) {
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
|
||||
/* Update the first byte of the character. */
|
||||
// Update the first byte of the character
|
||||
(*mb_char2bytes)(curr_c, buf);
|
||||
*ccp = buf[0];
|
||||
}
|
||||
|
||||
/* Return the shaped character */
|
||||
// Return the shaped character
|
||||
return curr_c;
|
||||
}
|
||||
|
||||
@ -1441,11 +1432,9 @@ bool arabic_maycombine(int two)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* A_firstc_laa returns first character of LAA combination if it exists
|
||||
* in: "c" base character
|
||||
* in: "c1" first composing character
|
||||
*/
|
||||
// A_firstc_laa returns first character of LAA combination if it ex.ists
|
||||
// in: "c" base character
|
||||
// in: "c1" first composing character
|
||||
static int A_firstc_laa(int c, int c1)
|
||||
{
|
||||
if ((c1 != NUL) && (c == a_LAM) && !A_is_harakat(c1)) {
|
||||
@ -1454,19 +1443,15 @@ static int A_firstc_laa(int c, int c1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* A_is_harakat returns TRUE if 'c' is an Arabic Harakat character
|
||||
* (harakat/tanween)
|
||||
*/
|
||||
// A_is_harakat returns true if 'c' is an Arabic Harakat character.
|
||||
// (harakat/tanween)
|
||||
static bool A_is_harakat(int c)
|
||||
{
|
||||
return c >= a_FATHATAN && c <= a_SUKUN;
|
||||
}
|
||||
|
||||
/*
|
||||
* A_is_iso returns TRUE if 'c' is an Arabic ISO-8859-6 character
|
||||
* (alphabet/number/punctuation)
|
||||
*/
|
||||
// A_is_iso returns true if 'c' is an Arabic ISO-8859-6 character.
|
||||
// (alphabet/number/punctuation)
|
||||
static bool A_is_iso(int c)
|
||||
{
|
||||
return (c >= a_HAMZA && c <= a_GHAIN) ||
|
||||
@ -1474,10 +1459,8 @@ static bool A_is_iso(int c)
|
||||
c == a_MINI_ALEF;
|
||||
}
|
||||
|
||||
/*
|
||||
* A_is_formb returns TRUE if 'c' is an Arabic 10646-1 FormB character
|
||||
* (alphabet/number/punctuation)
|
||||
*/
|
||||
// A_is_formb returns true if 'c' is an Arabic 10646-1 FormB character.
|
||||
// (alphabet/number/punctuation)
|
||||
static bool A_is_formb(int c)
|
||||
{
|
||||
return (c >= a_s_FATHATAN && c <= a_s_DAMMATAN) ||
|
||||
@ -1486,27 +1469,21 @@ static bool A_is_formb(int c)
|
||||
c == a_BYTE_ORDER_MARK;
|
||||
}
|
||||
|
||||
/*
|
||||
* A_is_ok returns TRUE if 'c' is an Arabic 10646 (8859-6 or Form-B)
|
||||
*/
|
||||
// A_is_ok returns true if 'c' is an Arabic 10646 (8859-6 or Form-B).
|
||||
static bool A_is_ok(int c)
|
||||
{
|
||||
return A_is_iso(c) || A_is_formb(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* A_is_valid returns TRUE if 'c' is an Arabic 10646 (8859-6 or Form-B)
|
||||
* with some exceptions/exclusions
|
||||
*/
|
||||
// A_is_valid returns true if 'c' is an Arabic 10646 (8859-6 or Form-B),
|
||||
// with some exceptions/exclusions.
|
||||
static bool A_is_valid(int c)
|
||||
{
|
||||
return A_is_ok(c) && !A_is_special(c);
|
||||
}
|
||||
|
||||
/*
|
||||
* A_is_special returns TRUE if 'c' is not a special Arabic character.
|
||||
* Specials don't adhere to most of the rules.
|
||||
*/
|
||||
// A_is_special returns true if 'c' is not a special Arabic character.
|
||||
// Specials don't adhere to most of the rules.
|
||||
static bool A_is_special(int c)
|
||||
{
|
||||
return c == a_HAMZA || c == a_s_HAMZA;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/// @file farsi.c
|
||||
///
|
||||
/// Functions for Farsi language
|
||||
///
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "nvim/cursor.h"
|
||||
#include "nvim/edit.h"
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
#define AT_CURSOR 0
|
||||
|
||||
// special Farsi text messages
|
||||
// Special Farsi text messages
|
||||
|
||||
const char_u farsi_text_1[] = {
|
||||
YE_, _SIN, RE, ALEF_, _FE, ' ', 'V', 'I', 'M',
|
||||
@ -59,6 +59,7 @@ const char_u farsi_text_5[] = {
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "farsi.c.generated.h"
|
||||
#endif
|
||||
|
||||
/// Convert the given Farsi character into a _X or _X_ type
|
||||
///
|
||||
/// @param c The character to convert.
|
||||
@ -287,8 +288,8 @@ int toF_TyA(int c)
|
||||
/// @param src
|
||||
/// @param offset
|
||||
///
|
||||
/// @return TRUE if the character under the cursor+offset is a join type.
|
||||
static int F_is_TyB_TyC_TyD(int src, int offset)
|
||||
/// @return true if the character under the cursor+offset is a join type.
|
||||
static bool F_is_TyB_TyC_TyD(int src, int offset)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -330,17 +331,17 @@ static int F_is_TyB_TyC_TyD(int src, int offset)
|
||||
case _IE:
|
||||
case _HE_:
|
||||
case _HE:
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Is the Farsi character one of the terminating only type.
|
||||
///
|
||||
/// @param c The character to check.
|
||||
///
|
||||
/// @return TRUE if the Farsi character is one of the terminating only types.
|
||||
static int F_is_TyE(int c)
|
||||
/// @return true if the Farsi character is one of the terminating only types.
|
||||
static bool F_is_TyE(int c)
|
||||
{
|
||||
switch (c) {
|
||||
case ALEF_A:
|
||||
@ -353,17 +354,17 @@ static int F_is_TyE(int c)
|
||||
case WAW:
|
||||
case WAW_H:
|
||||
case HAMZE:
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Is the Farsi character one of the none leading type.
|
||||
///
|
||||
/// @param c The character to check.
|
||||
///
|
||||
/// @return TRUE if the Farsi character is one of the none-leading types.
|
||||
static int F_is_TyC_TyD(int c)
|
||||
/// @return true if the Farsi character is one of the none-leading types.
|
||||
static bool F_is_TyC_TyD(int c)
|
||||
{
|
||||
switch (c) {
|
||||
case ALEF_:
|
||||
@ -377,9 +378,9 @@ static int F_is_TyC_TyD(int c)
|
||||
case IE_:
|
||||
case TEE_:
|
||||
case YEE_:
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Convert a none leading Farsi char into a leading type.
|
||||
@ -2081,8 +2082,8 @@ static int toF_Rjoin(int c)
|
||||
///
|
||||
/// @param c The character to check.
|
||||
///
|
||||
/// @return TRUE if the character can join via its left edj.
|
||||
static int canF_Ljoin(int c)
|
||||
/// @return true if the character can join via its left edj.
|
||||
static bool canF_Ljoin(int c)
|
||||
{
|
||||
switch (c) {
|
||||
case _BE:
|
||||
@ -2146,17 +2147,17 @@ static int canF_Ljoin(int c)
|
||||
case F_HE:
|
||||
case _HE:
|
||||
case _HE_:
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Can a given Farsi character join via its right edj.
|
||||
///
|
||||
/// @param c
|
||||
///
|
||||
/// @return TRUE if the character can join via its right edj.
|
||||
static int canF_Rjoin(int c)
|
||||
/// @return true if the character can join via its right edj.
|
||||
static bool canF_Rjoin(int c)
|
||||
{
|
||||
switch (c) {
|
||||
case ALEF:
|
||||
@ -2172,9 +2173,8 @@ static int canF_Rjoin(int c)
|
||||
case TEE_:
|
||||
case WAW:
|
||||
case WAW_H:
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return canF_Ljoin(c);
|
||||
}
|
||||
|
||||
@ -2182,8 +2182,8 @@ static int canF_Rjoin(int c)
|
||||
///
|
||||
/// @param c
|
||||
///
|
||||
/// @return TRUE if the character is a terminating type.
|
||||
static int F_isterm(int c)
|
||||
/// @return true if the character is a terminating type.
|
||||
static bool F_isterm(int c)
|
||||
{
|
||||
switch (c) {
|
||||
case ALEF:
|
||||
@ -2199,10 +2199,9 @@ static int F_isterm(int c)
|
||||
case WAW_H:
|
||||
case TEE:
|
||||
case TEE_:
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Convert the given Farsi character into an ending type.
|
||||
@ -2915,34 +2914,34 @@ int cmdl_fkmap(int c)
|
||||
return c;
|
||||
}
|
||||
|
||||
/// F_isalpha returns TRUE if 'c' is a Farsi alphabet
|
||||
/// F_isalpha returns true if 'c' is in the Farsi alphabet.
|
||||
///
|
||||
/// @param c The character to check.
|
||||
///
|
||||
/// @return TRUE if 'c' is a Farsi alphabet character.
|
||||
int F_isalpha(int c)
|
||||
/// @return true if 'c' is a Farsi alphabet character.
|
||||
bool F_isalpha(int c)
|
||||
{
|
||||
return (c >= TEE_ && c <= _YE)
|
||||
|| (c >= ALEF_A && c <= YE)
|
||||
|| (c >= _IE && c <= YE_);
|
||||
}
|
||||
|
||||
/// F_isdigit returns TRUE if 'c' is a Farsi digit
|
||||
/// F_isdigit returns true if 'c' is a Farsi digit
|
||||
///
|
||||
/// @param c The character to check.
|
||||
///
|
||||
/// @return TRUE if 'c' is a Farsi digit.
|
||||
int F_isdigit(int c)
|
||||
/// @return true if 'c' is a Farsi digit.
|
||||
bool F_isdigit(int c)
|
||||
{
|
||||
return c >= FARSI_0 && c <= FARSI_9;
|
||||
}
|
||||
|
||||
/// F_ischar returns TRUE if 'c' is a Farsi character.
|
||||
/// F_ischar returns true if 'c' is a Farsi character.
|
||||
///
|
||||
/// @param c The character to check.
|
||||
///
|
||||
/// @return TRUE if 'c' is a Farsi character.
|
||||
int F_ischar(int c)
|
||||
/// @return true if 'c' is a Farsi character.
|
||||
bool F_ischar(int c)
|
||||
{
|
||||
return c >= TEE_ && c <= YE_;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user