Back to index

texmacs  1.0.7.15
Functions
analyze.hpp File Reference
#include "string.hpp"
#include "array.hpp"
#include "hashset.hpp"

Go to the source code of this file.

Functions

bool is_alpha (char c)
bool is_iso_alpha (char c)
bool is_locase (char c)
bool is_upcase (char c)
bool is_digit (char c)
bool is_numeric (char c)
bool is_punctuation (char c)
bool is_space (char s)
bool is_alpha (string s)
bool is_locase_alpha (string s)
bool is_iso_alpha (string s)
bool is_numeric (string s)
char upcase (char s)
char locase (char s)
string upcase_first (string s)
string locase_first (string s)
string upcase_all (string s)
string locase_all (string s)
string string_union (string s1, string s2)
string string_minus (string s1, string s2)
string iso_to_koi8 (string s)
string koi8_to_iso (string s)
string iso_to_koi8uk (string s)
string koi8uk_to_iso (string s)
string il2_to_cork (string s)
string cork_to_il2 (string s)
string ispanish_to_spanish (string s)
string spanish_to_ispanish (string s)
string igerman_to_german (string s)
string german_to_igerman (string s)
string old_tm_to_xml_cdata (string s)
object tm_to_xml_cdata (string s)
string old_xml_cdata_to_tm (string s)
string tm_to_xml_name (string s)
string xml_name_to_tm (string s)
string xml_unspace (string s, bool first, bool last)
bool contains_unicode_char (string s)
string roman_nr (int nr)
string Roman_nr (int nr)
string alpha_nr (int nr)
string Alpha_nr (int nr)
string fnsymbol_nr (int nr)
string as_hexadecimal (int i)
string as_hexadecimal (pointer ptr)
string as_hexadecimal (int i, int length)
int from_hexadecimal (string s)
string tm_encode (string s)
string tm_decode (string s)
string tm_var_encode (string s)
string tm_correct (string s)
void tm_char_forwards (string s, int &pos)
void tm_char_backwards (string s, int &pos)
int tm_char_next (string s, int pos)
int tm_char_previous (string s, int pos)
string tm_forward_access (string s, int i)
string tm_backward_access (string s, int i)
int tm_string_length (string s)
array< stringtm_tokenize (string s)
string tm_recompose (array< string > a)
string scm_quote (string s)
string scm_unquote (string s)
string raw_quote (string s)
string raw_unquote (string s)
string escape_sh (string s)
string escape_generic (string s)
string escape_verbatim (string s)
string escape_spaces (string s)
string dos_to_better (string s)
bool test (string s, int i, const char *test)
bool test (string s, int i, string test)
bool starts (string s, const char *test)
bool starts (string s, const string test)
bool ends (string s, const char *test)
bool ends (string s, const string test)
bool read (string s, int &i, const char *test)
bool read (string s, int &i, string test)
bool read (string s, string test)
bool read_line (string s, int &i, string &result)
bool read_int (string s, int &i, int &result)
bool read_double (string s, int &i, double &result)
void skip_spaces (string s, int &i)
void skip_line (string s, int &i)
void skip_symbol (string s, int &i)
void parse (string s, int &pos, QI &ret)
void parse (string s, int &pos, QN &ret)
void parse (string s, int &pos, HI &ret)
void parse (string s, int &pos, HN &ret)
void parse (string s, int &pos, SI &ret)
void parse (string s, int &pos, SI *&a, int len)
int search_forwards (string what, string in)
int search_forwards (string what, int pos, string in)
int search_backwards (string what, string in)
int search_backwards (string what, int pos, string in)
int count_occurrences (string what, string in)
bool occurs (string what, string in)
string replace (string s, string what, string by)
bool match_wildcard (string s, string w)
array< stringtokenize (string s, string sep)
string recompose (array< string > a, string sep)
string trim_spaces (string s)
array< stringtrim_spaces (array< string > a)
array< stringas_completions (hashset< string > h)
array< stringclose_completions (array< string > a)
array< stringstrip_completions (array< string > a, string prefix)

Function Documentation

string alpha_nr ( int  nr)

Definition at line 551 of file analyze.cpp.

                  {
  if (nr<0) return "-" * alpha_nr (nr);
  if (nr==0) return "0";
  if (nr<=26) return string ((char) (((int) 'a')+ nr-1));
  return alpha_nr ((nr-1)/26) * alpha_nr (((nr-1)%26)+1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

string Alpha_nr ( int  nr)

Definition at line 559 of file analyze.cpp.

                  {
  return upcase_all (alpha_nr (nr));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1237 of file analyze.cpp.

                                   {
  tree t= (tree) h;
  int i, n= N(t);
  array<string> a (n);
  for (i=0; i<n; i++) a[i]= t[i]->label;
  merge_sort (a);
  return a;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string as_hexadecimal ( int  i)

Definition at line 583 of file analyze.cpp.

                       {
  if (i<0) return "-" * as_hexadecimal (-i);
  if (i<16) return hex_string [i & 15];
  return as_hexadecimal (i >> 4) * hex_string [i & 15];
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 590 of file analyze.cpp.

                             {
  intptr_t i= (intptr_t) ptr;
  if (i<0) return "-" * as_hexadecimal (-i);
  if (i<16) return hex_string [i & 15];
  return as_hexadecimal (i >> 4) * hex_string [i & 15];
}

Here is the call graph for this function:

string as_hexadecimal ( int  i,
int  length 
)

Definition at line 598 of file analyze.cpp.

                                {
  if (len==1) return hex_string [i & 15];
  else return as_hexadecimal (i >> 4, len-1) * hex_string [i & 15];
}

Here is the call graph for this function:

Definition at line 1270 of file analyze.cpp.

                                    {
  if (N(a) == 0) return a;
  merge_sort (a);
  int i, j, n= N(a), l= N(a[0]);
  for (i=1; i<n; i++) {
    for (j=0; j<l && j<N(a[i]); j++)
      if (a[i-1][j] != a[i][j]) break;
    l= j;
  }
  array<string> r;
  r << a[0] (0, l);
  for (i=0; i<n; i++)
    if (a[i] != r[N(r)-1])
      r << a[i];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 512 of file analyze.cpp.

                                 {
  int i= 0, n= N(s);
  while (i+1<n) {
    if (s[i] == '<' && s[i+1] == '#') return true;
    tm_char_forwards (s, i);
  }
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 297 of file analyze.cpp.

                       {
  int i, n= N(s);
  string r (n);
  for (i=0; i<n; i++)
    r[i]= cork_to_il2 (s[i]);
  return r;
}

Here is the call graph for this function:

int count_occurrences ( string  what,
string  in 
)

Definition at line 1145 of file analyze.cpp.

                                        {
  int count= 0;
  int i=0, next, n= N(s);
  while (i<n) {
    next= search_forwards (s, i, in);
    if (next == -1) break;
    count++;
    i= next+1;
  }
  return count;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 894 of file analyze.cpp.

                         {
  int i, n= N(s);
  string r;
  for (i=0; i<n; i++)
    if (s[i] == '\015');
    else r << s[i];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool ends ( string  s,
const char *  test 
)

Definition at line 940 of file analyze.cpp.

                                  {
  string r (what);
  if (N(r) > N(s)) return false;
  return s (N(s)-N(r), N(s)) == r;
}

Here is the call graph for this function:

bool ends ( string  s,
const string  test 
)

Definition at line 947 of file analyze.cpp.

                                {
  if (N(r) > N(s)) return false;
  return s (N(s)-N(r), N(s)) == r;
}

Here is the call graph for this function:

Definition at line 859 of file analyze.cpp.

                          {
  int i, n= N(s);
  string r;
  for (i=0; i<n; i++) {
    if ((s[i] == '\2') || (s[i] == '\5') || (s[i] == '\33')) r << '\33';
    r << s[i];
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 834 of file analyze.cpp.

                     {
#if defined (__MINGW__) || defined (__MINGW32__) || defined (OS_WIN32)
  return raw_quote (s);
#else
  int i, n= N(s);
  string r;
  for (i=0; i<n; i++)
    switch (s[i]) {
    case '?':
    case '&':
    case '$':
    case '`':
    case '\"':
    case '\\':
    case ' ':
      r << '\\' << s[i];
      break;
    default:
      r << s[i];
    }
  return r;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 882 of file analyze.cpp.

                         {
  int i, n= N(s);
  string r;
  for (i=0; i<n; i++) {
    unsigned char c= (unsigned char) s[i];
    if (c == ' ') r << '\\';
    r << c;
  }
  return r;
}

Here is the call graph for this function:

Definition at line 870 of file analyze.cpp.

                           {
  int i, n= N(s);
  string r;
  for (i=0; i<n; i++) {
    unsigned char c= (unsigned char) s[i];
    if ((c == '\n') || (c == '\t')) r << ' ';
    else if (((int) c) >= 32) r << s[i];
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string fnsymbol_nr ( int  nr)

Definition at line 564 of file analyze.cpp.

                     {
  string sym, r;
  int i, m= (nr-1)%3, n= ((nr-1)/3)+1;
  switch (m) {
  case 0: sym= "<ast>"; break;
  case 1: sym= "<dag>"; break;
  case 2: sym= "<ddag>"; break;
  }
  for (i=0; i<n; i++) r << sym;
  return r;
}

Here is the caller graph for this function:

Definition at line 604 of file analyze.cpp.

                            {
  int i, n= N(s), res= 0;
  if ((n>0) && (s[0]=='-'))
    return -from_hexadecimal (s (1, n));
  for (i=0; i<n; i++) {
    res= res << 4;
    if ((s[i] >= '0') && (s[i] <= '9')) res += (int) (s[i] - '0');
    if ((s[i] >= 'A') && (s[i] <= 'F')) res += (int) (s[i] + 10 - 'A');
    if ((s[i] >= 'a') && (s[i] <= 'f')) res += (int) (s[i] + 10 - 'a');
  }
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 255 of file analyze.cpp.

                             {
  int i, n= N(s);
  string r;
  for (i=0; i<n; i++)
    if (s[i] == '') r << '';
    else r << s[i];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 245 of file analyze.cpp.

                             {
  int i, n= N(s);
  string r;
  for (i=0; i<n; i++)
    if (s[i] == '') r << '';
    else r << s[i];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 288 of file analyze.cpp.

                       {
  int i, n= N(s);
  string r (n);
  for (i=0; i<n; i++)
    r[i]= il2_to_cork (s[i]);
  return r;
}

Here is the call graph for this function:

bool is_alpha ( char  c)
bool is_alpha ( string  s)

Definition at line 80 of file analyze.cpp.

                    {
  int i;
  if (N(s)==0) return false;
  for (i=0; i<N(s); i++)
    if (!is_alpha (s[i])) return false;
  return true;
}

Here is the call graph for this function:

bool is_digit ( char  c)
bool is_iso_alpha ( char  c)
bool is_iso_alpha ( string  s)

Definition at line 98 of file analyze.cpp.

                        {
  int i;
  if (N(s)==0) return false;
  for (i=0; i<N(s); i++)
    if (!is_iso_alpha (s[i])) return false;
  return true;
}

Here is the call graph for this function:

bool is_locase ( char  c)
bool is_locase_alpha ( string  s)

Definition at line 89 of file analyze.cpp.

                           {
  int i;
  if (N(s)==0) return false;
  for (i=0; i<N(s); i++)
    if (s[i]<'a' || s[i]>'z') return false;
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_numeric ( char  c)
bool is_numeric ( string  s)

Definition at line 107 of file analyze.cpp.

                      {
  int i;
  if (N(s)==0) return false;
  for (i=0; i<N(s); i++)
    if (!is_numeric (s[i])) return false;
  return true;
}

Here is the call graph for this function:

bool is_punctuation ( char  c)
bool is_space ( char  s)
bool is_upcase ( char  c)

Definition at line 370 of file analyze.cpp.

                       {
  int i, n= N(s);
  string r (n);
  for (i=0; i<n; i++)
    r[i]= iso_to_koi8 (s[i], false);
  return r;
}

Here is the call graph for this function:

Definition at line 388 of file analyze.cpp.

                         {
  int i, n= N(s);
  string r (n);
  for (i=0; i<n; i++)
    r[i]= iso_to_koi8 (s[i], true);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 191 of file analyze.cpp.

                               {
  int i, n= N(s);
  string r;
  for (i=0; i<n; i++)
    if ((s[i] == '\'') && ((i+1)<n)) {
      switch (s[i+1]) {
      case 'A': r << ''; break;
      case 'E': r << ''; break;
      case 'I': r << ''; break;
      case 'N': r << ''; break;
      case 'O': r << ''; break;
      case 'U': r << ''; break;
      case 'Y': r << ''; break;
      case 'a': r << ''; break;
      case 'e': r << ''; break;
      case 'i': r << ''; break;
      case 'n': r << ''; break;
      case 'o': r << ''; break;
      case 'u': r << ''; break;
      case 'y': r << ''; break;
      default : r << '\'' << s[i+1];
      }
      i++;
    }
    else r << s[i];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 361 of file analyze.cpp.

                       {
  int i, n= N(s);
  string r (n);
  for (i=0; i<n; i++)
    r[i]= koi8_to_iso (s[i], false);
  return r;
}

Here is the call graph for this function:

Definition at line 379 of file analyze.cpp.

                         {
  int i, n= N(s);
  string r (n);
  for (i=0; i<n; i++)
    r[i]= koi8_to_iso (s[i], true);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char locase ( char  s)

Definition at line 127 of file analyze.cpp.

                {
  if (is_upcase (c))
    return (char) (((int) ((unsigned char) c)) + 32);
  else return c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 156 of file analyze.cpp.

                      {
  int i;
  string r (N(s));
  for (i=0; i<N(s); i++)
    if (!is_upcase (s[i])) r[i]= s[i];
    else r[i]= (char) (((int) ((unsigned char) s[i]))+32);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 140 of file analyze.cpp.

                        {
  if ((N(s)==0) || (!is_upcase (s[0]))) return s;
  return string ((char) (((int) ((unsigned char) s[0]))+32)) * s (1, N(s));
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool match_wildcard ( string  s,
string  w 
)

Definition at line 1188 of file analyze.cpp.

                                    {
  return match_wildcard (s, 0, w, 0);
}

Here is the call graph for this function:

bool occurs ( string  what,
string  in 
)

Definition at line 1126 of file analyze.cpp.

                                {
  return search_forwards (what, 0, in) >= 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 432 of file analyze.cpp.

                               {
  string r;
  int i, n= N(s);
  for (i=0; i<n; i++)
    if (s[i] == '&') r << "&amp;";
    else if (s[i] == '>') r << "&gt;";
    else if (s[i] != '<') r << s[i];
    else {
      int start= ++i;
      while ((i<n) && (s[i]!='>')) i++;
      r << "&" << tm_to_xml_name (s (start, i)) << ";";
    }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 480 of file analyze.cpp.

                               {
  string r;
  int i, n= N(s);
  for (i=0; i<n; i++)
    if (s[i] == '<') r << "<less>";
    else if (s[i] == '>') r << "<gtr>";
    else if (s[i] != '&') r << s[i];
    else {
      int start= ++i;
      while ((i<n) && (s[i]!=';')) i++;
      string x= "<" * xml_name_to_tm (s (start, i)) * ">";
      if (x == "<amp>") r << "&";
      else r << x;
    }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void parse ( string  s,
int &  pos,
QI ret 
)

Definition at line 1065 of file analyze.cpp.

                                    {
  ret= (QI) s[pos++];
}

Here is the caller graph for this function:

void parse ( string  s,
int &  pos,
QN ret 
)

Definition at line 1070 of file analyze.cpp.

                                    {
  ret= (QN) s[pos++];
}
void parse ( string  s,
int &  pos,
HI ret 
)

Definition at line 1075 of file analyze.cpp.

                                    {
  QI c1= (QI) s[pos++];
  QN c2= (QN) s[pos++];
  ret= (((HI) c1)<<8)+ c2;
}
void parse ( string  s,
int &  pos,
HN ret 
)

Definition at line 1082 of file analyze.cpp.

                                    {
  QN c1= (QN) s[pos++];
  QN c2= (QN) s[pos++];
  ret= (((HN) c1)<<8)+ c2;
}
void parse ( string  s,
int &  pos,
SI ret 
)

Definition at line 1089 of file analyze.cpp.

                                    {
  QI c1= (QI) s[pos++];
  QN c2= (QN) s[pos++];
  QN c3= (QN) s[pos++];
  QN c4= (QN) s[pos++];
  ret= (((((((SI) c1)<<8)+ ((SI) c2))<<8)+ ((SI) c3))<<8)+ c4;
}
void parse ( string  s,
int &  pos,
SI *&  a,
int  len 
)

Definition at line 1098 of file analyze.cpp.

                                            {
  int i;
  a= tm_new_array<int> (len);
  for (i=0; i<len; i++) parse (s, pos, a[i]);
}

Here is the call graph for this function:

Definition at line 816 of file analyze.cpp.

                     {
  // Mark the label of a STRING tree as representing a string and not a symbol.
  return "\"" * s * "\"";
}

Here is the caller graph for this function:

Definition at line 822 of file analyze.cpp.

                       {
  // Get the string value of a STRING tree label representing a string.
  if ((N(s)>=2) && (s[0]=='\"') && (s[N(s)-1]=='\"'))
    return s (1, N(s)-1);
  else return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool read ( string  s,
int &  i,
const char *  test 
)

Definition at line 953 of file analyze.cpp.

                                          {
  int n= N(s), j=0, k=i;
  while (test[j]!='\0') {
    if (k>=n) return false;
    if (s[k]!=test[j]) return false;
    j++; k++;
  }
  i=k;
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool read ( string  s,
int &  i,
string  test 
)

Definition at line 971 of file analyze.cpp.

                                     {
  int n= N(s), m= N(test), j=0, k=i;
  while (j<m) {
    if (k>=n) return false;
    if (s[k]!=test[j]) return false;
    j++; k++;
  }
  i=k;
  return true;
}

Here is the call graph for this function:

bool read ( string  s,
string  test 
)

Definition at line 965 of file analyze.cpp.

                             {
  int i = 0;
  return read (s, i, test);
}

Here is the call graph for this function:

bool read_double ( string  s,
int &  i,
double &  result 
)

Definition at line 1012 of file analyze.cpp.

                                               {
  int n= N(s), start= i;
  result= 0.0;
  if (i==n) return false;
  if (s[i]=='-') {
    if (i+1==n) return false;
    if (!is_numeric (s[i+1])) return false;
    i++;
  }
  else if (!is_numeric (s[i])) return false;
  while ((i<n) && is_digit (s[i])) i++;
  if ((i<n) && (s[i]=='.')) i++;
  while ((i<n) && is_digit (s[i])) i++;
  if ((i<n) && ((s[i]=='e') || (s[i]=='E'))) {
    i++;
    if ((i<n) && (s[i]=='-')) i++;
    if ((i==n) || (!is_digit (s[i]))) { i=start; return false; }
    while ((i<n) && is_digit (s[i])) i++;
  }
  result= as_double (s(start,i));
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool read_int ( string  s,
int &  i,
int &  result 
)

Definition at line 996 of file analyze.cpp.

                                         {
  int n= N(s), start= i;
  result= 0;
  if (i==n) return false;
  if (s[i]=='-') {
    if (i+1==n) return false;
    if (!is_digit (s[i+1])) return false;
    i++;
  }
  else if (!is_digit (s[i])) return false;
  while ((i<n) && is_digit (s[i])) i++;
  result= as_int (s(start,i));
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool read_line ( string  s,
int &  i,
string result 
)

Definition at line 983 of file analyze.cpp.

                                             {
  int start= i;
  for (; i<N(s); i++) {
    if (s[i]=='\n') {
      result= s(start,i++);
      return true;
    }
  }
  result= s(start,i);
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string recompose ( array< string a,
string  sep 
)

Definition at line 1207 of file analyze.cpp.

                                        {
  string r;
  for (int i=0; i<N(a); i++) {
    if (i != 0) r << sep;
    r << a[i];
  }
  return r;
}

Here is the call graph for this function:

string replace ( string  s,
string  what,
string  by 
)

Definition at line 1158 of file analyze.cpp.

                                           {
  int i, n= N(s);
  string r;
  for (i=0; i<n; )
    if (test (s, i, what)) {
      r << by;
      i += N(what);
    }
    else {
      r << s[i];
      i++;
    }
  return r;
}

Here is the call graph for this function:

string roman_nr ( int  nr)

Definition at line 533 of file analyze.cpp.

                  {
  if (nr<0) return "-" * roman_nr (nr);
  if (nr==0) return "o";
  if (nr>1000) return "m" * roman_nr (nr-1000);
  if (nr==1000) return "m";
  if (nr==999) return "im";
  if (nr==499) return "id";
  if ((nr%100)==99) return hundreds[nr/100] * "ic";
  if ((nr%100)==49) return hundreds[nr/100] * "il";
  return hundreds[nr/100] * tens[(nr%100)/10] * ones[nr%10];
}

Here is the call graph for this function:

Here is the caller graph for this function:

string Roman_nr ( int  nr)

Definition at line 546 of file analyze.cpp.

                  {
  return upcase_all (roman_nr (nr));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 784 of file analyze.cpp.

                     {
  // R5RS compliant external string representation.
  int i, n= N(s);
  string r;
  r << '"';
  for (i=0; i<n; i++)
    switch (s[i]) {
    case '\"':
    case '\\':
      r << '\\' << s[i];
      break;
    default:
      r << s[i];
    }
  r << '"';
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 803 of file analyze.cpp.

                       {
  if ((N(s)>=2) && (s[0]=='\"') && (s[N(s)-1]=='\"')) {
    int i, n= N(s);
    string r;
    for (i=1; i<n-1; i++)
      if (s[i] == '\\' && (s[i+1] == '\"' || s[i+1] == '\\')) r << s[++i];
      else r << s[i];
    return r;
  }
  else return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int search_backwards ( string  what,
string  in 
)

Definition at line 1140 of file analyze.cpp.

                                       {
  return search_backwards (s, N(in)-N(s), in);
}

Here is the call graph for this function:

int search_backwards ( string  what,
int  pos,
string  in 
)

Definition at line 1131 of file analyze.cpp.

                                                {
  while (pos >= 0) {
    if (test (in, pos, s)) return pos;
    pos--;
  }
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int search_forwards ( string  what,
string  in 
)

Definition at line 1121 of file analyze.cpp.

                                      {
  return search_forwards (s, 0, in);
}

Here is the call graph for this function:

int search_forwards ( string  what,
int  pos,
string  in 
)

Definition at line 1109 of file analyze.cpp.

                                               {
  int k= N(s), n= N(in);
  if (k == 0) return pos;
  char c= s[0];
  while (pos+k <= n) {
    if (in[pos] == c && test (in, pos, s)) return pos;
    pos++;
  }
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void skip_line ( string  s,
int &  i 
)

Definition at line 1042 of file analyze.cpp.

                             {
  int n=N(s);
  while ((i<n) && (s[i]!='\n')) i++;
  if (i<n) i++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void skip_spaces ( string  s,
int &  i 
)

Definition at line 1036 of file analyze.cpp.

                               {
  int n=N(s);
  while ((i<n) && ((s[i]==' ') || (s[i]=='\t'))) i++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void skip_symbol ( string  s,
int &  i 
)

Definition at line 1049 of file analyze.cpp.

                               {
  int n=N(s);
  if (i<n) {
    if (s[i]=='<') {
      for (i++; i<n; i++)
       if (s[i-1]=='>') break;
    }
    else i++;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 220 of file analyze.cpp.

                               {
  int i, n= N(s);
  string r;
  for (i=0; i<n; i++)
    switch (s[i]) {
    case '': r << "'A"; break;
    case '': r << "'E"; break;
    case '': r << "'I"; break;
    case '': r << "'N"; break;
    case '': r << "'O"; break;
    case '': r << "'U"; break;
    case '': r << "'Y"; break;
    case '': r << "'a"; break;
    case '': r << "'e"; break;
    case '': r << "'i"; break;
    case '': r << "'n"; break;
    case '': r << "'o"; break;
    case '': r << "'u"; break;
    case '': r << "'y"; break;
    default : r << s[i];
    }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool starts ( string  s,
const char *  test 
)

Definition at line 930 of file analyze.cpp.

                                    {
  return test (s, 0, what);
}

Here is the call graph for this function:

bool starts ( string  s,
const string  test 
)

Definition at line 935 of file analyze.cpp.

                                     {
  return test (s, 0, what);
}

Here is the call graph for this function:

string string_minus ( string  s1,
string  s2 
)

Definition at line 175 of file analyze.cpp.

                                    {
  string r;
  int i1, n1= N(s1), i2, n2= N(s2);
  for (i1=0; i1<n1; i1++) {
    for (i2=0; i2<n2; i2++)
      if (s1[i1] == s2[i2]) break;
    if (i2==n2) r << s1[i1];
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string string_union ( string  s1,
string  s2 
)

Definition at line 170 of file analyze.cpp.

                                    {
  return string_minus (s1, s2) * s2;
}

Here is the call graph for this function:

Here is the caller graph for this function:

array<string> strip_completions ( array< string a,
string  prefix 
)

Definition at line 1288 of file analyze.cpp.

                                                   {
  int i, n= N(a);
  array<string> b;
  for (i=0; i<n; i++)
    if (starts (a[i], prefix))
      b << a[i] (N(prefix), N(a[i]));
  return b;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool test ( string  s,
int  i,
const char *  test 
)

Definition at line 908 of file analyze.cpp.

                                         {
  int n= N(s), j=0;
  while (test[j]!='\0') {
    if (i>=n) return false;
    if (s[i]!=test[j]) return false;
    i++; j++;
  }
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool test ( string  s,
int  i,
string  test 
)

Definition at line 919 of file analyze.cpp.

                                    {
  int n= N(s), m= N(test), j=0;
  while (j<m) {
    if (i>=n) return false;
    if (s[i]!=test[j]) return false;
    i++; j++;
  }
  return true;
}

Here is the call graph for this function:

string tm_backward_access ( string  s,
int  i 
)

Definition at line 740 of file analyze.cpp.

                                     {
  int pos= N(s);
  for (int i=0; i<k; i++)
    tm_char_backwards (s, pos);
  int end= pos;
  tm_char_backwards (s, pos);
  return s (pos, end);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tm_char_backwards ( string  s,
int &  pos 
)

Definition at line 707 of file analyze.cpp.

                                       {
  ASSERT (pos >= 0 && pos <= N(s), "out of range");
  if (pos == 0);
  else if (s[pos-1] != '>') pos--;
  else {
    while (pos>0 && s[pos-1] != '<') pos--;
    if (pos>0) pos--;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tm_char_forwards ( string  s,
int &  pos 
)

Definition at line 695 of file analyze.cpp.

                                      {
  ASSERT (pos >= 0 && pos <= N(s), "out of range");
  int n= N(s);
  if (pos == n);
  else if (s[pos] != '<') pos++;
  else {
    while (pos<n && s[pos] != '>') pos++;
    if (pos<n) pos++;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tm_char_next ( string  s,
int  pos 
)

Definition at line 718 of file analyze.cpp.

                                 {
  tm_char_forwards (s, pos);
  return pos;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tm_char_previous ( string  s,
int  pos 
)

Definition at line 724 of file analyze.cpp.

                                     {
  tm_char_backwards (s, pos);
  return pos;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 674 of file analyze.cpp.

                      {
  register int i;
  string r;
  for (i=0; i<N(s); i++) {
    if (s[i]=='<') {
      register bool flag= true;
      register int j, k;
      for (j=i+1; j<N(s); j++)
       if (s[j]=='>') break;
      if (j==N(s)) return r;
      for (k=i+1; k<j; k++)
       if (s[k]=='<') flag= false;
      if (flag) r << s(i,j+1);
      i=j;
    }
    else if (s[i]!='>') r << s[i];
  }
  return r;
}

Here is the call graph for this function:

Definition at line 635 of file analyze.cpp.

                     {
  // TeXmacs encoding to verbatim
  register int i;
  string r;
  for (i=0; i<N(s); i++) {
    if (s[i]=='<') {
      register int j;
      for (j=i+1; j<N(s); j++)
       if (s[j]=='>') break;
      if (j<N(s)) j++;
      if (s(i,j) == "<less>") r << "<";
      else if (s(i,j) == "<gtr>") r << ">";
      i=j-1;
      if (s[i]!='>') return r;
    }
    else if (s[i]!='>') r << s[i];
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 622 of file analyze.cpp.

                     {
  // verbatim to TeXmacs encoding
  register int i;
  string r;
  for (i=0; i<N(s); i++) {
    if (s[i]=='<') r << "<less>";
    else if (s[i]=='>') r << "<gtr>";
    else r << s[i];
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string tm_forward_access ( string  s,
int  i 
)

Definition at line 730 of file analyze.cpp.

                                    {
  int pos= 0;
  for (int i=0; i<k; i++)
    tm_char_forwards (s, pos);
  int start= pos;
  tm_char_forwards (s, pos);
  return s (start, pos);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 772 of file analyze.cpp.

                               {
  string r;
  for (int i=0; i<N(a); i++)
    r << a[i];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 750 of file analyze.cpp.

                            {
  int i= 0, pos= 0;
  while (pos < N(s)) {
    tm_char_forwards (s, pos);
    i++;
  }
  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 448 of file analyze.cpp.

                           {
  array<object> a;
  a << symbol_object ("!concat");
  string r;
  int i, n= N(s);
  for (i=0; i<n; i++)
    if (s[i] == '&') r << "&amp;";
    else if (s[i] == '>') r << "&gt;";
    else if (s[i] == '\\') r << "\\";
    else if (s[i] != '<') r << cork_to_utf8 (s (i, i+1));
    else {
      int start= i++;
      while ((i<n) && (s[i]!='>')) i++;
      string ss= s (start, i+1);
      string rr= cork_to_utf8 (ss);
      string qq= utf8_to_cork (rr);
      if (rr != ss && qq == ss) r << rr;
      else {
       if (r != "") a << object (r);
       a << cons (symbol_object ("tm-sym"),
                 cons (ss (1, N(ss)-1),
                      null_object ()));
       r= "";
      }
    }
  if (r != "") a << object (r);
  if (N(a) == 1) return object ("");
  else if (N(a) == 2) return a[1];
  else return call ("list", a);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 408 of file analyze.cpp.

                          {
  string r;
  int i, n= N(s);
  for (i=0; i<n; i++)
    if (is_xml_name (s[i])) r << s[i];
    else r << "_" << as_string ((int) ((unsigned char) s[i])) << "_";
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 760 of file analyze.cpp.

                       {
  array<string> r;
  int pos= 0;
  while (pos < N(s)) {
    int start= pos;
    tm_char_forwards (s, pos);
    r << s (start, pos);
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 656 of file analyze.cpp.

                         {
  register int i, n= N(s);
  string r;
  for (i=0; i<n; i++) {
    if (s[i]=='<') {
      if (i+1 < n && s[i+1] == '#') {
       while (i<n && s[i] != '>') r << s[i++];
       if (i<n) r << s[i];
      }
      else r << "<less>";
    }
    else if (s[i]=='>') r << "<gtr>";
    else r << s[i];
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

array<string> tokenize ( string  s,
string  sep 
)

Definition at line 1193 of file analyze.cpp.

                                {
  int start=0;
  array<string> a;
  for (int i=0; i<N(s); )
    if (test (s, i, sep)) {
      a << s (start, i);
      i += N(sep);
      start= i;
    }
    else i++;
  return a;
}

Here is the call graph for this function:

Definition at line 1217 of file analyze.cpp.

                       {
  int start, end;
  for (start=0; start<N(s) && is_space (s[start]); start++);
  for (end=N(s); end>start && is_space (s[end]); end--);
  return s (start, end);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1225 of file analyze.cpp.

                              {
  array<string> b (N(a));
  for (int i=0; i<N(a); i++)
    b[i]= trim_spaces (a[i]);
  return b;
}

Here is the call graph for this function:

char upcase ( char  s)

Definition at line 120 of file analyze.cpp.

                {
  if (is_locase (c))
    return (char) (((int) ((unsigned char) c)) - 32);
  else return c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 146 of file analyze.cpp.

                      {
  int i;
  string r (N(s));
  for (i=0; i<N(s); i++)
    if (!is_locase (s[i])) r[i]= s[i];
    else r[i]= (char) (((int) ((unsigned char) s[i]))-32);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 134 of file analyze.cpp.

                        {
  if ((N(s)==0) || (!is_locase (s[0]))) return s;
  return string ((char) (((int) ((unsigned char) s[0]))-32)) * s (1, N(s));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 418 of file analyze.cpp.

                          {
  string r;
  int i, n= N(s);
  for (i=0; i<n; i++)
    if (s[i] != '_') r << s[i];
    else {
      int start= ++i;
      while ((i<n) && (s[i]!='_')) i++;
      r << (char) ((unsigned char) as_int (s (start, i)));
    }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string xml_unspace ( string  s,
bool  first,
bool  last 
)

Definition at line 498 of file analyze.cpp.

                                              {
  string r;
  int i= 0, n= N(s);
  if (first) while ((i<n) && is_space (s[i])) i++;
  while (i<n)
    if (!is_space (s[i])) r << s[i++];
    else {
      while ((i<n) && is_space (s[i])) i++;
      if ((i<n) || (!last)) r << ' ';
    }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function: