aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/arabic.c105
-rw-r--r--src/nvim/farsi.c71
-rw-r--r--src/nvim/hardcopy.c70
3 files changed, 106 insertions, 140 deletions
diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c
index 7880c66e1e..7d50aae7ab 100644
--- a/src/nvim/arabic.c
+++ b/src/nvim/arabic.c
@@ -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;
diff --git a/src/nvim/farsi.c b/src/nvim/farsi.c
index 13a284e926..db167825ce 100644
--- a/src/nvim/farsi.c
+++ b/src/nvim/farsi.c
@@ -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_;
}
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index 2ef35fdac6..1d15e30921 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -2434,20 +2434,15 @@ int mch_print_begin(prt_settings_T *psettings)
double right;
double top;
double bottom;
- struct prt_ps_resource_S *res_prolog;
- struct prt_ps_resource_S *res_encoding;
+ struct prt_ps_resource_S res_prolog;
+ struct prt_ps_resource_S res_encoding;
char buffer[256];
char_u *p_encoding;
char_u *p;
- struct prt_ps_resource_S *res_cidfont;
- struct prt_ps_resource_S *res_cmap;
+ struct prt_ps_resource_S res_cidfont;
+ struct prt_ps_resource_S res_cmap;
int retval = FALSE;
- res_prolog = xmalloc(sizeof(struct prt_ps_resource_S));
- res_encoding = xmalloc(sizeof(struct prt_ps_resource_S));
- res_cidfont = xmalloc(sizeof(struct prt_ps_resource_S));
- res_cmap = xmalloc(sizeof(struct prt_ps_resource_S));
-
/*
* PS DSC Header comments - no PS code!
*/
@@ -2515,23 +2510,23 @@ int mch_print_begin(prt_settings_T *psettings)
}
/* Search for external resources VIM supplies */
- if (!prt_find_resource("prolog", res_prolog)) {
+ if (!prt_find_resource("prolog", &res_prolog)) {
EMSG(_("E456: Can't find PostScript resource file \"prolog.ps\""));
return FALSE;
}
- if (!prt_open_resource(res_prolog))
+ if (!prt_open_resource(&res_prolog))
return FALSE;
- if (!prt_check_resource(res_prolog, PRT_PROLOG_VERSION))
+ if (!prt_check_resource(&res_prolog, PRT_PROLOG_VERSION))
return FALSE;
if (prt_out_mbyte) {
/* Look for required version of multi-byte printing procset */
- if (!prt_find_resource("cidfont", res_cidfont)) {
+ if (!prt_find_resource("cidfont", &res_cidfont)) {
EMSG(_("E456: Can't find PostScript resource file \"cidfont.ps\""));
return FALSE;
}
- if (!prt_open_resource(res_cidfont))
+ if (!prt_open_resource(&res_cidfont))
return FALSE;
- if (!prt_check_resource(res_cidfont, PRT_CID_PROLOG_VERSION))
+ if (!prt_check_resource(&res_cidfont, PRT_CID_PROLOG_VERSION))
return FALSE;
}
@@ -2543,25 +2538,25 @@ int mch_print_begin(prt_settings_T *psettings)
if (!prt_out_mbyte) {
p_encoding = enc_skip(p_penc);
if (*p_encoding == NUL
- || !prt_find_resource((char *)p_encoding, res_encoding)) {
+ || !prt_find_resource((char *)p_encoding, &res_encoding)) {
/* 'printencoding' not set or not supported - find alternate */
int props;
p_encoding = enc_skip(p_enc);
props = enc_canon_props(p_encoding);
if (!(props & ENC_8BIT)
- || !prt_find_resource((char *)p_encoding, res_encoding)) {
+ || !prt_find_resource((char *)p_encoding, &res_encoding)) {
/* 8-bit 'encoding' is not supported */
/* Use latin1 as default printing encoding */
p_encoding = (char_u *)"latin1";
- if (!prt_find_resource((char *)p_encoding, res_encoding)) {
+ if (!prt_find_resource((char *)p_encoding, &res_encoding)) {
EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
p_encoding);
return FALSE;
}
}
}
- if (!prt_open_resource(res_encoding))
+ if (!prt_open_resource(&res_encoding))
return FALSE;
/* For the moment there are no checks on encoding resource files to
* perform */
@@ -2571,12 +2566,12 @@ int mch_print_begin(prt_settings_T *psettings)
p_encoding = enc_skip(p_enc);
if (prt_use_courier) {
/* Include ASCII range encoding vector */
- if (!prt_find_resource(prt_ascii_encoding, res_encoding)) {
+ if (!prt_find_resource(prt_ascii_encoding, &res_encoding)) {
EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
prt_ascii_encoding);
return FALSE;
}
- if (!prt_open_resource(res_encoding))
+ if (!prt_open_resource(&res_encoding))
return FALSE;
/* For the moment there are no checks on encoding resource files to
* perform */
@@ -2597,37 +2592,37 @@ int mch_print_begin(prt_settings_T *psettings)
if (prt_out_mbyte && prt_custom_cmap) {
/* Find user supplied CMap */
- if (!prt_find_resource(prt_cmap, res_cmap)) {
+ if (!prt_find_resource(prt_cmap, &res_cmap)) {
EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
prt_cmap);
return FALSE;
}
- if (!prt_open_resource(res_cmap))
+ if (!prt_open_resource(&res_cmap))
return FALSE;
}
/* List resources supplied */
- STRCPY(buffer, res_prolog->title);
+ STRCPY(buffer, res_prolog.title);
STRCAT(buffer, " ");
- STRCAT(buffer, res_prolog->version);
+ STRCAT(buffer, res_prolog.version);
prt_dsc_resources("DocumentSuppliedResources", "procset", buffer);
if (prt_out_mbyte) {
- STRCPY(buffer, res_cidfont->title);
+ STRCPY(buffer, res_cidfont.title);
STRCAT(buffer, " ");
- STRCAT(buffer, res_cidfont->version);
+ STRCAT(buffer, res_cidfont.version);
prt_dsc_resources(NULL, "procset", buffer);
if (prt_custom_cmap) {
- STRCPY(buffer, res_cmap->title);
+ STRCPY(buffer, res_cmap.title);
STRCAT(buffer, " ");
- STRCAT(buffer, res_cmap->version);
+ STRCAT(buffer, res_cmap.version);
prt_dsc_resources(NULL, "cmap", buffer);
}
}
if (!prt_out_mbyte || prt_use_courier) {
- STRCPY(buffer, res_encoding->title);
+ STRCPY(buffer, res_encoding.title);
STRCAT(buffer, " ");
- STRCAT(buffer, res_encoding->version);
+ STRCAT(buffer, res_encoding.version);
prt_dsc_resources(NULL, "encoding", buffer);
}
prt_dsc_requirements(prt_duplex, prt_tumble, prt_collate,
@@ -2661,20 +2656,20 @@ int mch_print_begin(prt_settings_T *psettings)
prt_dsc_noarg("BeginProlog");
/* Add required procsets - NOTE: order is important! */
- if (!prt_add_resource(res_prolog))
+ if (!prt_add_resource(&res_prolog))
return FALSE;
if (prt_out_mbyte) {
/* Add CID font procset, and any user supplied CMap */
- if (!prt_add_resource(res_cidfont))
+ if (!prt_add_resource(&res_cidfont))
return FALSE;
- if (prt_custom_cmap && !prt_add_resource(res_cmap))
+ if (prt_custom_cmap && !prt_add_resource(&res_cmap))
return FALSE;
}
if (!prt_out_mbyte || prt_use_courier)
/* There will be only one Roman font encoding to be included in the PS
* file. */
- if (!prt_add_resource(res_encoding))
+ if (!prt_add_resource(&res_encoding))
return FALSE;
prt_dsc_noarg("EndProlog");
@@ -2780,11 +2775,6 @@ int mch_print_begin(prt_settings_T *psettings)
/* Fail if any problems writing out to the PS file */
retval = !prt_file_error;
- free(res_prolog);
- free(res_encoding);
- free(res_cidfont);
- free(res_cmap);
-
return retval;
}