~ubuntu-branches/ubuntu/quantal/texmacs/quantal

« back to all changes in this revision

Viewing changes to src/Typeset/Env/env_exec.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Atsuhito KOHDA, Kamaraju Kusumanchi, kohda
  • Date: 2008-04-06 15:11:41 UTC
  • mfrom: (1.1.7 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080406151141-w0sg20jnv86mlt6f
Tags: 1:1.0.6.14-1
[Kamaraju Kusumanchi <kamaraju@gmail.com>]
* New upstream release
* 01_american.dpatch is updated
* Since thread support in guile-1.8 is now disabled, the segmentation faults
  should not arise anymore. More info at #439923. (Closes: #450499, #458685)
[kohda]
* This version fixed menu problem.  (Closes: #447083)
* Reverted orig.tar.gz to the upstream tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#include "file.hpp"
16
16
#include "image_files.hpp"
17
17
#include "scheme.hpp"
18
 
#include "PsDevice/page_type.hpp"
 
18
#include "page_type.hpp"
19
19
#include "typesetter.hpp"
20
20
#include "drd_mode.hpp"
 
21
#include "dictionary.hpp"
21
22
 
22
23
extern int script_status;
23
24
 
69
70
    {
70
71
      if (!(is_atomic (t[0]) && is_atomic (t[1]) && is_atomic (t[2])))
71
72
        return tree (ERROR, "invalid map arguments");
72
 
      if (nil (macro_arg) || (!macro_arg->item->contains (t[2]->label)))
 
73
      if (is_nil (macro_arg) || (!macro_arg->item->contains (t[2]->label)))
73
74
        return tree (ERROR, "map arguments " * t[2]->label);
74
75
      tree v= macro_arg->item [t[2]->label];
75
76
      if (is_atomic (v))
76
77
        return tree (ERROR, "map arguments " * t[2]->label);
77
78
      list<hashmap<string,tree> > old_var= macro_arg;
78
79
      list<hashmap<string,path> > old_src= macro_src;
79
 
      if (!nil (macro_arg)) macro_arg= macro_arg->next;
80
 
      if (!nil (macro_src)) macro_src= macro_src->next;
 
80
      if (!is_nil (macro_arg)) macro_arg= macro_arg->next;
 
81
      if (!is_nil (macro_src)) macro_src= macro_src->next;
81
82
 
82
83
      int start= 0, end= N(v);
83
84
      if (N(t)>=4) start= as_int (exec (t[3]));
102
103
    {
103
104
      if ((!is_func (t[0], ARG)) ||
104
105
          is_compound (t[0][0]) ||
105
 
          nil (macro_arg) ||
 
106
          is_nil (macro_arg) ||
106
107
          (!macro_arg->item->contains (t[0][0]->label)))
107
108
        return tree (ERROR, "invalid rewrite-inactive");
108
109
      tree val= macro_arg->item [t[0][0]->label];
151
152
tree
152
153
texmacs_exec (edit_env env, tree cmd) {
153
154
  // re-entrancy
154
 
  if (!nil (current_rewrite_env)) env= current_rewrite_env;
 
155
  if (!is_nil (current_rewrite_env)) env= current_rewrite_env;
155
156
  return env->exec (cmd);
156
157
}
157
158
 
626
627
  tree r= t[0];
627
628
  if (is_compound (r))
628
629
    return tree (ERROR, "bad argument application");
629
 
  if (nil (macro_arg) || (!macro_arg->item->contains (r->label)))
 
630
  if (is_nil (macro_arg) || (!macro_arg->item->contains (r->label)))
630
631
    return tree (ERROR, "argument " * r->label);
631
632
  r= macro_arg->item [r->label];
632
633
  list<hashmap<string,tree> > old_var= macro_arg;
633
634
  list<hashmap<string,path> > old_src= macro_src;
634
 
  if (!nil (macro_arg)) macro_arg= macro_arg->next;
635
 
  if (!nil (macro_src)) macro_src= macro_src->next;
 
635
  if (!is_nil (macro_arg)) macro_arg= macro_arg->next;
 
636
  if (!is_nil (macro_src)) macro_src= macro_src->next;
636
637
  if (N(t) > 1) {
637
638
    int i, n= N(t);
638
639
    for (i=1; i<n; i++) {
656
657
  tree r= t[0];
657
658
  if (is_compound (r))
658
659
    return tree (ERROR, "bad quoted argument application");
659
 
  if (nil (macro_arg) || (!macro_arg->item->contains (r->label)))
 
660
  if (is_nil (macro_arg) || (!macro_arg->item->contains (r->label)))
660
661
    return tree (ERROR, "quoted argument " * r->label);
661
662
  r= macro_arg->item [r->label];
662
663
  if (N(t) > 1) {
694
695
tree
695
696
edit_env_rep::exec_eval_args (tree t) {
696
697
  tree v= macro_arg->item [as_string (t[0])];
697
 
  if (is_atomic (v) || nil (macro_arg))
 
698
  if (is_atomic (v) || is_nil (macro_arg))
698
699
    return tree (ERROR, "eval arguments " * t[0]->label);
699
700
  list<hashmap<string,tree> > old_var= macro_arg;
700
701
  list<hashmap<string,path> > old_src= macro_src;
701
 
  if (!nil (macro_arg)) macro_arg= macro_arg->next;
702
 
  if (!nil (macro_src)) macro_src= macro_src->next;
 
702
  if (!is_nil (macro_arg)) macro_arg= macro_arg->next;
 
703
  if (!is_nil (macro_src)) macro_src= macro_src->next;
703
704
 
704
705
  int i, n= N(v);
705
706
  tree r (v, n);
1194
1195
  tree t3= exec (t[2]);
1195
1196
  if (is_compound (t1) || is_compound (t2) || is_compound (t3))
1196
1197
    return tree (ERROR, "bad translate");
1197
 
  return dis->translate (t1->label, t2->label, t3->label);
 
1198
  return translate (t1->label, t2->label, t3->label);
1198
1199
}
1199
1200
 
1200
1201
tree
1523
1524
tree
1524
1525
edit_env_rep::exec_frame_direct (tree t) {
1525
1526
  tree t1= exec (t[0]);
1526
 
  return as_tree (!nil (fr) ? fr (::as_point (t1)) : point ());
 
1527
  return as_tree (!is_nil (fr) ? fr (::as_point (t1)) : point ());
1527
1528
}
1528
1529
 
1529
1530
tree
1530
1531
edit_env_rep::exec_frame_inverse (tree t) {
1531
1532
  tree t1= exec (t[0]);
1532
 
  return as_tree (!nil (fr) ? fr [::as_point (t1)] : point ());
 
1533
  return as_tree (!is_nil (fr) ? fr [::as_point (t1)] : point ());
1533
1534
}
1534
1535
 
1535
1536
/******************************************************************************
1539
1540
void
1540
1541
edit_env_rep::exec_until (tree t, path p) {
1541
1542
  // cout << "Execute " << t << " until " << p << "\n";
1542
 
  if (nil (p)) return;
1543
 
  if (atom (p)) {
 
1543
  if (is_nil (p)) return;
 
1544
  if (is_atom (p)) {
1544
1545
    if (p->item!=0)
1545
1546
      (void) exec (t);
1546
1547
    return;
1952
1953
edit_env_rep::exec_until_arg (tree t, path p, string var, int level) {
1953
1954
  // cout << "  " << macro_arg << "\n";
1954
1955
  tree r= t[0];
1955
 
  if (is_atomic (r) && (!nil (macro_arg)) &&
 
1956
  if (is_atomic (r) && (!is_nil (macro_arg)) &&
1956
1957
      macro_arg->item->contains (r->label))
1957
1958
    {
1958
1959
      bool found;
1959
1960
      tree arg= macro_arg->item [r->label];
1960
1961
      list<hashmap<string,tree> > old_var= macro_arg;
1961
1962
      list<hashmap<string,path> > old_src= macro_src;
1962
 
      if (!nil (macro_arg)) macro_arg= macro_arg->next;
1963
 
      if (!nil (macro_src)) macro_src= macro_src->next;
 
1963
      if (!is_nil (macro_arg)) macro_arg= macro_arg->next;
 
1964
      if (!is_nil (macro_src)) macro_src= macro_src->next;
1964
1965
      if (level == 0) {
1965
1966
        found= (r->label == var);
1966
1967
        if ((N(t) > 1) && found) {
1969
1970
            tree u= exec (t[i]);
1970
1971
            if (!is_int (u)) { found= false; break; }
1971
1972
            int nr= as_int (u);
1972
 
            if ((!is_compound (arg)) || (nr<0) || (nr>=N(arg)) || nil (p)) {
 
1973
            if ((!is_compound (arg)) || (nr<0) || (nr>=N(arg)) || is_nil (p)) {
1973
1974
              found= false; break; }
1974
1975
            if (p->item != nr) found= false;
1975
1976
            arg= arg[nr];
1988
1989
  /*
1989
1990
  cout << "  " << macro_arg << "\n";
1990
1991
  tree r= t[0];
1991
 
  if (is_atomic (r) && (r->label == var) && (!nil (macro_arg))) {
 
1992
  if (is_atomic (r) && (r->label == var) && (!is_nil (macro_arg))) {
1992
1993
    bool found= (level == 0) && macro_arg->item->contains (r->label);
1993
1994
    tree arg  = macro_arg->item [var];
1994
1995
    list<hashmap<string,tree> > old_var= macro_arg;
1995
1996
    list<hashmap<string,path> > old_src= macro_src;
1996
 
    if (!nil (macro_arg)) macro_arg= macro_arg->next;
1997
 
    if (!nil (macro_src)) macro_src= macro_src->next;
 
1997
    if (!is_nil (macro_arg)) macro_arg= macro_arg->next;
 
1998
    if (!is_nil (macro_src)) macro_src= macro_src->next;
1998
1999
    if (found) exec_until (arg, p);
1999
2000
    else found= exec_until (arg, p, var, level-1);
2000
2001
    macro_arg= old_var;
2011
2012
    // cout << "\n\tTest: " << t[0] << ", " << p << "\n";
2012
2013
    path q= p;
2013
2014
    int i, n= N(t[0]);
2014
 
    for (i=1; (!nil (q)) && (i<n); i++, q= q->next)
 
2015
    for (i=1; (!is_nil (q)) && (i<n); i++, q= q->next)
2015
2016
      if (t[0][i] != as_string (q->item))
2016
2017
        break;
2017
 
    border= (i == n) && atom (q);
 
2018
    border= (i == n) && is_atom (q);
2018
2019
    // FIXME: in order to be clean, we should check whether q->item
2019
2020
    // is on the border of the contents of the argument t[0].
2020
2021
    // Nevertheless, this only matters for strings and
2076
2077
 
2077
2078
tree
2078
2079
edit_env_rep::expand (tree t, bool search_accessible) {
2079
 
  if (is_atomic (t) || nil (macro_arg)) return t;
 
2080
  if (is_atomic (t) || is_nil (macro_arg)) return t;
2080
2081
  else if (is_func (t, ARG) || is_func (t, QUOTE_ARG)) {
2081
2082
    if (is_compound (t[0]))
2082
2083
      return tree (ERROR, "bad argument application");
2085
2086
    tree r= macro_arg->item [t[0]->label];
2086
2087
    list<hashmap<string,tree> > old_var= macro_arg;
2087
2088
    list<hashmap<string,path> > old_src= macro_src;
2088
 
    if (!nil (macro_arg)) macro_arg= macro_arg->next;
2089
 
    if (!nil (macro_src)) macro_src= macro_src->next;
 
2089
    if (!is_nil (macro_arg)) macro_arg= macro_arg->next;
 
2090
    if (!is_nil (macro_src)) macro_src= macro_src->next;
2090
2091
    if (N(t) > 1) {
2091
2092
      int i, n= N(t);
2092
2093
      for (i=1; i<n; i++) {
2129
2130
       << " " << macro_arg << "\n";
2130
2131
  */
2131
2132
 
2132
 
  if (is_atomic (t) || nil (macro_arg)) return false;
 
2133
  if (is_atomic (t) || is_nil (macro_arg)) return false;
2133
2134
  else if (is_func (t, ARG) ||
2134
2135
           is_func (t, QUOTE_ARG) ||
2135
2136
           is_func (t, MAP_ARGS) ||
2144
2145
      tree r= macro_arg->item [v->label];
2145
2146
      list<hashmap<string,tree> > old_var= macro_arg;
2146
2147
      list<hashmap<string,path> > old_src= macro_src;
2147
 
      if (!nil (macro_arg)) macro_arg= macro_arg->next;
2148
 
      if (!nil (macro_src)) macro_src= macro_src->next;
 
2148
      if (!is_nil (macro_arg)) macro_arg= macro_arg->next;
 
2149
      if (!is_nil (macro_src)) macro_src= macro_src->next;
2149
2150
      bool dep= depends (r, s, level-1);
2150
2151
      macro_arg= old_var;
2151
2152
      macro_src= old_src;