Back to index

texmacs  1.0.7.15
Functions
bibtex_functions.cpp File Reference
#include "bibtex_functions.hpp"
#include "vars.hpp"

Go to the source code of this file.

Functions

static string bib_parse_char (string s, int &pos, int &depth, bool &special, int &math)
static string bib_get_char (string s, int pos)
static bool bib_is_normal (string s)
static bool bib_is_space (string s)
static bool bib_is_char (string s, char c)
static string bib_to_latex (string s)
bool bib_is_bad (tree t)
char * bib_last_char (tree t)
scheme_tree bib_add_period (scheme_tree st)
char * bib_first_char (tree t)
scheme_tree bib_upcase_first (scheme_tree st)
void bib_change_case (tree &t, string(*change_case)(string))
scheme_tree bib_locase (scheme_tree st)
scheme_tree bib_upcase (scheme_tree st)
scheme_tree bib_default (scheme_tree st)
static bool search_and_keyword (string s, int &pos)
int bib_num_names (string s)
static bool bib_is_entry (tree t)
static bool bib_is_field (tree t)
static bool bib_is_comment (tree t)
static bool bib_is_var (tree t)
static bool bib_is_string (tree t)
static bool bib_is_assign (tree t)
static bool bib_is_preamble (tree t)
static bool bib_is_latex (tree t)
static bool bib_is_blank_string (string s)
static tree bib_assoc (tree entry, string key)
static list< stringget_words (string s)
static bool first_is_locase (string s)
static string get_fvl (string sfvl)
static string get_vl_f (string svl, string sf)
static string get_vl_j_f (string svl, string sj, string sf)
static string get_until_char (string s, int &pos, string c)
static string get_first_von_last (string s)
string bib_names (string s, int &nbfields)
void bib_purify_tree (tree t, string &res)
string bib_purify (scheme_tree st)
static int bib_tree_length (tree t)
int bib_text_length (scheme_tree st)
static void bib_get_prefix (tree t, string &pre, int &i)
string bib_prefix (scheme_tree st, int i)
static void get_first_letters (tree t, tree s1, tree s2, tree &l)
scheme_tree bib_abbreviate (scheme_tree st, scheme_tree s1, scheme_tree s2)
tree bib_field_pages (string p)
static int bib_get_fields (tree t, string &latex)
static void bib_set_fields (tree &t, array< tree > latex, int &ind)
static array< treebib_latex_array (tree latex)
void bib_parse_fields (tree &t)
scheme_tree bib_field (scheme_tree st, string field)
bool bib_empty (scheme_tree st, string f)
string bib_preamble (tree t)
hashmap< string, stringbib_strings_dict (tree t)
static string bib_subst_str (tree t, hashmap< string, string > dict)
tree bib_subst_vars (tree t, hashmap< string, string > dict)
static tree bib_select_entries (tree t, tree bib_t)
tree bib_entries (tree t, tree bib_t)

Function Documentation

Definition at line 768 of file bibtex_functions.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 205 of file bibtex_functions.cpp.

                                {
  tree t= simplify_correct (scheme_tree_to_tree (st));
  char* ch= bib_last_char (t);
  if (ch == 0) return tree_to_scheme_tree (t);
  if (*ch == ',' || *ch == ';') {
    *ch= '.';
    return tree_to_scheme_tree (t);
  }
  else if (*ch != '!' && *ch != '?' && *ch != '.') {
    tree res (CONCAT);
    res << t;
    res << ".";
    return tree_to_scheme_tree (res);
  }
  else return tree_to_scheme_tree (t);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static tree bib_assoc ( tree  entry,
string  key 
) [static]

Definition at line 410 of file bibtex_functions.cpp.

                                   {
  if (bib_is_entry (entry)) {
    tree doc= entry[2];
    for (int i= 0; i<N(doc); i++)
      if (bib_is_field (doc[i]) && doc[i][0]->label == key)
       return doc[i][1];
  }
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bib_change_case ( tree t,
string(*)(string change_case 
)

Definition at line 290 of file bibtex_functions.cpp.

                                                          {
  if (is_atomic (t) && change_case) t->label= change_case (t->label);
  else if (is_compound (t, "verbatim"));
  else if (L(t) == WITH) bib_change_case (t[N(t)-1], change_case);
  else if (L(t) == as_tree_label ("keepcase")) t= t[0];
  else if (L(t) == CONCAT || L(t) == DOCUMENT)
    for (int i= 0; i<N(t); i++) bib_change_case (t[i], change_case);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 314 of file bibtex_functions.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool bib_empty ( scheme_tree  st,
string  f 
)

Definition at line 920 of file bibtex_functions.cpp.

                                     {
  return (bib_field (st, f) == "");
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree bib_entries ( tree  t,
tree  bib_t 
)

Definition at line 1049 of file bibtex_functions.cpp.

                                 {
  hashmap<string,string> dict= bib_strings_dict (t);
  tree res= bib_select_entries (t, bib_t);
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

scheme_tree bib_field ( scheme_tree  st,
string  field 
)

Definition at line 903 of file bibtex_functions.cpp.

                                         {
  tree t= scheme_tree_to_tree (st);
  if (bib_is_entry (t)) {
    tree doc= t[2];
    for (int i= 0; i<N(doc); i++) {
      if (bib_is_field (doc[i]) && doc[i][0] == field)
        return tree_to_scheme_tree (doc[i][1]);
    }
  }
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 782 of file bibtex_functions.cpp.

                           {
  tree res= compound ("bib-pages");;
  int p1, p2;
  int pos= 0;
  if (read_int (p, pos, p1)) {
    res << as_string (p1);
    while (pos < N(p) && !is_digit (p[pos])) pos++;
    if (read_int (p, pos, p2))
      res << as_string (p2);
    return res;
  }
  res << "0";
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* bib_first_char ( tree  t)

Definition at line 227 of file bibtex_functions.cpp.

                        {
  if (is_atomic (t)) {
    string s= t->label;
    int beg= 0;
    while ((beg < N(s)) && is_space (s[beg])) beg++;
    if (beg < N(s)) return &(s[beg]);
    else return 0;
  }
  else if (is_compound (t, "verbatim"))
    return 0;
  else if (is_func (t, WITH, 3) && t[0] == FONT_FAMILY && t[1] == "tt")
    return 0;
  else {
    int pos= 0;
    if (L(t) == WITH) pos= N(t)-1;
    else while ((pos < N(t)) && bib_is_bad (t[pos])) pos++;
    if (pos < N(t)) return bib_first_char (t[pos]);
    else return 0;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string bib_get_char ( string  s,
int  pos 
) [static]

Definition at line 94 of file bibtex_functions.cpp.

                                 {
  int d= 0;
  bool sp= false;
  int m= 0;
  int p= pos;
  return bib_parse_char (s, p, d, sp, m);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int bib_get_fields ( tree  t,
string latex 
) [static]

Definition at line 798 of file bibtex_functions.cpp.

                                       {
  int nbfields= 0;
  for (int i= 0; i<N(t); i++) {
    if (bib_is_entry (t[i])) {
      for (int j= 0; j<N(t[i][2]); j++) {
        tree f= t[i][2][j];
        if (bib_is_field (f)) {
          if ((f[0]->label == "author" || f[0]->label == "editor") &&
              is_atomic (f[1])) {
            latex << bib_names (f[1]->label, nbfields);
          }
          else if (is_atomic (f[1]) && f[0]->label != "pages") {
            if (!bib_is_blank_string (f[1]->label)) {
              latex << "\\nextbib{}" << bib_to_latex (f[1]->label);
              nbfields++;;
            }
            else {
              latex << "\\nextbib{}";
              nbfields++;
            }
          }
        }
      }
    }
    else if (bib_is_comment (t[i]))
      nbfields += bib_get_fields (t[i], latex);
  }
  return nbfields;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void bib_get_prefix ( tree  t,
string pre,
int &  i 
) [static]

Definition at line 681 of file bibtex_functions.cpp.

                                             {
  if (i > 0) {
    if (is_atomic (t)) {
      string s= t->label;
      int beg= 0;
      while ((beg < N(s)) && (i > 0)) {
        pre << s[beg];
        beg++;
        i--;
      }
      return;
    }
    else {
      int pos= 0;
      if (L(t) == WITH) pos= N(t)-1;
      else if (L(t) == CONCAT || L(t) == DOCUMENT)
        for (int j= pos; j<N(t); j++) bib_get_prefix (t[j], pre, i);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_assign ( tree  t) [static]

Definition at line 384 of file bibtex_functions.cpp.

                       {
  return as_string (L(t)) == "bib-assign" && arity (t) == 2 &&
         is_atomic (t[0]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool bib_is_bad ( tree  t)

Definition at line 177 of file bibtex_functions.cpp.

                    {
  if (is_atomic(t)) {
    string s= t->label;
    for (int i= N(s); i >= 0; i--)
      if (!is_space (s[i])) return false;
    return true;
  }
  else return (N(t) == 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_blank_string ( string  s) [static]

Definition at line 403 of file bibtex_functions.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_char ( string  s,
char  c 
) [static]

Definition at line 126 of file bibtex_functions.cpp.

                               {
  return (N(s) == 1) && (s[0] == c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_comment ( tree  t) [static]

Definition at line 368 of file bibtex_functions.cpp.

                        {
  return (as_string (L (t)) == "bib-comment"); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_entry ( tree  t) [static]

Definition at line 356 of file bibtex_functions.cpp.

                      {
  return (as_string (L (t)) == "bib-entry") && (arity (t) == 3) &&
         is_atomic (t[0]) && is_atomic (t[1]) && (L(t[2]) == DOCUMENT); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_field ( tree  t) [static]

Definition at line 362 of file bibtex_functions.cpp.

                      {
  return (as_string (L (t)) == "bib-field") && (arity (t) == 2) &&
         is_atomic (t[0]); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_latex ( tree  t) [static]

Definition at line 396 of file bibtex_functions.cpp.

                      {
  return as_string (L(t)) == "bib-latex" && arity (t) == 1 &&
         is_atomic (t[0]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_normal ( string  s) [static]

Definition at line 103 of file bibtex_functions.cpp.

                         {
  return (N(s) == 1) && (s[0] != '{') && (s[0] != '}') &&
         (s[0] != '\\') && !is_space (s[0]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_preamble ( tree  t) [static]

Definition at line 390 of file bibtex_functions.cpp.

                         {
  return as_string (L(t)) == "bib-preamble" && arity (t) == 1 &&
         L(t[0]) == DOCUMENT;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_space ( string  s) [static]

Definition at line 109 of file bibtex_functions.cpp.

                        {
  return (N(s) == 1) && is_space (s[0]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_string ( tree  t) [static]

Definition at line 378 of file bibtex_functions.cpp.

                       {
  return as_string (L(t)) == "bib-string" && arity (t) == 1 &&
         L(t[0]) == DOCUMENT;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool bib_is_var ( tree  t) [static]

Definition at line 373 of file bibtex_functions.cpp.

                    {
  return as_string (L(t)) == "bib-var" && arity (t) == 1 && is_atomic (t[0]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* bib_last_char ( tree  t)

Definition at line 188 of file bibtex_functions.cpp.

                       {
  if (is_atomic (t)) {
    string s= t->label;
    int end= N(s)-1;
    while ((end >= 0) && is_space (s[end])) end--;
    if (end >= 0) return &(s[end]);
    else return 0;
  }
  else {
    int pos= N(t)-1;
    while ((pos >= 0) && bib_is_bad (t[pos])) pos--;
    if (pos >= 0) return bib_last_char (t[pos]);
    else return 0;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static array<tree> bib_latex_array ( tree  latex) [static]

Definition at line 865 of file bibtex_functions.cpp.

                             {
  int i= 0;
  array<tree> res;
  while (i < N(latex) && latex[i] == compound ("nextbib", "")) {
    i++;
    if (i < N(latex)) {
      if (latex[i] == compound ("bibnames")
          || latex[i] == compound ("bibname")) {
        res << simplify_correct (latex[i]);
        i++;
      }
      else {
        tree elt (CONCAT);
        while (i < N(latex) && latex[i] != compound ("nextbib", "")) {
          elt << latex[i];
          i++;
        }
        res << simplify_correct (elt);
      }
    }
  }
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 300 of file bibtex_functions.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

string bib_names ( string  s,
int &  nbfields 
)

Definition at line 576 of file bibtex_functions.cpp.

                                    {
  string res;
  int pos= 0;
  nbfields++;
  res << "\\nextbib{}{\\bibnames}";
  while (pos < N(s)) {
    string name;
    int deb= pos;
    search_and_keyword (s, pos);
    int pos2= pos;
    if (pos < N(s)) pos -= 5;
    if (pos <= N(s) && deb < pos) name= s (deb, pos);
    res << "\\nextbib{}{\\bibname}";
    res << get_first_von_last (name);
    nbfields += 5;
    pos= pos2;
  }
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int bib_num_names ( string  s)

Definition at line 343 of file bibtex_functions.cpp.

                         {
  int pos= 0;
  int nband= 0;
  while (pos < N(s))
    if (search_and_keyword (s, pos)) nband++;
  return nband+1;
}

Here is the call graph for this function:

static string bib_parse_char ( string  s,
int &  pos,
int &  depth,
bool &  special,
int &  math 
) [static]

Definition at line 20 of file bibtex_functions.cpp.

                                                                          {
  switch (s[pos]) {
    case '{': {
      pos++;
      if (pos < N(s) && s[pos] == '\\' && depth == 0) special= true;
      depth++;
      return "{";
    }
    case '}': {
      pos++;
      depth--;
      if (special && depth == 0) special= false;
      return "}";
    }
    case '\\': {
      string r= "\\";
      pos++;
      if (pos < N(s) && (s[pos] == '{' || s[pos] == '}')) {
        r << s[pos];
        pos++;
      }
      else /* if (special) */ {
        if (pos < N(s) && !is_alpha (s[pos]) && !is_digit (s[pos])) {
          r << s[pos];
          pos++;
        }
        else {
          while (pos < N(s) && (is_alpha (s[pos]) || is_digit (s[pos]))) {
            r << s[pos];
            pos++;
          }
        }
        if (pos < N(s) && (is_alpha (s[pos]) || is_digit (s[pos]))) {
          r << s[pos];
          pos++;
        }
        else if (pos < N(s) && s[pos] == '{') {
          int d= 1;
          r << s[pos];
          pos++;
          while (pos < N(s) && d > 0) {
            if (s[pos] == '{') d++;
            if (s[pos] == '}') d--;
            r << s[pos];
            pos++;
          }
        }
      }
      return r;
    }
    case '$': {
      pos++;
      if (pos < N(s) && s[pos] == '$') {
        if (math == 2) math= 0;
        else math= 2;
        pos++;
        return "$$";
      }
      else {
        if (math == 1) math= 0;
        else math= 1;
        return "$";
      }
    }
    default: {
      string r;
      r << s[pos];
      pos++;
      return r;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bib_parse_fields ( tree t)

Definition at line 890 of file bibtex_functions.cpp.

                           {
  string fields;
  int i= 0;
  int nb= bib_get_fields (t, fields);
  array<tree> latex= bib_latex_array (latex_to_tree (parse_latex (fields)));
  if (nb == N(latex)) bib_set_fields (t, latex, i);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 929 of file bibtex_functions.cpp.

                      {
  string pre;
  if (bib_is_preamble (t)) {
    tree doc= t[0];
    for (int i= 0; i<N(doc); i++)
      if (bib_is_latex (doc[i]))
       pre << "\n" << doc[i][0]->label;
  }
  return pre;
}

Here is the call graph for this function:

string bib_prefix ( scheme_tree  st,
int  i 
)

Definition at line 703 of file bibtex_functions.cpp.

                                   {
  tree t= simplify_correct (scheme_tree_to_tree (st));
  string pre;
  int j= i;
  bib_get_prefix (t, pre, j);
  return pre; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 612 of file bibtex_functions.cpp.

                            {
  tree t= simplify_correct (scheme_tree_to_tree (st));
  string res;
  bib_purify_tree (t, res);
  return res; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bib_purify_tree ( tree  t,
string res 
)

Definition at line 601 of file bibtex_functions.cpp.

                                      {
  if (is_atomic (t)) res << t->label;
  else if (L(t) == WITH) bib_purify_tree (t[N(t)-1], res);
  else if (L(t) == as_tree_label ("keepcase")) bib_purify_tree (t[0], res);
  else if (L(t) == CONCAT || L(t) == DOCUMENT) {
    for (int i= 0; i<N(t); i++) bib_purify_tree (t[i], res);
  }
  cout << UNINDENT;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static tree bib_select_entries ( tree  t,
tree  bib_t 
) [static]

Definition at line 1028 of file bibtex_functions.cpp.

                                        {
  hashmap<string, tree> h;
  hashset<string> r;
  tree entries (DOCUMENT);
  tree bt= copy (bib_t);
  for (int i= 0; i<N(t); i++)
    if (bib_is_entry (t[i]))
      h(t[i][1]->label)= t[i];
  for (int i= 0; i < arity (bt); i++) {
    string b= as_string (bt[i]);
    if (h->contains (b) && !r->contains (b)) {
      r->insert (b);
      entries << h[b];
      tree cr= bib_assoc (h[b], string ("crossref"));
      if (cr != "") bt << as_string (cr);
    }
  }
  return entries;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void bib_set_fields ( tree t,
array< tree latex,
int &  ind 
) [static]

Definition at line 829 of file bibtex_functions.cpp.

                                                      {
  for (int i= 0; i<N(t); i++) {
    if (bib_is_entry (t[i])) {
      //cout << "Changing " << t[i] << "\n";
      for (int j= 0; j<N(t[i][2]); j++) {
        tree f= t[i][2][j];
        //cout << "  Field " << f << "\n";
        if (bib_is_field (f)) {
          if ((f[0]->label == "author" || f[0]->label == "editor") &&
              is_atomic (f[1])) {
            tree res= compound ("bib-names"); ind++;
            while (latex[ind] == compound ("bibname")) {
              tree name= compound ("bib-name"); ind++;
              name << latex[ind]; ind++;
              name << latex[ind]; ind++;
              name << latex[ind]; ind++;
              name << latex[ind]; ind++;
              res << name;
            }
            f[1]= res;
          }
          else if (f[0]->label == "pages" && is_atomic (f[1]))
            f[1]= bib_field_pages (f[1]->label);
          else {
            f[1]= latex[ind];
            ind++;
          }
        }
      }
    }
    else if (bib_is_comment (t[i]))
      bib_set_fields (t[i], latex, ind);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 945 of file bibtex_functions.cpp.

                          {
  hashmap<string,string> dict ("");
  dict("acmcs")= "ACM Computing Surveys";
  dict("acta")= "Acta Informatica";
  dict("cacm")= "Communications of the ACM";
  dict("ibmjrd")= "IBM Journal of Research and Development";
  dict("ibmsj")= "IBM Systems Journal";
  dict("ieeese")= "IEEE Transactions on Software Engineering";
  dict("ieeetc")= "IEEE Transactions on Computers";
  dict("ieeetcad")= "IEEE Transactions on Computer-Aided Design of Integrated Circuits";
  dict("ipl")= "Information Processing Letters";
  dict("jacm")= "Journal of the ACM";
  dict("jcss")= "Journal of Computer and System Sciences";
  dict("scp")= "Science of Computer Programming";
  dict("sicomp")= "SIAM Journal on Computing";
  dict("tocs")= "ACM Transactions on Computer Systems";
  dict("tods")= "ACM Transactions on Database Systems";
  dict("tog")= "ACM Transactions on Graphics";
  dict("toms")= "ACM Transactions on Mathematical Software";
  dict("toois")= "ACM Transactions on Office Information Systems";
  dict("toplas")= "ACM Transactions on Programming Languages and Systems";
  dict("tcs")= "Theoretical Computer Science";
  if (L(t) == DOCUMENT) {
    tree str (DOCUMENT);
    for (int i= 0; i<N(t); i++) {
      if (bib_is_string (t[i])) {
        str= t[i][0];
        break;
      }
    }
    for (int i= 0; i<N(str); i++) {
      if (bib_is_assign (str[i])) {
        string key= locase_all (str[i][0]->label);
        tree val= str[i][1];
        if (L(val) == CONCAT) {
          string sval;
          for (int j= 0; j<N(val); j++) {
            if (is_atomic (val[j])) sval << val[j]->label;
            else if (bib_is_var (val[j])) sval << dict[val[j][0]->label];
          }
          dict(key)= sval;
        }
        else if (is_atomic (val))
          dict(key)= val->label;
      }
    }
  }
  return dict;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string bib_subst_str ( tree  t,
hashmap< string, string dict 
) [static]

Definition at line 996 of file bibtex_functions.cpp.

                                                    {
  if (is_atomic (t)) return t->label;
  else if (L(t) == CONCAT) {
    string s;
    for (int i= 0; i<N(t); i++) {
      if (bib_is_var (t[i])) s << dict[locase_all (t[i][0]->label)];
      else if (is_atomic (t[i])) s << t[i]->label;
      else s << bib_subst_str (t[i], dict);
    }
    return s;
  }
  else if (bib_is_var (t)) {
    string key= locase_all (t[0]->label);
    if (dict->contains (key)) return dict[locase_all (t[0]->label)];
    else return t[0]->label;
  }
  else return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree bib_subst_vars ( tree  t,
hashmap< string, string dict 
)

Definition at line 1016 of file bibtex_functions.cpp.

                                                     {
  if (is_atomic (t) || L(t) == CONCAT || bib_is_var (t))
    return tree (copy (bib_subst_str (t, dict)));
  else {
    tree r (L(t), N(t));
    for (int i= 0; i<N(t); i++)
      r[i]= bib_subst_vars (t[i], dict);
    return r;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 671 of file bibtex_functions.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static string bib_to_latex ( string  s) [static]

Definition at line 131 of file bibtex_functions.cpp.

                        {
  string r= "{";
  int pos= 0;
  int depth= 0;
  bool special= false;
  bool specialsav= special;
  int math= 0;
  int keepcase= -1;
  while (pos < N(s)) {
    specialsav= special;
    string ch= bib_parse_char (s, pos, depth, special, math);
    //    cerr << ch << " " << as_string (keepcase) << " " << as_string (depth) << "\n";
    if (ch == "$$") r << "$";
    else if (special || math) r << ch;
    else if (bib_is_space (ch)) {
      if (keepcase == depth+1) {
        r << "} ";
        keepcase= -1;
      }
      else r << " ";
    }
    else if (ch == "%") r << "\\%";
    else if (bib_is_char (ch, '{') && depth > 0 &&
             bib_get_char (s, pos) != "\\") {
      if (keepcase == -1) {
        r << "\\keepcase{";
        keepcase= depth;
      }
      else if (keepcase < depth) r << "{";
    }
    else if (bib_is_char (ch, '}')) {
      if (keepcase <= depth || specialsav) r << ch;
    }
    else  r << ch;
  }
  for (int i= keepcase; i>0; i--) r << "}";
  r << "}";
  //  cerr << r << "\n";
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int bib_tree_length ( tree  t) [static]

Definition at line 660 of file bibtex_functions.cpp.

                         {
  if (is_atomic (t)) return N(t->label);
  else if (L(t) == WITH) return bib_tree_length (t[N(t)-1]);
  else if (L(t) == CONCAT || L(t) == DOCUMENT) {
    int s= 0;
    for (int i= 0; i<N(t); i++) s += bib_tree_length (t[i]);
  }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 307 of file bibtex_functions.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 249 of file bibtex_functions.cpp.

                                  {
  tree t= simplify_correct (scheme_tree_to_tree (st));
  char* ch= bib_first_char (t);
  if (ch != 0) *ch= upcase (*ch);
  return tree_to_scheme_tree (t); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool first_is_locase ( string  s) [static]

Definition at line 447 of file bibtex_functions.cpp.

                           {
  int pos= 0;
  int depth= 0;
  bool special= false;
  int math= 0;
  while (pos < N(s) && is_space (s[pos])) pos++;
  while (pos < N(s)) {
    string ch= bib_parse_char (s, pos, depth, special, math);
    if (bib_is_normal (ch))
      return (special || depth == 0) && is_locase (ch[0]);
  }
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void get_first_letters ( tree  t,
tree  s1,
tree  s2,
tree l 
) [static]

Definition at line 740 of file bibtex_functions.cpp.

                                                      {
  if (is_atomic (t)) {
    string s= t->label;
    int beg= 0;
    while (beg < N(s)) {
      while (beg < N(s) && is_space (s[beg])) beg++;
      if (beg < N(s)) {
        if (N(l) > 0) l << s2;
        l << s(beg, beg+1) << s1;
        while (beg < N(s) && !is_space (s[beg])) {
          beg++;
          if (beg < N(s) && s[beg] == '-') {
            beg++;
            l << "-" << s(beg, beg+1) << s1;
          }
        }
      }
    }
  }
  else {
    if (L(t) == WITH) get_first_letters (t[N(t)-1], s1, s2, l);
    else
      for (int pos= 0; pos<N(t); pos++)
        get_first_letters (t[pos], s1, s2, l);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string get_first_von_last ( string  s) [static]

Definition at line 555 of file bibtex_functions.cpp.

                              {
  string a, b, c;
  int pos= 0;
  a= get_until_char (s, pos, ",");
  b= get_until_char (s, pos, ",");
  c= get_until_char (s, pos, "");
  if (a != "" && b == "" && c == "") {
    string res= get_fvl (a);
    res << "\\nextbib{}";
    return res;
  }
  if (a != "" && b != "" && c == "") {
    string res= get_vl_f (a, b);
    res << "\\nextbib{}";
    return res;
  }
  if (a != "" && b != "" && c != "") return get_vl_j_f (a, b, c);
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string get_fvl ( string  sfvl) [static]

Definition at line 462 of file bibtex_functions.cpp.

                      {
  string w, res, f, v, l;
  list<string> words= get_words (sfvl);
  if (!is_nil (words)) l << words;
  bool all_up= true;
  for (int i= 0; i<N(words); i++)
    all_up= all_up && !first_is_locase (words[i]);
  if (!all_up) {
    while (!is_nil (words) && !first_is_locase (words[0])) {
      w << words;
      l= w << " " << l;
    }
    words= reverse (words);
    if (!is_nil (words) && !first_is_locase (words[0])) f << words;
    while (!is_nil (words) && !first_is_locase (words[0])) {
      w << words;
      f << " " << w;
    }
    if (!is_nil (words)) v << words;
    while (!is_nil (words)) {
      w << words;
      v << " " << w;
    }
  }
  else {
    if (!is_nil (words)) f << words;
    while (!is_nil (words)) {
      w << words;
      f= w << " " << f;
    }
  }
  res << "\\nextbib{}" << bib_to_latex (f);
  res << "\\nextbib{}" << bib_to_latex (v);
  res << "\\nextbib{}" << bib_to_latex (l);
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string get_until_char ( string  s,
int &  pos,
string  c 
) [static]

Definition at line 541 of file bibtex_functions.cpp.

                                              {
  string res;
  int depth= 0;
  bool special= false;
  int math= 0;
  while (pos < N(s)) {
    string ch= bib_parse_char (s, pos, depth, special, math);
    if (ch == c && depth == 0 && !special && math == 0) return res;
    else res << ch;
  }
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string get_vl_f ( string  svl,
string  sf 
) [static]

Definition at line 500 of file bibtex_functions.cpp.

                                 {
  string w, res, f, v, l;
  list<string> words= get_words (svl);
  if (!is_nil (words)) l << words;
  while (!is_nil (words) && !first_is_locase (words[0])) {
    w << words;
    l= w <<  " " << l;
  }
  if (!is_nil (words)) v << words;
  while (!is_nil (words)) {
    w << words;
    v= w << " " << v;
  }
  words= get_words (sf);
  if (!is_nil (words)) f << words;
  while (!is_nil (words)) {
    w << words;
    f= w << " " << f;
  }
  res << "\\nextbib{}" << bib_to_latex (f);
  res << "\\nextbib{}" << bib_to_latex (v);
  res << "\\nextbib{}" << bib_to_latex (l);
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string get_vl_j_f ( string  svl,
string  sj,
string  sf 
) [static]

Definition at line 526 of file bibtex_functions.cpp.

                                              {
  string res, j;
  res << get_vl_f (svl, sf);
  string w;
  list<string> words= get_words (sj);
  if (!is_nil (words)) j << words;
  while (!is_nil (words)) {
    w << words;
    j= w << " " << j;
  }
  res << "\\nextbib{}" << bib_to_latex (j);
  return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static list<string> get_words ( string  s) [static]

Definition at line 425 of file bibtex_functions.cpp.

                     {
  list<string> words;
  string curr;
  int pos= 0;
  int depth= 0;
  bool special= false;
  int math= 0;
  while (pos < N(s) && is_space (s[pos])) pos++;
  while (pos < N(s)) {
    string ch= bib_parse_char (s, pos, depth, special, math);
    if (bib_is_space (ch) && depth == 0) {
      while (pos < N(s) && is_space (s[pos])) pos++;
      curr >> words;
      curr= "";
    }
    else curr << ch;
  }
  if (curr != "") curr >> words;
  return words;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool search_and_keyword ( string  s,
int &  pos 
) [static]

Definition at line 325 of file bibtex_functions.cpp.

                                        {
  int depth= 0;
  bool special= false;
  int math= 0;
  while (pos < N(s)) {
    string ch= bib_parse_char (s, pos, depth, special, math);
    if (bib_is_space (ch) && depth == 0) {
      while (pos < N(s) && is_space (s[pos])) pos++;
      if (pos < N(s)-3 && s (pos, pos+3) == "and" && is_space (s[pos+3])) {
        pos += 4;
        return true;
      }
    }
  }
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function: